diff --git a/app/assets/javascripts/admins/department_applies/index.js b/app/assets/javascripts/admins/department_applies/index.js
deleted file mode 100644
index 7ecf0be75..000000000
--- a/app/assets/javascripts/admins/department_applies/index.js
+++ /dev/null
@@ -1,22 +0,0 @@
-$(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');
- });
- });
- }
-});
\ No newline at end of file
diff --git a/app/assets/javascripts/admins/modals/admin-merge-department-modal.js b/app/assets/javascripts/admins/modals/admin-merge-department-modal.js
index aead3f485..f5f2dceeb 100644
--- a/app/assets/javascripts/admins/modals/admin-merge-department-modal.js
+++ b/app/assets/javascripts/admins/modals/admin-merge-department-modal.js
@@ -66,10 +66,11 @@ $(document).on('turbolinks:load', function() {
var $link = $(event.relatedTarget);
var schoolId = $link.data('schoolId');
+ var url = $link.data('url');
$schoolIdInput.val(schoolId);
$originDepartmentIdInput.val($link.data('departmentId'));
-
+ $form.data('url', url);
$.ajax({
url: '/api/schools/' + schoolId + '/departments/for_option.json',
dataType: 'json',
diff --git a/app/controllers/admins/department_applies_controller.rb b/app/controllers/admins/department_applies_controller.rb
index 6c26e67af..b6dece1de 100644
--- a/app/controllers/admins/department_applies_controller.rb
+++ b/app/controllers/admins/department_applies_controller.rb
@@ -1,6 +1,7 @@
class Admins::DepartmentAppliesController < Admins::BaseController
- before_action :get_apply,only:[:agree,:edit,:update,:destroy]
+ before_action :get_apply,only:[:agree,:destroy]
+
def index
params[:status] ||= 0
params[:sort_by] = params[:sort_by].presence || 'created_at'
@@ -19,46 +20,77 @@ class Admins::DepartmentAppliesController < Admins::BaseController
end
end
- def update
- depart_name = params[:name]
+ def merge
+ apply_id = params[:origin_department_id]
+ apply_add =ApplyAddDepartment.find(apply_id)
+ origin_id = apply_add&.department_id
+ new_id = params[:department_id]
+
+ return render_error('请选择其它部门') if origin_id.to_s == new_id.to_s
+
+ origin_department = apply_add&.department
+ to_department = Department.find(new_id)
+
+ return render_error('部门所属单位不相同') if origin_department&.school_id != to_department&.school_id
+
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)})"
+ applied_message = AppliedMessage.where(applied_id: origin_id, applied_type: "ApplyAddDepartment")
+
+ applied_message.update_all(:status => 4)
+ apply_add.update_attribute(:status, 2)
+ apply_add.tidings.update_all(:status => 1)
+
+ extra = to_department&.name + "(#{apply_add&.department&.school&.try(:name)})"
tiding_params = {
- user_id: @depart_apply.user_id,
+ user_id: apply_add.user_id,
trigger_user_id: 0,
- container_id: @depart_apply.id,
+ container_id: apply_add.id,
container_type: 'ApplyAddDepartment',
- belong_container_id: @depart_apply.department.school_id,
+ belong_container_id: apply_add&.department&.school_id,
belong_container_type: "School",
tiding_type: "System",
status: 3,
extra: extra
}
Tiding.create(tiding_params)
- render_success_js
+
+ origin_department.apply_add_departments.delete_all
+
+ origin_department.user_extensions.update_all(department_id: new_id)
+
+ if to_department.identifier.blank? && origin_department.identifier.present?
+ to_department.update!(identifier: origin_department.identifier)
+ end
+
+ origin_department.destroy!
+ apply_add.destroy!
end
+ render_ok
end
def destroy
ActiveRecord::Base.transaction do
@depart_apply.update_attribute("status",3)
@depart_apply&.applied_messages&.update_all(status:3)
+
+ if params[:tip] == 'unapplied' #未审批时候删除
+ UserExtension.where(department_id: @depart_apply.department_id).update_all(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)
+ end
+
@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)
+ @depart_apply.destroy
render_success_js
end
end
diff --git a/app/controllers/admins/unit_applies_controller.rb b/app/controllers/admins/unit_applies_controller.rb
new file mode 100644
index 000000000..deb231f16
--- /dev/null
+++ b/app/controllers/admins/unit_applies_controller.rb
@@ -0,0 +1,122 @@
+class Admins::UnitAppliesController < Admins::BaseController
+ before_action :get_apply,only: [:agree,:destroy,:edit,:update]
+
+ def index
+ params[:sort_by] ||= 'created_at'
+ params[:sort_direction] ||= 'desc'
+ unit_applies = Admins::UnitApplyQuery.call(params)
+ @unit_applies = paginate unit_applies.preload(:school, :user)
+ end
+
+ def agree
+ ActiveRecord::Base.transaction do
+ begin
+ @unit_apply.update_attribute("status",1)
+ @unit_apply&.applied_messages&.update_all(status:1)
+ @unit_apply&.school&.update_attribute("province",@unit_apply.province)
+
+ # #申请信息的创建
+ apply_message_params = {
+ user_id: @unit_apply&.user_id,
+ status: 1,
+ viewed: 0,
+ applied_id: @unit_apply.school_id,
+ applied_type: "ApplyAddSchools",
+ name: @unit_apply.name,
+ }
+ AppliedMessage.new(apply_message_params).save(validate: false)
+
+ Tiding.where(user_id: 1, trigger_user_id: @unit_apply.user_id, container_id: @unit_apply.id,
+ container_type: 'ApplyAddSchools', status: 0, tiding_type: "Apply").update_all(status: 1)
+ #消息的创建
+ tiding_params = {
+ user_id: @unit_apply.user_id,
+ trigger_user_id: 0,
+ container_id: @unit_apply.id,
+ container_type: 'ApplyAddSchools',
+ belong_container_id: @unit_apply.school_id,
+ belong_container_type: "School",
+ tiding_type: "System",
+ status: 1
+ }
+ Tiding.create(tiding_params)
+ render_success_js
+ rescue Exception => e
+ Rails.logger.info("############_________________#########{e}")
+ end
+ end
+ end
+
+ def destroy
+ Admins::DeleteUnitApplyService.call(@unit_apply, params)
+ render_success_js
+ end
+
+ def edit
+ @all_schools = School.where.not(id: @unit_apply.school_id).pluck("name","id")
+
+ end
+
+ def update
+ school = School.find_by(id: params[:school_id])
+ ActiveRecord::Base.transaction do
+ @unit_apply&.applied_messages&.update_all(status:4)
+ Tiding.where(user_id: 1, trigger_user_id: @unit_apply.user_id, container_id: @unit_apply.id,
+ container_type: 'ApplyAddSchools', status: 0, tiding_type: "Apply").update_all(status: 1)
+
+ #消息的创建
+ tiding_params = {
+ user_id: @unit_apply.user_id,
+ trigger_user_id: 0,
+ container_id: @unit_apply.id,
+ container_type: 'ApplyAddSchools',
+ belong_container_id: params[:school_id],
+ belong_container_type: "School",
+ tiding_type: "System",
+ status: 3,
+ extra: school.try(:name).to_s
+ }
+ Tiding.create(tiding_params)
+
+ UserExtension.where(school_id: @unit_apply.school_id).update_all(school_id: params[:school_id].to_i)
+ ApplyAddDepartment.where(:school_id => @unit_apply.school_id).update_all(school_id: params[:school_id].to_i)
+
+ # 判断重复
+ before_apply_departments = Department.where(school_id: @unit_apply.school_id)
+ before_apply_departments.each do |department|
+ after_dep = Department.where(school_id: params[:school_id].to_i, name: department.name)&.first
+ if after_dep.present?
+ UserExtension.where(school_id: @unit_apply.school_id, department_id: department.id).update_all(department_id: after_dep.id)
+ department.destroy
+ department.apply_add_departments.destroy_all
+ else
+ department.apply_add_departments.update_all(school_id: school.id)
+ department.update_attribute(:school_id, school.id)
+ end
+ end
+
+ @unit_apply&.school&.destroy
+ apply_params = {
+ status: 2,
+ name: school&.name.to_s,
+ school_id: params[:school_id],
+ province: params[:province],
+ city: params[:city],
+ address: params[:address]
+ }
+ @unit_apply.update_attributes(apply_params)
+ # render_success_js
+ end
+ end
+
+ private
+
+ def get_apply
+ @unit_apply = ApplyAddSchool.find_by(id:params[:id])
+ end
+
+ def disk_auth_filename(source_type, source_id, type)
+ File.join(storage_path, "#{source_type}", "#{source_id}#{type}")
+ end
+end
+
diff --git a/app/models/apply_add_school.rb b/app/models/apply_add_school.rb
index c303283ca..ac7c880cd 100644
--- a/app/models/apply_add_school.rb
+++ b/app/models/apply_add_school.rb
@@ -1,10 +1,12 @@
class ApplyAddSchool < ApplicationRecord
belongs_to :school
+ belongs_to :user
has_many :applied_messages, as: :applied
has_many :tidings, as: :container, dependent: :destroy
after_create :send_notify
+ # after_destroy :after_delete_apply
private
@@ -12,4 +14,9 @@ class ApplyAddSchool < ApplicationRecord
Tiding.create!(user_id: 1, status: 0, container_id: id, container_type: 'ApplyAddSchools',
trigger_user_id: user_id, belong_container: school, tiding_type: 'Apply')
end
+
+ # def after_delete_apply
+ #
+ # end
+
end
\ No newline at end of file
diff --git a/app/models/school.rb b/app/models/school.rb
index 1034fd997..24de02496 100644
--- a/app/models/school.rb
+++ b/app/models/school.rb
@@ -16,6 +16,8 @@ class School < ApplicationRecord
has_many :customers, dependent: :destroy
has_many :partners, dependent: :destroy
+ has_many :apply_add_departments, dependent: :destroy
+
# 学校管理员
def manager?(user)
ec_school_users.exists?(user_id: user.id)
diff --git a/app/queries/admins/unit_apply_query.rb b/app/queries/admins/unit_apply_query.rb
new file mode 100644
index 000000000..5df9c8ebb
--- /dev/null
+++ b/app/queries/admins/unit_apply_query.rb
@@ -0,0 +1,24 @@
+class Admins::UnitApplyQuery < 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
+ unit_applies = ApplyAddSchool.where(status:0)
+
+ # 关键字模糊查询
+ keyword = params[:keyword].to_s.strip
+ if keyword.present?
+ unit_applies = unit_applies.where("name like ?","%#{keyword}%")
+ end
+
+ custom_sort(unit_applies, params[:sort_by], params[:sort_direction])
+ end
+end
+
diff --git a/app/services/admins/delete_unit_apply_service.rb b/app/services/admins/delete_unit_apply_service.rb
new file mode 100644
index 000000000..a64c8d64d
--- /dev/null
+++ b/app/services/admins/delete_unit_apply_service.rb
@@ -0,0 +1,56 @@
+class Admins::DeleteUnitApplyService < ApplicationService
+
+ attr_reader :department, :params
+
+ def initialize(unit_apply, params)
+ @unit_apply = unit_apply
+ @params = params
+ end
+
+ def call
+ ActiveRecord::Base.transaction do
+ @unit_apply.update_attribute("status",3)
+ @unit_apply&.applied_messages&.update_all(status:3)
+ @unit_apply&.school&.apply_add_departments&.update_all(status:3)
+
+ applied_departments = ApplyAddDepartment.where(school_id: @unit_apply.school_id)
+ applied_departments.update_all(status: 3)
+
+ use_extensions = UserExtension&.where(school_id: @unit_apply.school_id)
+ user_ids = UserExtension&.where(school_id: @unit_apply.school_id)&.pluck(:user_id)
+ User.where(id: user_ids).update_all(profile_completed: false)
+ use_extensions.update_all(school_id: nil,department_id: nil)
+
+ @unit_apply&.user&.user_extension&.update_attribute("department_id", nil)
+
+ # 申请了职业认证的用户撤销申请
+ apply_user_auth = ApplyUserAuthentication.where(user_id: user_ids, auth_type: 2, status: 0)
+ apply_user_auth.each do |apply|
+ apply.tidings.destroy_all
+ apply.update_attribute('status', 3)
+ diskfile2 = disk_auth_filename('UserAuthentication', apply.user_id, 'PRO')
+ diskfilePRO = diskfile2 + 'temp'
+ File.delete(diskfilePRO) if File.exist?(diskfilePRO)
+ File.delete(diskfile2) if File.exist?(diskfile2)
+ end
+
+ # 未审批删除
+ if params[:tip] == "unapplied"
+ Tiding.where(:user_id => 1, :trigger_user_id => @unit_apply.user_id, :container_id => @unit_apply.id, :container_type => 'ApplyAddSchools', :status => 0, :tiding_type => "Apply").update_all(status: 1)
+ Tiding.create(:user_id => @unit_apply.user_id, :trigger_user_id => 0, :container_id => @unit_apply.id, :container_type =>'ApplyAddSchools', :belong_container_id => @unit_apply.school_id, :belong_container_type=> 'School', :tiding_type => "System", :status => 2, :extra => params[:reason])
+
+ Tiding.where(:user_id => 1, :container_id => applied_departments.pluck(:id), :container_type => 'ApplyAddDepartment', :status => 0, :tiding_type => "Apply").update_all(status: 1)
+ if applied_departments&.first.present?
+ Tiding.create(:user_id => applied_departments.first.user_id, :trigger_user_id => 0, :container_id => applied_departments.first.id, :container_type =>'ApplyAddDepartment', :belong_container_id => @unit_apply.school_id, :belong_container_type=> 'School', :tiding_type => "System", :status => 2)
+ AppliedMessage.create(:user_id => applied_departments.first.user_id, :status => 3, :viewed => 0, :applied_id => applied_departments.first.id, :applied_type => "ApplyAddDepartment", :name => applied_departments.first.name )
+ end
+ @unit_apply&.school&.destroy
+ @unit_apply&.school&.departments&.destroy_all
+ elsif params[:tip] == "applied"
+ applied_departments.destroy_all
+ @unit_apply.destroy
+ end
+ end
+
+ end
+end
\ No newline at end of file
diff --git a/app/views/admins/department_applies/agree.js.erb b/app/views/admins/department_applies/agree.js.erb
deleted file mode 100644
index d6a9f078a..000000000
--- a/app/views/admins/department_applies/agree.js.erb
+++ /dev/null
@@ -1,2 +0,0 @@
-//$("#apply-id-<%= @depart_apply.id %>").remove()
-//pop_box_new("批准成功", 400, 248);
\ No newline at end of file
diff --git a/app/views/admins/department_applies/index.html.erb b/app/views/admins/department_applies/index.html.erb
index 72e0e42fc..49b38e31a 100644
--- a/app/views/admins/department_applies/index.html.erb
+++ b/app/views/admins/department_applies/index.html.erb
@@ -15,4 +15,4 @@
<%= render(partial: 'admins/shared/admin_common_refuse_modal') %>
-<%= render partial: 'admins/department_applies/shared/edit_modal' %>
\ No newline at end of file
+<%= render 'admins/departments/shared/merge_department_modal' %>
\ No newline at end of file
diff --git a/app/views/admins/department_applies/shared/_edit_modal.html.erb b/app/views/admins/department_applies/shared/_edit_modal.html.erb
deleted file mode 100644
index 44c38ac28..000000000
--- a/app/views/admins/department_applies/shared/_edit_modal.html.erb
+++ /dev/null
@@ -1,26 +0,0 @@
-
\ No newline at end of file
diff --git a/app/views/admins/department_applies/shared/_list.html.erb b/app/views/admins/department_applies/shared/_list.html.erb
index a31e39a37..bdd518a8f 100644
--- a/app/views/admins/department_applies/shared/_list.html.erb
+++ b/app/views/admins/department_applies/shared/_list.html.erb
@@ -1,12 +1,12 @@
- ID
- 部门名称
- 单位名称
+ ID
+ 部门名称
+ 单位名称
创建者
<%= sort_tag('创建于', name: 'created_at', path: admins_department_applies_path) %>
- 操作
+ 操作
@@ -14,8 +14,8 @@
<% applies.each do |apply| %>
<%= apply.id %>
- <%= apply.name %>
- <%= apply.school.try(:name) %>
+ <%= apply.name %>
+ <%= apply.school.try(:name) %>
<%= apply.user.show_real_name %>
<%= format_time apply.created_at %>
@@ -23,17 +23,16 @@
<%= 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}")
+ url: admins_department_apply_path(apply,tip:"unapplied", element: ".department-apply-#{apply.id}")
}) %>
-
- <%= javascript_void_link('修改', class: 'action department-apply-action', data: { toggle: 'modal', target: '.department-apply-edit-modal', id: apply.id }) %>
+ <%= javascript_void_link '更改', class: 'action', data: { school_id: apply.school_id, department_id: apply.id,
+ toggle: 'modal', target: '.admin-merge-department-modal', url: merge_admins_department_applies_path } %>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
-
diff --git a/app/views/admins/departments/shared/_department_item.html.erb b/app/views/admins/departments/shared/_department_item.html.erb
index 11584909d..64b4ee70b 100644
--- a/app/views/admins/departments/shared/_department_item.html.erb
+++ b/app/views/admins/departments/shared/_department_item.html.erb
@@ -28,7 +28,8 @@
<%= javascript_void_link '添加管理员', class: 'action', data: { department_id: department.id, toggle: 'modal', target: '.admin-add-department-member-modal' } %>
- <%= javascript_void_link '更改', class: 'action', data: { school_id: department.school_id, department_id: department.id, toggle: 'modal', target: '.admin-merge-department-modal' } %>
+ <%= javascript_void_link '更改', class: 'action', data: { school_id: department.school_id, department_id: department.id,
+ toggle: 'modal', target: '.admin-merge-department-modal', url: merge_admins_departments_path } %>
<%= delete_link '删除', admins_department_path(department, element: ".department-item-#{department.id}"), class: 'delete-department-action' %>
\ No newline at end of file
diff --git a/app/views/admins/departments/shared/_merge_department_modal.html.erb b/app/views/admins/departments/shared/_merge_department_modal.html.erb
index 200e75ccd..5c1ca6892 100644
--- a/app/views/admins/departments/shared/_merge_department_modal.html.erb
+++ b/app/views/admins/departments/shared/_merge_department_modal.html.erb
@@ -18,7 +18,6 @@
-
diff --git a/app/views/admins/shared/_sidebar.html.erb b/app/views/admins/shared/_sidebar.html.erb
index 96d67b52a..9a7c696b8 100644
--- a/app/views/admins/shared/_sidebar.html.erb
+++ b/app/views/admins/shared/_sidebar.html.erb
@@ -56,7 +56,8 @@
<%= sidebar_item_group('#apply-review-submenu', '审核', icon: 'gavel') do %>
<%= sidebar_item(admins_identity_authentications_path, '实名认证', icon: 'id-card-o', controller: 'admins-identity_authentications') %>
<%= sidebar_item(admins_professional_authentications_path, '职业认证', icon: 'drivers-license', controller: 'admins-professional_authentications') %>
- <%= sidebar_item(admins_department_applies_path, '部门审批', icon: 'building', controller: 'admins-department_applies') %>
+ <%= sidebar_item(admins_department_applies_path, '部门审批', icon: 'newspaper-o', controller: 'admins-department_applies') %>
+ <%= sidebar_item(admins_unit_applies_path, '单位审批', icon: 'building-o', controller: 'admins-unit_applies') %>
<%= sidebar_item(admins_shixun_authorizations_path, '实训发布', icon: 'object-ungroup', controller: 'admins-shixun_authorizations') %>
<%= sidebar_item(admins_subject_authorizations_path, '实践课程发布', icon: 'object-group', controller: 'admins-subject_authorizations') %>
<%= sidebar_item(admins_library_applies_path, '教学案例发布', icon: 'language', controller: 'admins-library_applies') %>
diff --git a/app/views/admins/unit_applies/edit.js.erb b/app/views/admins/unit_applies/edit.js.erb
new file mode 100644
index 000000000..15fc1f4c2
--- /dev/null
+++ b/app/views/admins/unit_applies/edit.js.erb
@@ -0,0 +1,56 @@
+$("body").append("<%= j render partial: "admins/unit_applies/shared/edit_modal",locals: {apply: @unit_apply, schools: @all_schools} %>")
+var uni_edit_modal = $(".admin-unit-edit-modal")
+uni_edit_modal.modal("show")
+
+uni_edit_modal.on("hidden.bs.modal",function () {
+ $(".admin-unit-edit-modal").remove()
+ $("body").removeClass("modal-open")
+})
+
+// 初始化学校选择器
+var matcherFunc = function(params, data){
+ if ($.trim(params.term) === '') {
+ return data;
+ }
+ if (typeof data.text === 'undefined') {
+ return null;
+ }
+ if (data.name && data.name.indexOf(params.term) > -1) {
+ var modifiedData = $.extend({}, data, true);
+ return modifiedData;
+ }
+
+ // Return `null` if the term should not be displayed
+ return null;
+}
+$.ajax({
+ url: '/api/schools/for_option.json',
+ dataType: 'json',
+ type: 'GET',
+ success: function(data) {
+ $("#all-schools").select2({
+ theme: 'bootstrap4',
+ placeholder: '查询学校/单位',
+ minimumInputLength: 1,
+ data: data.schools,
+ templateResult: function (item) {
+ if(!item.id || item.id === '') return item.text;
+ return item.name;
+ },
+ templateSelection: function(item){
+ return item.name || item.text;
+ },
+ matcher: matcherFunc
+ })
+ }
+});
+
+$("#all-schools").select2({})
+$("#show-province-<%= @unit_apply.id %>").select2()
+$("#schoolCity_<%= @unit_apply.id %>").select2()
+
+// **************** 地区选择 ****************
+$('.province-city-select').cxSelect({
+ url: '/javascripts/educoder/province-data.json',
+ selects: ['province-select', 'city-select']
+});
\ No newline at end of file
diff --git a/app/views/admins/unit_applies/index.html.erb b/app/views/admins/unit_applies/index.html.erb
new file mode 100644
index 000000000..2b715b87c
--- /dev/null
+++ b/app/views/admins/unit_applies/index.html.erb
@@ -0,0 +1,17 @@
+<% define_admin_breadcrumbs do %>
+ <% add_admin_breadcrumb('单位审批') %>
+<% end %>
+
+
+ <%= form_tag(admins_unit_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_unit_applies_path(keyword:nil),class:"btn btn-default",remote:true %>
+ <% end %>
+
+
+
+ <%= render(partial: 'admins/unit_applies/shared/list', locals: { applies: @unit_applies }) %>
+
+
+<%= render(partial: 'admins/shared/admin_common_refuse_modal') %>
diff --git a/app/views/admins/unit_applies/index.js.erb b/app/views/admins/unit_applies/index.js.erb
new file mode 100644
index 000000000..d9297d51a
--- /dev/null
+++ b/app/views/admins/unit_applies/index.js.erb
@@ -0,0 +1 @@
+$(".unit-applies-list-container").html("<%= j render partial: "admins/unit_applies/shared/list", locals: {applies: @unit_applies} %>")
diff --git a/app/views/admins/unit_applies/shared/_apply_item.html.erb b/app/views/admins/unit_applies/shared/_apply_item.html.erb
new file mode 100644
index 000000000..d8a2bdcc4
--- /dev/null
+++ b/app/views/admins/unit_applies/shared/_apply_item.html.erb
@@ -0,0 +1,17 @@
+<%= apply.id %>
+<%= overflow_hidden_span apply.name %>
+
+ <%= "#{apply&.province.to_s}"+"#{apply&.city.to_s}" %>
+
+<%= overflow_hidden_span apply.address %>
+<%= apply.user.try(:show_real_name) %>
+<%= format_time apply.created_at %>
+
+ <%= agree_link '批准', agree_admins_unit_apply_path(apply, element: ".unit-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_unit_apply_path(apply, tip: "unapplied", element: ".unit-apply-#{apply.id}")
+ }) %>
+ <%= link_to "更改",edit_admins_unit_apply_path(apply), remote: true, class:"action",'data-disable-with': '打开中...' %>
+
\ No newline at end of file
diff --git a/app/views/admins/unit_applies/shared/_edit_modal.html.erb b/app/views/admins/unit_applies/shared/_edit_modal.html.erb
new file mode 100644
index 000000000..6f8995ae0
--- /dev/null
+++ b/app/views/admins/unit_applies/shared/_edit_modal.html.erb
@@ -0,0 +1,43 @@
+
+
+
+
+ <%= form_tag(admins_unit_apply_path, method: :put, remote: true) do %>
+
+
+ <% end %>
+
+
+
\ No newline at end of file
diff --git a/app/views/admins/unit_applies/shared/_list.html.erb b/app/views/admins/unit_applies/shared/_list.html.erb
new file mode 100644
index 000000000..c28ce7967
--- /dev/null
+++ b/app/views/admins/unit_applies/shared/_list.html.erb
@@ -0,0 +1,26 @@
+
+
+
+ ID
+ 单位名称
+ 地区
+ 详细地址
+ 申请者
+ <%= sort_tag('创建于', name: 'created_at', path: admins_unit_applies_path) %>
+ 操作
+
+
+
+ <% if applies.present? %>
+ <% applies.each do |apply| %>
+
+ <%= render partial: "admins/unit_applies/shared/apply_item", locals: {apply: apply} %>
+
+ <% end %>
+ <% else %>
+ <%= render 'admins/shared/no_data_for_table' %>
+ <% end %>
+
+
+
+<%= render partial: 'admins/shared/paginate', locals: { objects: applies } %>
\ No newline at end of file
diff --git a/app/views/admins/unit_applies/update.js.erb b/app/views/admins/unit_applies/update.js.erb
new file mode 100644
index 000000000..725f926d0
--- /dev/null
+++ b/app/views/admins/unit_applies/update.js.erb
@@ -0,0 +1,6 @@
+$('.modal.admin-unit-edit-modal').modal('hide');
+//$(".modal.admin-unit-edit-modal").remove()
+//$("body").removeClass("modal-open")
+$('.unit-applies-list-table .unit-apply-<%= @unit_apply.id %>').remove()
+//$('.unit-applies-list-table .unit-apply-<%= @unit_apply.id %>').html("<%= j render partial: "admins/unit_applies/shared/apply_item", locals: {apply: @unit_apply} %>")
+$.notify({ message: '操作成功' });
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 36d4bcfab..108630366 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -850,7 +850,15 @@ 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
+ resources :department_applies,only: [:index,:destroy] do
+ collection do
+ post :merge
+ end
+ member do
+ post :agree
+ end
+ end
+ resources :unit_applies,only: [:index,:destroy,:edit,:update] do
member do
post :agree
end