Browse Source

审批中,管理员设置审批流程相关

MaiXinRong 1 year ago
parent
commit
1f4bc5c2c0

+ 8 - 13
app/controller/stage_controller.js

@@ -1398,23 +1398,18 @@ module.exports = app => {
                 if (ctx.stage.revising) {
                     throw '台账修订中,请勿修改提交期数据';
                 }
-                const data = JSON.parse(ctx.request.body.data);
-                if (ctx.session.sessionUser.is_admin && ctx.stage.status !== auditConst.status.checked) {
-                    await ctx.service.stageAudit.saveAudit(ctx.stage.id, ctx.stage.times, data);
-                    const auditors = await ctx.service.stageAudit.getAuditGroupByListWithOwner(ctx.stage.id, ctx.stage.times);
-                    ctx.body = { err: 0, msg: '', data: auditors };
-                } else {
+                if (!ctx.session.sessionUser.is_admin || ctx.stage.status === auditConst.status.checked) {
                     throw '您无权进行该操作';
                 }
+
+                const data = JSON.parse(ctx.request.body.data);
+                await ctx.service.stageAudit.saveAudit(ctx.stage.id, ctx.stage.times, data);
+
+                const auditors = await ctx.service.stageAudit.getUserGroup(ctx.stage.id, ctx.stage.times);
+                ctx.body = { err: 0, msg: '', data: auditors };
             } catch (err) {
                 this.log(err);
-                // ctx.session.postError = err.toString();
-                // ctx.redirect(ctx.request.header.referer);
-                ctx.body = {
-                    err: 1,
-                    // url: ctx.request.header.referer,
-                    msg: err,
-                };
+                ctx.body = this.ajaxErrorBody(err, '保存审批人数据失败');
             }
         }
 

+ 0 - 1
app/public/js/measure_stage.js

@@ -68,7 +68,6 @@ $('a[data-target="#sp-list" ]').on('click', function () {
             historyHTML.push(`<div class="text-center text-muted">${idx+1}#</div>`);
             historyHTML.push(`<ul class="timeline-list list-unstyled mt-2 ${ idx === auditHistory.length - 1 && auditHistory.length !== 1 ? 'last-auditor-list' : '' }">`);
             his.forEach((group, index) => {
-                console.log(group);
                 if (index === 0) {
                     historyHTML.push(`<li class="timeline-list-item pb-2">
                                             <div class="timeline-item-date">

+ 102 - 91
app/public/js/stage_audit.js

@@ -291,6 +291,57 @@ $(document).ready(function () {
         }, 400);
     });
 
+    const getAdminEditShenpiListHtml = function(auditGroup) {
+        const html = [];
+        for (const [i, group] of auditGroup.entries()) {
+            if (i === 0) continue;
+            for (const [j, auditor] of group.entries()) {
+                html.push('<tr>');
+                if (j === 0) {
+                    const auditTypeHtml = auditor.type === auditType.key.common ? '' : `<span class="ml-2 badge badge-pill badge-${auditType.info[auditor.audit_type].class} p-1"><small>${auditType.info[auditor.audit_type].short}</small></span>`;
+                    html.push(`<td class="text-left d-flex">${i + '审'}${auditTypeHtml}</td>`);
+                } else {
+                    html.push(`<td class="text-left d-flex"></td>`);
+                }
+                html.push(`<td></span> ${auditor.name} <small class="text-muted">${auditor.role}</small></td>`);
+                html.push(`<td style="text-align: center"><span class="${auditConst.auditStringClass[auditor.status]}">${ auditor.status !== auditConst.status.uncheck ? auditConst.auditString[auditor.status] : '待审批' }</span></td>`);
+                html.push('<td style="text-align: center">');
+                if (auditor.status === auditConst.status.checking && j === group.length - 1) {
+                    html.push('<span class="dropdown mr-2">',
+                        '<a href="javascript: void(0)" class="add-audit" id="<%- auditor.aid %>_add_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">增加</a>',
+                        makeSelectAudit(auditor.id+'_add', auditor.id, 'add'),'</div>', '</span>');
+                }
+                if (auditor.status === auditConst.status.uncheck) {
+                    if (j === group.length - 1) {
+                        html.push('<span class="dropdown mr-2">',
+                            '<a href="javascript: void(0)" class="add-audit" id="<%- auditor.aid %>_add_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">增加</a>',
+                            makeSelectAudit(auditor.id+'_add', auditor.id, 'add'),'</div>', '</span>');
+                        html.push('<span class="dropdown mr-2">',
+                            '<a href="javascript: void(0)" class="add-audit" id="<%- auditor.aid %>_add_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">平级</a>',
+                            makeSelectAudit(auditor.id+'_add-sibling', auditor.id, 'add-sibling'),'</div>', '</span>');
+                    }
+                    html.push('<span class="dropdown mr-2">',
+                        '<a href="javascript: void(0)" class="add-audit" id="<%- auditor.aid %>_add_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">更换</a>',
+                        makeSelectAudit(auditor.id+'_change', auditor.id, 'change'),'</div>', '</span>');
+                    html.push(`<span class="dropdown">
+                                    <a href="javascript: void(0)" class="text-danger" title="移除" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">移除</a>
+                                    <div class="dropdown-menu">
+                                        <span class="dropdown-item" href="javascript:void(0);">确认移除审批人?</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.aid}">移除</button>
+                                            <button class="btn btn-sm btn-secondary">取消</button>
+                                        </div>
+                                    </div>
+                                    </span>`);
+                }
+                html.push('</td>');
+                html.push('</tr>');
+            }
+        }
+        return html.join('');
+    };
+
     $('body').on('click', '#admin-edit-shenpi dl dd', function () {
         const id = parseInt($(this).attr('data-id'));
         if (!id) return;
@@ -305,63 +356,13 @@ $(document).ready(function () {
             toastr.warning('该审核人已存在,请勿重复添加');
             return;
         }
-        const order = parseInt($(this).parents('tr').find('.shenpi-order').text());
-        const curAuditorIndex = _.findIndex(auditorList, { aid: this_aid });
         const prop = {
             operate: this_operate,
             old_aid: this_aid,
             new_aid: user.id,
         };
         postData(getUrlPre() + '/audit/save', prop, (datas) => {
-            if (this_operate === 'add') {
-                const addhtml = '<tr>\n' +
-                    `                                <td><span class="shenpi-order">${order+1}</span> ${user.name} <small class="text-muted">${user.role}</small></td>\n` +
-                    `                                <td style="text-align: center"><span class="">待审批</span></td>\n` +
-                    '                                <td style="text-align: center">\n' +
-                    '                                    <span class="dropdown mr-2">\n' +
-                    `                                    <a href="javascript: void(0)" class="add-audit" id="${user.id}_add_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">增加</a>\n` +
-                    makeSelectAudit(user.id+'_add', user.id, 'add') +
-                    '                                        </div>\n' +
-                    '                                    </span>\n' +
-                    '                                    <span class="dropdown mr-2">\n' +
-                    `                                        <a href="javascript: void(0)" class="change-audit" id="${user.id}_change_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">更换</a>\n` +
-                    makeSelectAudit(user.id+'_change', user.id, 'change') +
-                    '                                    </span>\n' +
-                    '                                    <span class="dropdown">\n' +
-                    '                                    <a href="javascript: void(0)" class="text-danger" title="移除" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">移除</a>\n' +
-                    '                                    <div class="dropdown-menu">\n' +
-                    '                                        <span class="dropdown-item">确认移除审批人?</span>\n' +
-                    '                                        <div class="dropdown-divider"></div>\n' +
-                    '                                        <div class="px-2 py-1 text-center">\n' +
-                    `                                            <button class="remove-audit btn btn-sm btn-danger" data-id="${user.id}">移除</button>\n` +
-                    '                                            <button class="btn btn-sm btn-secondary">取消</button>\n' +
-                    '                                        </div>\n' +
-                    '                                    </div>\n' +
-                    '                                    </span>\n' +
-                    '                                </td>\n' +
-                    '                            </tr>';
-                $(this).parents('tr').after(addhtml);
-                auditorList.splice(curAuditorIndex+1, 0, { aid: user.id, company: user.company, name: user.name, role: user.role });
-                updateOrder(user.id);
-            } else if (this_operate === 'change') {
-                const this_user = _.find(auditorList, { aid: this_aid });
-                this_user.aid = user.id;
-                this_user.company = user.company;
-                this_user.role = user.role;
-                this_user.name = user.name;
-                auditorList.splice(curAuditorIndex, 1, this_user);
-                $(this).parents('tr').children('td').eq(0).html(`<span class="shenpi-order">${order}</span> ${user.name} <small class="text-muted">${user.role}</small>`);
-                // 替换所有aid
-                $(this).parents('.book-list').attr('data-aid', user.id);
-                $(this).parents('.dropdown-menu').attr('id', user.id +'_change_dropdownMenu').attr('aria-labelledby', user.id +'_change_dropdownMenuButton');
-                $(this).parents('.dropdown-menu').children('mb-2').children('input').attr('data-code', user.id +'_change');
-                $(this).parents('.dropdown-menu').siblings('.change-audit').attr('id', user.id +'_change_dropdownMenuButton');
-                $(this).parents('td').children('span').eq(0).find('.add-audit').attr('id', user.id +'_add_dropdownMenuButton');
-                $(this).parents('td').children('span').eq(0).find('.dropdown-menu').attr('id', user.id +'_add_dropdownMenu').attr('aria-labelledby', user.id +'_add_dropdownMenuButton');
-                $(this).parents('td').children('span').eq(0).find('.dropdown-menu').children('mb-2').children('input').attr('data-code', user.id +'_add');
-                $(this).parents('td').children('span').eq(0).find('.dropdown-menu').children('.book-list').attr('data-aid', user.id);
-                $(this).parents('td').children('span').eq(2).find('.remove-audit').attr('data-id', user.id);
-            }
+            $('#admin-edit-shenpi-list').html(getAdminEditShenpiListHtml(datas));
             changeLiucheng(datas);
         });
     });
@@ -374,62 +375,72 @@ $(document).ready(function () {
             old_aid: id,
         };
         postData(getUrlPre() + '/audit/save', prop, (datas) => {
-            updateOrder(id, 0);
-            const curAuditorIndex = _.findIndex(auditorList, { aid: id });
-            auditorList.splice(curAuditorIndex, 1);
-            $(this).parents('tr').remove();
+            $('#admin-edit-shenpi-list').html(getAdminEditShenpiListHtml(datas));
             changeLiucheng(datas);
         });
     });
 
-    // 比uid大的序号进行调整
-    function updateOrder(aid, num = 1) {
-        const index = _.findIndex(auditorList, { aid });
-        for (let i = index;i < auditorList.length; i++) {
-            $('#admin-edit-shenpi tbody').children('tr').eq(i).find('.shenpi-order').text(i+num);
-        }
-    }
+    const getAuditTypeText = function (type) {
+        if (type === auditType.key.common) return '';
+        return `<span class="text-${auditType.info[type].class}">${auditType.info[type].long}</span>`;
+    };
 
     function changeLiucheng(datas) {
         const auditorshtml = [];
-        let lastAuditorHtml = '';
+        let lastAuditorHtml = [];
         for (const [index,data] of datas.entries()) {
-            auditorshtml.push('<li class="list-group-item" data-auditorid="' + data.aid + '">');
-            auditorshtml.push('<i class="fa ' + (index+1 === datas.length ? 'fa-stop-circle' : 'fa-chevron-circle-down') + '"></i> ');
-            auditorshtml.push(data.name + ' <small class="text-muted">' + data.role + '</small>');
+            auditorshtml.push('<li class="list-group-item d-flex justify-content-between align-items-center">');
             if (index === 0) {
-                auditorshtml.push('<span class="pull-right">原报</span>');
+                auditorshtml.push('<span class="mr-1"><i class="fa fa fa-play-circle fa-rotate-90"></i></span>');
             } else if (index+1 === datas.length) {
-                auditorshtml.push('<span class="pull-right">终审</span>');
+                auditorshtml.push('<span class="mr-1"><i class="fa fa fa-stop-circle"></i></span>');
             } else {
-                auditorshtml.push('<span class="pull-right">'+ transFormToChinese(index) +'审</span>');
+                auditorshtml.push('<span class="mr-1"><i class="fa fa-chevron-circle-down"></i></span>');
+            }
+            auditorshtml.push('<span class="text-muted">');
+            for (const u of data) {
+                auditorshtml.push(`<small class="d-inline-block text-dark mx-1" title="${u.role}" data-auditorId="<%- u.aid %>">${u.name}</small>`);
             }
+            auditorshtml.push('</span>');
+            auditorshtml.push('<div class="d-flex ml-auto">');
+            if (data[0].audit_type !== auditType.key.common) auditorshtml.push(`<span class="badge badge-pill badge-${auditType.info[data[0].audit_type].class} p-1"><small>${auditType.info[data[0].audit_type].short}</small></span>`);
+            if (index === 0) {
+                auditorshtml.push('<span class="badge badge-light badge-pill ml-auto"><small>原报</small></span>');
+            } else if (index+1 === datas.length) {
+                auditorshtml.push('<span class="badge badge-light badge-pill"><small>终审</small></span>');
+            } else {
+                auditorshtml.push('<span class="badge badge-light badge-pill"><small>'+ transFormToChinese(index) +'审</small></span>');
+            }
+            auditorshtml.push('</div>');
             auditorshtml.push('</li>');
-            if (data.status === sam_auditConst.status.uncheck) {
-                lastAuditorHtml += '<li class="timeline-list-item pb-2 is_uncheck">\n' +
-                    '                                            <div class="timeline-item-date">\n' +
-                    '                                                \n' +
-                    '                                            </div>\n' +
-                    '                                            <div class="timeline-item-icon bg-secondary text-light">\n' +
-                    '                                            </div>\n' +
-                    '                                            <div class="timeline-item-content">\n' +
-                    '                                                <div class="card">\n' +
-                    '                                                    <div class="card-body p-3">\n' +
-                    '                                                        <div class="card-text">\n' +
-                    `                                                            <p class="mb-1"><span class="h5">${data.name}</span>\n` +
-                    '                                                                <span class="pull-right ">\n' +
-                    '                                                                </span>\n' +
-                    '                                                            </p>\n' +
-                    `                                                            <p class="text-muted mb-0">${data.role}</p>\n` +
-                    '                                                        </div>\n' +
-                    '                                                    </div>\n' +
-                    '                                                </div>\n' +
-                    '                                            </div>\n' +
-                    '                                        </li>';
+            if (data[0].status === sam_auditConst.status.uncheck) {
+                lastAuditorHtml.push('<li class="timeline-list-item pb-2 is_uncheck">');
+                if (index < datas.length - 1) {
+                    lastAuditorHtml.push('<div class="timeline-item-tail"></div>');
+                }
+                lastAuditorHtml.push('<div class="timeline-item-icon bg-secondary text-light"></div>');
+
+                lastAuditorHtml.push('<div class="timeline-item-content">');
+                lastAuditorHtml.push(`<div class="py-1">
+                        <span class="text-black-50">
+                        ${ !index === datas.length - 1 ? data[0].audit_order + '' : '终' }审 ${getAuditTypeText(data[0].audit_type)}
+                        </span>
+                    </div>`);
+                lastAuditorHtml.push('<div class="card"><div class="card-body px-3 py-0">');
+                for (const [i, auditor] of data.entries()) {
+                    lastAuditorHtml.push(`<div class="card-text p-2 py-3 row ${ ( i > 0 ? 'border-top' : '') }">`);
+                    lastAuditorHtml.push(`<div class="col"><span class="h6">${auditor.name}</span><span class="text-muted ml-1">${auditor.role}</span></div>`);
+                    lastAuditorHtml.push('<div class="col">');
+                    lastAuditorHtml.push('</div>');
+                    lastAuditorHtml.push('</div>');
+                }
+                lastAuditorHtml.push('</div></div>');
+                lastAuditorHtml.push('</div>');
+                lastAuditorHtml.push('</li>');
             }
         }
         $('.last-auditor-list .is_uncheck').remove();
-        $('.last-auditor-list').append(lastAuditorHtml);
+        $('.last-auditor-list').append(lastAuditorHtml.join(''));
         $('.auditors-list').html(auditorshtml.join(''));
 
     }

+ 34 - 0
app/service/shenpi_audit.js

@@ -318,6 +318,40 @@ module.exports = app => {
                 }
             }
         }
+
+        async updateAuditListWithAuditType(transaction, tenderId, sp_status, sp_type, auditGroup) {
+            const auditList = await this.getAuditList(tenderId, sp_type, sp_status);
+            const newAuditList = [];
+            for (const group of auditGroup) {
+                newAuditList.push(...group);
+            }
+            let sameAudit = auditList.length === newAuditList.length;
+            if (sameAudit) {
+                for (const audit of auditList) {
+                    const newAudit = newAuditList.find(x => { return x.audit_id === audit.aid; });
+                    if (!newAudit || newAudit.audit_order !== audit.audit_order || newAudit.audit_type !== audit.audit_type) {
+                        sameAudit = false;
+                        break;
+                    }
+                }
+            }
+            if (sameAudit) return;
+
+            // 更新固定审批流
+            await transaction.delete(this.tableName, { tid: tenderId, sp_type, sp_status });
+            const insertDatas = [];
+            for (const a of newAuditList) {
+                insertDatas.push({
+                    tid: tenderId,
+                    sp_type,
+                    sp_status,
+                    audit_id: a.aid,
+                    audit_order: a.audit_order,
+                    audit_type: a.audit_type
+                });
+            }
+            await transaction.insert(this.tableName, insertDatas);
+        }
     }
 
     return ShenpiAudit;

+ 27 - 4
app/service/stage_audit.js

@@ -1939,7 +1939,9 @@ module.exports = app => {
                         tid: this.ctx.tender.id,
                         sid: stageId,
                         aid: data.new_aid,
-                        order: now_audit.order+1,
+                        order: now_audit.order + 1,
+                        audit_order: now_audit.audit_order + 1,
+                        audit_type: auditType.key.common,
                         times: times,
                         status: 1
                     };
@@ -1947,12 +1949,28 @@ module.exports = app => {
                     await this._syncOrderByDelete(transaction, stageId, now_audit.order+1, times, '+');
                     await transaction.insert(this.tableName, newAudit);
                     // 更新审批流程页数据,如果存在
+                } else if (data.operate === 'add-sibling') {
+                    if (now_audit.status !== auditConst.status.uncheck && now_audit.status !== auditConst.status.checking) {
+                        throw '当前人下无法操作新增';
+                    }
+                    const newAudit = {
+                        tid: this.ctx.tender.id,
+                        sid: stageId,
+                        aid: data.new_aid,
+                        order: now_audit.order,
+                        audit_order: now_audit.audit_order,
+                        audit_type: now_audit.audit_type,
+                        times: times,
+                        status: 1
+                    };
+                    await transaction.insert(this.tableName, newAudit);
                 } else if (data.operate === 'del') {
                     if (now_audit.status !== auditConst.status.uncheck) {
                         throw '当前人无法操作删除';
                     }
+                    const flowAuditors = auditors.filter(x => { return x.order === now_audit.order; });
                     await transaction.delete(this.tableName, { sid: stageId, times, aid: now_audit.aid, order: now_audit.order });
-                    await this._syncOrderByDelete(transaction, stageId, now_audit.order, times);
+                    if (flowAuditors.length === 1) await this._syncOrderByDelete(transaction, stageId, now_audit.order, times);
                     // 旧的更新为is_old为1
                     await transaction.update(this.tableName, { is_old: 1 }, {
                         where: {
@@ -1977,7 +1995,12 @@ module.exports = app => {
                         }
                     });
                 }
-                if (this.ctx.tender.info.shenpi.stage === shenpiConst.sp_status.gdspl || this.ctx.tender.info.shenpi.stage === shenpiConst.sp_status.gdzs) {
+                if (this.ctx.tender.info.shenpi.stage === shenpiConst.sp_status.gdspl) {
+                    const newAuditors = await transaction.select(this.tableName, { where: { sid: stageId, times } });
+                    const newAuditorGroup = this.ctx.helper.groupAuditors(newAuditors);
+                    const uniqNewAuditorGroup = this.ctx.helper.groupAuditorsUniq(newAuditorGroup);
+                    await this.ctx.service.shenpiAudit.updateAuditListWithAuditType(transaction, this.ctx.tender.id, this.ctx.tender.info.shenpi.stage, shenpiConst.sp_type.stage, uniqNewAuditorGroup);
+                } else if (this.ctx.tender.info.shenpi.stage === shenpiConst.sp_status.gdzs) {
                     const newAuditors = await this.getAuditGroupByList(stageId, times, transaction);
                     await this.ctx.service.shenpiAudit.updateAuditList(transaction, this.ctx.tender.id, this.ctx.tender.info.shenpi.stage, shenpiConst.sp_type.stage, this._.map(newAuditors, 'aid'));
                 }
@@ -1997,7 +2020,7 @@ module.exports = app => {
         async getUserGroup(stageId, times) {
             const group = await this.getAuditorGroup(stageId, times);
             const sql =
-                'SELECT pa.`id` As aid, pa.`name`, pa.`company`, pa.`role`, ? As times, ? As sid, 0 As `order`' +
+                'SELECT pa.`id` As aid, pa.`name`, pa.`company`, pa.`role`, ? As times, ? As sid, 0 As `order`, 1 As audit_type, 0 As audit_order' +
                 '  FROM ' + this.ctx.service.stage.tableName + ' As s' +
                 '  LEFT JOIN ' + this.ctx.service.projectAccount.tableName + ' As pa' +
                 '  ON s.user_id = pa.id' +

+ 82 - 35
app/view/stage/audit_modal.ejs

@@ -795,36 +795,48 @@
                         </style>
                         <table class="table table-hover" id="admin-edit-shenpi">
                             <thead>
-                            <tr class="card-header">
-                                <th>审批流程</th>
+                            <tr class="card-header text-center">
+                                <th width="100px">审批流程</th>
+                                <th>审批人员</th>
                                 <th width="80" style="text-align: center">审批状态</th>
                                 <th width="200" style="text-align: center">操作</th>
                             </tr>
                             </thead>
-                            <% for (let i = 1, iLen = ctx.stage.auditors2.length; i < iLen; i++) { %>
+                            <tbody id="admin-edit-shenpi-list">
+                            <% for (const [i, group] of ctx.stage.auditors2.entries()) { %>
+                            <% if (i === 0) continue; %>
+                            <% for (const [j, auditor] of group.entries()) { %>
                             <tr>
-                                <td><span class="shenpi-order"><%- i %></span> <%- ctx.stage.auditors2[i].name %> <small class="text-muted"><%- ctx.stage.auditors2[i].role %></small></td>
-                                <td style="text-align: center"><span class="<%- auditConst.auditStringClass[ctx.stage.auditors2[i].status] %>"><%- ctx.stage.auditors2[i].status !== auditConst.status.uncheck ? auditConst.auditString[ctx.stage.auditors2[i].status] : '待审批'  %></span></td>
+                                <td class="text-left d-flex">
+                                    <% if (j === 0) { %>
+                                    <%- i + '审' %>
+                                    <% if (auditor.audit_type !== auditType.key.common) { %>
+                                    <span class="ml-2 badge badge-pill badge-<%-  auditType.info[auditor.audit_type].class %> p-1"><small><%- auditType.info[auditor.audit_type].short %></small></span>
+                                    <% } %>
+                                    <% } %>
+                                </td>
+                                <td></span> <%- auditor.name %> <small class="text-muted"><%- auditor.role %></small></td>
+                                <td style="text-align: center"><span class="<%- auditConst.auditStringClass[auditor.status] %>"><%- auditor.status !== auditConst.status.uncheck ? auditConst.auditString[auditor.status] : '待审批'  %></span></td>
                                 <td style="text-align: center">
-                                    <% if (ctx.stage.auditors2[i].status === auditConst.status.checking) { %>
+                                    <% if (auditor.status === auditConst.status.checking && j === group.length - 1) { %>
                                     <span class="dropdown mr-2">
-                                    <a href="javascript: void(0)" class="add-audit" id="<%- ctx.stage.auditors2[i].aid %>_add_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">增加</a>
-                                    <div class="dropdown-menu dropdown-menu-right" id="<%- ctx.stage.auditors2[i].aid %>_add_dropdownMenu" aria-labelledby="<%- ctx.stage.auditors2[i].aid %>_add_dropdownMenuButton" style="width:220px">
+                                    <a href="javascript: void(0)" class="add-audit" id="<%- auditor.aid %>_add_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">增加</a>
+                                    <div class="dropdown-menu dropdown-menu-right" id="<%- auditor.aid %>_add_dropdownMenu" aria-labelledby="<%- auditor.aid %>_add_dropdownMenuButton" style="width:220px">
                                         <div class="mb-2 p-2"><input class="form-control form-control-sm gr-search"
-                                                                     placeholder="姓名/手机 检索" autocomplete="off" data-code="<%- ctx.stage.auditors2[i].aid %>_add"></div>
-                                        <dl class="list-unstyled book-list" data-aid="<%- ctx.stage.auditors2[i].aid %>" data-operate="add">
+                                                                     placeholder="姓名/手机 检索" autocomplete="off" data-code="<%- auditor.aid %>_add"></div>
+                                        <dl class="list-unstyled book-list" data-aid="<%- auditor.aid %>" data-operate="add">
                                             <% accountGroup.forEach((group, idx) => { %>
-                                                <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>
+                                            <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 %>">
                                                     <% group.groupList.forEach(item => { %>
-                                                        <% if (item.id !== ctx.stage.user_id) { %>
-                                                            <dd class="border-bottom p-2 mb-0 " data-id="<%- item.id %>">
+                                                    <% if (item.id !== ctx.stage.user_id) { %>
+                                                    <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>
-                                                        <% } %>
+                                                    <% } %>
                                                     <% });%>
                                                 </div>
                                             <% }) %>
@@ -832,49 +844,77 @@
                                     </div>
                                     </span>
                                     <% } %>
-                                    <% if (ctx.stage.auditors2[i].status === auditConst.status.uncheck) { %>
+                                    <% if (auditor.status === auditConst.status.uncheck) { %>
+                                    <% if (j === group.length - 1) { %>
                                     <span class="dropdown mr-2">
-                                    <a href="javascript: void(0)" class="add-audit" id="<%- ctx.stage.auditors2[i].aid %>_add_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">增加</a>
-                                        <div class="dropdown-menu dropdown-menu-right" id="<%- ctx.stage.auditors2[i].aid %>_add_dropdownMenu" aria-labelledby="<%- ctx.stage.auditors2[i].aid %>_add_dropdownMenuButton" style="width:220px">
+                                    <a href="javascript: void(0)" class="add-audit" id="<%- auditor.aid %>_add_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">增加</a>
+                                        <div class="dropdown-menu dropdown-menu-right" id="<%- auditor.aid %>_add_dropdownMenu" aria-labelledby="<%- auditor.aid %>_add_dropdownMenuButton" style="width:220px">
                                             <div class="mb-2 p-2"><input class="form-control form-control-sm gr-search"
-                                                                         placeholder="姓名/手机 检索" autocomplete="off" data-code="<%- ctx.stage.auditors2[i].aid %>_add"></div>
-                                            <dl class="list-unstyled book-list" data-aid="<%- ctx.stage.auditors2[i].aid %>" data-operate="add">
+                                                                         placeholder="姓名/手机 检索" autocomplete="off" data-code="<%- auditor.aid %>_add"></div>
+                                            <dl class="list-unstyled book-list" data-aid="<%- auditor.aid %>" data-operate="add">
                                                 <% accountGroup.forEach((group, idx) => { %>
-                                                    <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>
+                                                <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 %>">
                                                         <% group.groupList.forEach(item => { %>
-                                                            <% if (item.id !== ctx.stage.user_id) { %>
-                                                                <dd class="border-bottom p-2 mb-0 " data-id="<%- item.id %>">
+                                                        <% if (item.id !== ctx.stage.user_id) { %>
+                                                        <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>
-                                                            <% } %>
+                                                        <% } %>
                                                         <% });%>
                                                     </div>
                                                 <% }) %>
                                             </dl>
                                         </div>
                                     </span>
+                                    <% if (auditor.audit_type !== auditType.key.common) { %>
                                     <span class="dropdown mr-2">
-                                        <a href="javascript: void(0)" class="change-audit" id="<%- ctx.stage.auditors2[i].aid %>_change_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">更换</a>
-                                        <div class="dropdown-menu dropdown-menu-right" id="<%- ctx.stage.auditors2[i].aid %>_change_dropdownMenu" aria-labelledby="<%- ctx.stage.auditors2[i].aid %>_change_dropdownMenuButton" style="width:220px">
+                                    <a href="javascript: void(0)" class="add-audit" id="<%- auditor.aid %>_add-sibling_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">平级</a>
+                                        <div class="dropdown-menu dropdown-menu-right" id="<%- auditor.aid %>_add-sibling_dropdownMenu" aria-labelledby="<%- auditor.aid %>_add-sibling_dropdownMenuButton" style="width:220px">
                                             <div class="mb-2 p-2"><input class="form-control form-control-sm gr-search"
-                                                                         placeholder="姓名/手机 检索" autocomplete="off" data-code="<%- ctx.stage.auditors2[i].aid %>_change"></div>
-                                            <dl class="list-unstyled book-list" data-aid="<%- ctx.stage.auditors2[i].aid %>" data-operate="change">
+                                                                         placeholder="姓名/手机 检索" autocomplete="off" data-code="<%- auditor.aid %>_add-sibling"></div>
+                                            <dl class="list-unstyled book-list" data-aid="<%- auditor.aid %>" data-operate="add-sibling">
                                                 <% accountGroup.forEach((group, idx) => { %>
-                                                    <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>
+                                                <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 %>">
                                                         <% group.groupList.forEach(item => { %>
-                                                            <% if (item.id !== ctx.stage.user_id) { %>
-                                                                <dd class="border-bottom p-2 mb-0 " data-id="<%- item.id %>">
+                                                        <% if (item.id !== ctx.stage.user_id) { %>
+                                                        <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>
-                                                            <% } %>
+                                                        <% } %>
+                                                        <% });%>
+                                                    </div>
+                                                <% }) %>
+                                            </dl>
+                                        </div>
+                                    </span>
+                                    <% } %>
+                                    <% } %>
+                                    <span class="dropdown mr-2">
+                                        <a href="javascript: void(0)" class="change-audit" id="<%- auditor.aid %>_change_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">更换</a>
+                                        <div class="dropdown-menu dropdown-menu-right" id="<%- auditor.aid %>_change_dropdownMenu" aria-labelledby="<%- auditor.aid %>_change_dropdownMenuButton" style="width:220px">
+                                            <div class="mb-2 p-2"><input class="form-control form-control-sm gr-search"
+                                                                         placeholder="姓名/手机 检索" autocomplete="off" data-code="<%- auditor.aid %>_change"></div>
+                                            <dl class="list-unstyled book-list" data-aid="<%- auditor.aid %>" data-operate="change">
+                                                <% accountGroup.forEach((group, idx) => { %>
+                                                <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 %>">
+                                                        <% group.groupList.forEach(item => { %>
+                                                        <% if (item.id !== ctx.stage.user_id) { %>
+                                                        <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>
+                                                        <% } %>
                                                         <% });%>
                                                     </div>
                                                 <% }) %>
@@ -887,7 +927,7 @@
                                         <span class="dropdown-item" href="javascript:void(0);">确认移除审批人?</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="<%- ctx.stage.auditors2[i].aid %>">移除</button>
+                                            <button class="remove-audit btn btn-sm btn-danger" data-id="<%- auditor.aid %>">移除</button>
                                             <button class="btn btn-sm btn-secondary">取消</button>
                                         </div>
                                     </div>
@@ -896,11 +936,17 @@
                                 </td>
                             </tr>
                             <% } %>
+                            <% } %>
+                            </tbody>
                         </table>
                     </div>
                 </div>
             </div>
             <form class="modal-footer">
+                <div class="mr-auto text-warning">
+                    <span class="mr-3">增加:后级审核人</span>
+                    <span class="">平级:会签/或签增加平级审核人</span>
+                </div>
                 <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">关闭</button>
             </form>
         </div>
@@ -912,6 +958,7 @@
     const csrf = '<%= ctx.csrf %>';
     const authMobile = '<%= authMobile %>';
     const sam_auditConst = JSON.parse('<%- JSON.stringify(auditConst) %>');
+    const auditType = JSON.parse('<%- JSON.stringify(auditType) %>');
 </script>
 <% if (ctx.stage && (ctx.session.sessionUser.accountId === ctx.stage.user_id && (ctx.stage.status === auditConst.status.uncheck || ctx.stage.status === auditConst.status.checkNo))) { %>
 <script>