|
|
@@ -34,6 +34,104 @@ $(document).ready(function () {
|
|
|
let oldSearchVal = null
|
|
|
handleFileList(fileList)
|
|
|
|
|
|
+ if ($('#admin-edit-shenpi').length) {
|
|
|
+ let adminAuditors = advanceAdminAuditors
|
|
|
+ let adminAuditChanged = false
|
|
|
+
|
|
|
+ function makeAdminSelect(code, aid, operate) {
|
|
|
+ let groups = ''
|
|
|
+ accountGroup.forEach((group, idx) => {
|
|
|
+ if (!group) return
|
|
|
+ const users = group.groupList.map(item => `<dd class="border-bottom p-2 mb-0" data-id="${item.id}">
|
|
|
+ <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span class="ml-auto">${item.mobile || ''}</span></p>
|
|
|
+ <span class="text-muted">${item.role || ''}</span></dd>`).join('')
|
|
|
+ groups += `<dt><a href="javascript:void(0);" class="acc-btn" data-groupid="${idx}" data-type="hide"><i class="fa fa-plus-square"></i></a> ${group.groupName}</dt>
|
|
|
+ <div class="dd-content" data-toggleid="${idx}">${users}</div>`
|
|
|
+ })
|
|
|
+ return `<div class="dropdown-menu dropdown-menu-right" id="${code}_dropdownMenu" aria-labelledby="${code}_dropdownMenuButton" style="width:220px">
|
|
|
+ <div class="mb-2 p-2"><input class="form-control form-control-sm gr-search" placeholder="姓名/手机 检索" autocomplete="off" data-code="${code}"></div>
|
|
|
+ <dl class="list-unstyled book-list" data-aid="${aid}" data-operate="${operate}">${groups}</dl></div>`
|
|
|
+ }
|
|
|
+
|
|
|
+ function renderAdminAuditors(groups) {
|
|
|
+ const html = []
|
|
|
+ groups.forEach((group, i) => {
|
|
|
+ if (i === 0) return
|
|
|
+ group.forEach((auditor, j) => {
|
|
|
+ html.push('<tr>')
|
|
|
+ html.push(`<td class="text-left">${j === 0 ? i + '审' : ''}</td>`)
|
|
|
+ html.push(`<td>${auditor.name} <small class="text-muted">${auditor.role || ''}</small></td>`)
|
|
|
+ const statusText = auditor.status === auditConst.status.uncheck ? '待审批' : (auditConst.auditString[auditor.status] || '')
|
|
|
+ html.push(`<td class="text-center"><span class="${auditConst.auditStringClass[auditor.status] || ''}">${statusText}</span></td>`)
|
|
|
+ html.push('<td class="text-center">')
|
|
|
+ if ((auditor.status === auditConst.status.checking || auditor.status === auditConst.status.uncheck) && j === group.length - 1) {
|
|
|
+ html.push(`<span class="dropdown mr-2"><a href="javascript:void(0)" id="${auditor.audit_id}_add_dropdownMenuButton" data-toggle="dropdown">增加</a>${makeAdminSelect(auditor.audit_id + '_add', auditor.audit_id, 'add')}</span>`)
|
|
|
+ }
|
|
|
+ if (auditor.status === auditConst.status.uncheck) {
|
|
|
+ html.push(`<span class="dropdown mr-2"><a href="javascript:void(0)" id="${auditor.audit_id}_change_dropdownMenuButton" data-toggle="dropdown">更换</a>${makeAdminSelect(auditor.audit_id + '_change', auditor.audit_id, 'change')}</span>`)
|
|
|
+ html.push(`<span class="dropdown"><a href="javascript:void(0)" class="text-danger" data-toggle="dropdown">移除</a>
|
|
|
+ <div class="dropdown-menu"><span class="dropdown-item">确认移除审批人?</span><div class="dropdown-divider"></div>
|
|
|
+ <div class="px-2 py-1 text-center"><button class="remove-audit btn btn-sm btn-danger" data-id="${auditor.audit_id}">移除</button> <button class="btn btn-sm btn-secondary">取消</button></div></div></span>`)
|
|
|
+ }
|
|
|
+ html.push('</td></tr>')
|
|
|
+ })
|
|
|
+ })
|
|
|
+ $('#admin-edit-shenpi-list').html(html.join(''))
|
|
|
+ }
|
|
|
+
|
|
|
+ renderAdminAuditors(adminAuditors)
|
|
|
+
|
|
|
+ $('body').on('click', '#admin-edit-shenpi .book-list dt', function () {
|
|
|
+ const idx = $(this).find('.acc-btn').attr('data-groupid')
|
|
|
+ const button = $(this).find('.acc-btn')
|
|
|
+ const content = $(this).parent().find(`div[data-toggleid="${idx}"]`)
|
|
|
+ const showing = button.attr('data-type') === 'hide'
|
|
|
+ content.toggle(showing)
|
|
|
+ button.attr('data-type', showing ? 'show' : 'hide')
|
|
|
+ button.find('i').toggleClass('fa-plus-square', !showing).toggleClass('fa-minus-square-o', showing)
|
|
|
+ return false
|
|
|
+ })
|
|
|
+
|
|
|
+ let adminSearchTimer = null
|
|
|
+ $('body').on('input propertychange', '#admin-edit-shenpi .gr-search', function () {
|
|
|
+ const input = $(this)
|
|
|
+ clearTimeout(adminSearchTimer)
|
|
|
+ adminSearchTimer = setTimeout(() => {
|
|
|
+ const keyword = input.val()
|
|
|
+ const list = input.closest('.dropdown-menu').find('.book-list')
|
|
|
+ if (!keyword) {
|
|
|
+ list.html($(makeAdminSelect(input.data('code'), list.data('aid'), list.data('operate'))).find('.book-list').html())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ list.html(accountList.filter(item => item && (item.name.indexOf(keyword) !== -1 || (item.mobile && item.mobile.indexOf(keyword) !== -1)))
|
|
|
+ .map(item => `<dd class="border-bottom p-2 mb-0" data-id="${item.id}"><p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span class="ml-auto">${item.mobile || ''}</span></p><span class="text-muted">${item.role || ''}</span></dd>`).join(''))
|
|
|
+ }, 400)
|
|
|
+ })
|
|
|
+
|
|
|
+ $('body').on('click', '#admin-edit-shenpi dl dd', function () {
|
|
|
+ const newAid = Number($(this).data('id'))
|
|
|
+ const list = $(this).closest('.book-list')
|
|
|
+ if (adminAuditors.some(group => group.some(auditor => auditor.audit_id === newAid))) return toastr.warning('该审核人已存在,请勿重复添加')
|
|
|
+ postData(preUrl + '/audit/save', { operate: list.data('operate'), old_aid: Number(list.data('aid')), new_aid: newAid }, datas => {
|
|
|
+ adminAuditors = datas
|
|
|
+ adminAuditChanged = true
|
|
|
+ renderAdminAuditors(datas)
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ $('body').on('click', '#admin-edit-shenpi .remove-audit', function () {
|
|
|
+ postData(preUrl + '/audit/save', { operate: 'del', old_aid: Number($(this).data('id')) }, datas => {
|
|
|
+ adminAuditors = datas
|
|
|
+ adminAuditChanged = true
|
|
|
+ renderAdminAuditors(datas)
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ $('#sub-sp2').on('hidden.bs.modal', function () {
|
|
|
+ if (adminAuditChanged) window.location.reload()
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
// 控制上报弹窗的文案
|
|
|
function checkModal(isHide) {
|
|
|
$('#start-modal').empty()
|
|
|
@@ -61,8 +159,8 @@ $(document).ready(function () {
|
|
|
<span class="text-muted">${item.role || ''}</span>
|
|
|
</dd>`
|
|
|
})
|
|
|
- $('.book-list').empty()
|
|
|
- $('.book-list').append(html)
|
|
|
+ $('.book-list').not('#admin-edit-shenpi .book-list').empty()
|
|
|
+ $('.book-list').not('#admin-edit-shenpi .book-list').append(html)
|
|
|
} else {
|
|
|
if (!$('.acc-btn').length) {
|
|
|
accountGroup.forEach((group, idx) => {
|
|
|
@@ -81,8 +179,8 @@ $(document).ready(function () {
|
|
|
});
|
|
|
html += '</div>'
|
|
|
})
|
|
|
- $('.book-list').empty()
|
|
|
- $('.book-list').append(html)
|
|
|
+ $('.book-list').not('#admin-edit-shenpi .book-list').empty()
|
|
|
+ $('.book-list').not('#admin-edit-shenpi .book-list').append(html)
|
|
|
}
|
|
|
}
|
|
|
}, 400);
|
|
|
@@ -90,6 +188,7 @@ $(document).ready(function () {
|
|
|
|
|
|
// 添加审批流程按钮逻辑
|
|
|
$('.book-list').on('click', 'dt', function () {
|
|
|
+ if ($(this).closest('#admin-edit-shenpi').length) return
|
|
|
const idx = $(this).find('.acc-btn').attr('data-groupid')
|
|
|
const type = $(this).find('.acc-btn').attr('data-type')
|
|
|
if (type === 'hide') {
|
|
|
@@ -109,6 +208,7 @@ $(document).ready(function () {
|
|
|
|
|
|
// 添加到审批流程中
|
|
|
$('dl').on('click', 'dd', function () {
|
|
|
+ if ($(this).closest('#admin-edit-shenpi').length) return
|
|
|
const id = parseInt($(this).data('id'))
|
|
|
if (id !== 0) {
|
|
|
postData(preUrl + '/audit/add', { auditorId: id }, (datas) => {
|