Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun
commit
cca8b5d88b
@ -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">×</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 } %>
|
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Loading…
Reference in new issue