Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_hss
caicai8 5 years ago
commit cca8b5d88b

@ -3,6 +3,7 @@ $(document).on('turbolinks:load', function() {
if ($refuseModal.length > 0) {
var $form = $refuseModal.find('form.admin-common-refuse-form');
var $applyIdInput = $refuseModal.find('.modal-body input[name="apply_id"]');
var $applyTitle = $refuseModal.find('.modal-title');
$form.validate({
errorElement: 'span',
@ -21,9 +22,19 @@ $(document).on('turbolinks:load', function() {
var applyId = $link.data('id');
var url = $link.data('url');
var title = $link.data('title');
var type = $link.data('type');
var form_method = "POST";
if(typeof title !== 'undefined'){
$applyTitle.html(title)
}
if(typeof type !== 'undefined'){
form_method = type;
}
$applyIdInput.val(applyId);
$form.data('url', url);
$form.data('type', form_method);
});
// modal visited fire
$refuseModal.on('shown.bs.modal', function(){
@ -40,9 +51,10 @@ $(document).on('turbolinks:load', function() {
if ($form.valid()) {
var url = $form.data('url');
var form_method = $form.data('type');
$.ajax({
method: 'POST',
method: form_method,
dataType: 'script',
url: url,
data: $form.serialize(),

@ -0,0 +1,22 @@
$(document).on('turbolinks:load', function() {
var $editModal = $('.department-apply-edit-modal');
if($editModal.length > 0){
var $form = $editModal.find('form.department-apply-form');
var $applyIdInput = $form.find('input[name="id"]');
$editModal.on('show.bs.modal', function (event) {
var $link = $(event.relatedTarget);
var applyId = $link.data('id');
$applyIdInput.val(applyId);
});
$editModal.on('click', '.submit-btn', function(){
$.ajax({
method: "PUT",
dataType: 'script',
url: "/admins/department_applies/"+ $applyIdInput.val(),
data: $form.serialize(),
}).done(function(){
$editModal.modal('hide');
});
});
}
});

@ -0,0 +1,71 @@
class Admins::DepartmentAppliesController < Admins::BaseController
before_action :get_apply,only:[:agree,:edit,:update,:destroy]
def index
params[:status] ||= 0
params[:sort_by] = params[:sort_by].presence || 'created_at'
params[:sort_direction] = params[:sort_direction].presence || 'desc'
applies = Admins::DepartmentApplyQuery.call(params)
@depart_applies = paginate applies.preload(:school,user: :user_extension)
end
def agree
ActiveRecord::Base.transaction do
@depart_apply.update_attribute("status",1)
@depart_apply&.applied_messages&.update_all(status:1)
@depart_apply&.department&.update_attribute("is_auth",1)
@depart_apply&.user&.user_extension&.update_attribute("department_id",@depart_apply.department_id)
render_success_js
end
end
def update
depart_name = params[:name]
ActiveRecord::Base.transaction do
@depart_apply.update_attribute("name",depart_name)
@depart_apply&.department&.update_attribute("name",depart_name)
extra = depart_name + "(#{@depart_apply&.department&.school&.try(:name)})"
tiding_params = {
user_id: @depart_apply.user_id,
trigger_user_id: 0,
container_id: @depart_apply.id,
container_type: 'ApplyAddDepartment',
belong_container_id: @depart_apply.department.school_id,
belong_container_type: "School",
tiding_type: "System",
status: 3,
extra: extra
}
Tiding.create(tiding_params)
render_success_js
end
end
def destroy
ActiveRecord::Base.transaction do
@depart_apply.update_attribute("status",3)
@depart_apply&.applied_messages&.update_all(status:3)
@depart_apply&.department&.destroy
@depart_apply&.user&.user_extension&.update_attribute("department_id", nil)
tiding_params = {
user_id: @depart_apply.user_id,
trigger_user_id: 0,
container_id: @depart_apply.id,
container_type: 'ApplyAddDepartment',
belong_container_id: @depart_apply.department.school_id,
belong_container_type: "School",
tiding_type: "System",
status: 2,
extra: params[:reason]
}
Tiding.create(tiding_params)
render_success_js
end
end
private
def get_apply
@depart_apply = ApplyAddDepartment.find_by(id:params[:id])
end
end

@ -0,0 +1,25 @@
class Admins::DepartmentApplyQuery < ApplicationQuery
include CustomSortable
attr_reader :params
sort_columns :created_at, default_by: :created_at, default_direction: :desc
def initialize(params)
@params = params
end
def call
status = params[:status]
applies = ApplyAddDepartment.where(status: status) if status.present?
# 关键字模糊查询
keyword = params[:keyword].to_s.strip
if keyword.present?
applies = applies.where('name LIKE :keyword', keyword: "%#{keyword}%")
end
custom_sort(applies, params[:sort_by], params[:sort_direction])
end
end

@ -0,0 +1,2 @@
//$("#apply-id-<%= @depart_apply.id %>").remove()
//pop_box_new("批准成功", 400, 248);

@ -0,0 +1,18 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('部门审批') %>
<% end %>
<div class="box search-form-container flex-column mb-0 pb-0 department-applies-list-form">
<%= form_tag(admins_department_applies_path(unsafe_params), method: :get, class: 'form-inline search-form mt-3', remote: true) do %>
<%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: '部门名称检索') %>
<%= submit_tag('搜索', class: 'btn btn-primary ml-3','data-disable-with':"搜索中...") %>
<%= link_to "清除",admins_department_applies_path(keyword:nil),class:"btn btn-default",remote:true %>
<% end %>
</div>
<div class="box department-applies-list-container">
<%= render(partial: 'admins/department_applies/shared/list', locals: { applies: @depart_applies }) %>
</div>
<%= render(partial: 'admins/shared/admin_common_refuse_modal') %>
<%= render partial: 'admins/department_applies/shared/edit_modal' %>

@ -0,0 +1 @@
$(".department-applies-list-container").html("<%= j render partial: "admins/department_applies/shared/list",locals: {applies:@depart_applies} %>")

@ -0,0 +1,26 @@
<div class="modal fade department-apply-edit-modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">修改为</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form class="department-apply-form" data-remote="true">
<%= hidden_field_tag(:id, nil) %>
<div class="form-group">
<label for="grade" class="col-form-label">名称:</label>
<%= text_field_tag(:name,nil,class:"form-control",placeholder:"输入新的名称") %>
</div>
<div class="error text-danger"></div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary submit-btn">确认</button>
</div>
</div>
</div>
</div>

@ -0,0 +1,40 @@
<table class="table table-hover text-center department_applies-list-table">
<thead class="thead-light">
<tr>
<th width="9%">ID</th>
<th width="25%" class="edu-txt-left">部门名称</th>
<th width="20%" class="edu-txt-left">单位名称</th>
<th width="15%">创建者</th>
<th width="15%"><%= sort_tag('创建于', name: 'created_at', path: admins_department_applies_path) %></th>
<th>操作</th>
</tr>
</thead>
<tbody>
<% if applies.present? %>
<% applies.each do |apply| %>
<tr class="department-apply-<%= apply.id %>">
<td><%= apply.id %></td>
<td class="edu-txt-left"> <%= apply.name %></td>
<td class="edu-txt-left"> <%= apply.school.try(:name) %></td>
<td><%= apply.user.show_real_name %></td>
<td><%= format_time apply.created_at %></td>
<td class="action-container">
<%= agree_link '批准', agree_admins_department_apply_path(apply, element: ".department-apply-#{apply.id}"), 'data-confirm': '确认批准通过?' %>
<%= javascript_void_link('删除', class: 'action refuse-action',
data: {
toggle: 'modal', target: '.admin-common-refuse-modal', id: apply.id, title: "删除原因", type: "delete",
url: admins_department_apply_path(apply, element: ".department-apply-#{apply.id}")
}) %>
<%= javascript_void_link('修改', class: 'action department-apply-action', data: { toggle: 'modal', target: '.department-apply-edit-modal', id: apply.id }) %>
</td>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>
<%= render partial: 'admins/shared/paginate', locals: { objects: applies } %>

@ -56,15 +56,14 @@
<%= sidebar_item_group('#apply-review-submenu', '审核', icon: 'gavel') do %>
<li><%= sidebar_item(admins_identity_authentications_path, '实名认证', icon: 'id-card-o', controller: 'admins-identity_authentications') %></li>
<li><%= sidebar_item(admins_professional_authentications_path, '职业认证', icon: 'drivers-license', controller: 'admins-professional_authentications') %></li>
<li><%= sidebar_item(admins_department_applies_path, '部门审批', icon: 'building', controller: 'admins-department_applies') %></li>
<li><%= sidebar_item(admins_shixun_authorizations_path, '实训发布', icon: 'object-ungroup', controller: 'admins-shixun_authorizations') %></li>
<li><%= sidebar_item(admins_subject_authorizations_path, '实践课程发布', icon: 'object-group', controller: 'admins-subject_authorizations') %></li>
<li><%= sidebar_item(admins_library_applies_path, '教学案例发布', icon: 'language', controller: 'admins-library_applies') %></li>
<li><%= sidebar_item(admins_project_package_applies_path, '众包需求发布', icon: 'joomla', controller: 'admins-project_package_applies') %></li>
<li><%= sidebar_item(admins_video_applies_path, '视频发布', icon: 'film', controller: 'admins-video_applies') %></li>
<% end %>
<li><%= sidebar_item(admins_subject_authorizations_path, '实践课程发布', icon: 'object-group', controller: 'admins-subject_authorizations') %></li>
<li><%= sidebar_item(admins_library_applies_path, '教学案例发布', icon: 'language', controller: 'admins-library_applies') %></li>
<li><%= sidebar_item(admins_project_package_applies_path, '众包需求发布', icon: 'joomla', controller: 'admins-project_package_applies') %></li>
<li><%= sidebar_item(admins_video_applies_path, '视频发布', icon: 'film', controller: 'admins-video_applies') %></li>
<% end %>
</li>
<li><%= sidebar_item('/', '返回主站', icon: 'sign-out', controller: 'root') %></li>
</ul>
</nav>

@ -850,18 +850,21 @@ Rails.application.routes.draw do
end
resources :shixuns, only: [:index,:destroy]
resources :shixun_settings, only: [:index,:update]
resources :department_applies,only: [:index,:edit,:update,:destroy] do
member do
post :agree
end
end
resources :mirror_repositories, only: [:index, :new, :create, :edit, :update, :destroy] do
collection do
post :merge
get :for_select
end
resources :mirror_scripts, only: [:index, :new, :create, :edit, :update, :destroy]
end
resources :choose_mirror_repositories, only: [:new, :create]
resources :departments, only: [:index, :create, :edit, :update, :destroy] do
resource :department_member, only: [:create, :update, :destroy]
post :merge, on: :collection
end
resources :myshixuns, only: [:index]

File diff suppressed because one or more lines are too long

@ -128079,6 +128079,7 @@ $(document).on('turbolinks:load', function() {
if ($refuseModal.length > 0) {
var $form = $refuseModal.find('form.admin-common-refuse-form');
var $applyIdInput = $refuseModal.find('.modal-body input[name="apply_id"]');
var $applyTitle = $refuseModal.find('.modal-title');
$form.validate({
errorElement: 'span',
@ -128097,9 +128098,19 @@ $(document).on('turbolinks:load', function() {
var applyId = $link.data('id');
var url = $link.data('url');
var title = $link.data('title');
var type = $link.data('type');
var form_method = "POST";
if(typeof title !== 'undefined'){
$applyTitle.html(title)
}
if(typeof type !== 'undefined'){
form_method = type;
}
$applyIdInput.val(applyId);
$form.data('url', url);
$form.data('type', form_method);
});
// modal visited fire
$refuseModal.on('shown.bs.modal', function(){
@ -128116,9 +128127,10 @@ $(document).on('turbolinks:load', function() {
if ($form.valid()) {
var url = $form.data('url');
var form_method = $form.data('type');
$.ajax({
method: 'POST',
method: form_method,
dataType: 'script',
url: url,
data: $form.serialize(),
@ -128208,6 +128220,28 @@ $(document).on('turbolinks:load', function() {
// });
}
});
$(document).on('turbolinks:load', function() {
var $editModal = $('.department-apply-edit-modal');
if($editModal.length > 0){
var $form = $editModal.find('form.department-apply-form');
var $applyIdInput = $form.find('input[name="id"]');
$editModal.on('show.bs.modal', function (event) {
var $link = $(event.relatedTarget);
var applyId = $link.data('id');
$applyIdInput.val(applyId);
});
$editModal.on('click', '.submit-btn', function(){
$.ajax({
method: "PUT",
dataType: 'script',
url: "/admins/department_applies/"+ $applyIdInput.val(),
data: $form.serialize(),
}).done(function(){
$editModal.modal('hide');
});
});
}
});
$(document).on('turbolinks:load', function() {
if ($('body.admins-departments-index-page').length > 0) {
var $searchContainer = $('.department-list-form');

@ -376,7 +376,7 @@ class AccountBasic extends Component {
this.getSchoolList(this.props.basicInfo, name);
this.props.form.setFieldsValue({
name: name
org: name
})
}

Loading…
Cancel
Save