Browse Source

台账审批增加管理员控制流程

ellisran 11 months ago
parent
commit
60b94af815

+ 22 - 0
app/controller/ledger_audit_controller.js

@@ -188,6 +188,28 @@ module.exports = app => {
                 ctx.redirect(ctx.request.header.referer);
             }
         }
+
+        async saveAudit(ctx) {
+            try {
+                const data = JSON.parse(ctx.request.body.data);
+                if (ctx.session.sessionUser.is_admin && ctx.tender.ledger_status !== auditConst.status.checked) {
+                    await ctx.service.ledgerAudit.saveAudit(ctx.tender.id, ctx.tender.data.ledger_times, data);
+                    const auditors = await ctx.service.ledgerAudit.getAuditorsWithOwner(ctx.tender.id, ctx.tender.data.ledger_times);
+                    ctx.body = { err: 0, msg: '', data: auditors };
+                } else {
+                    throw '您无权进行该操作';
+                }
+            } 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,
+                };
+            }
+        }
     }
 
     return LedgerAuditController;

+ 1 - 1
app/controller/ledger_controller.js

@@ -156,7 +156,7 @@ module.exports = app => {
                     authMobile: pa.auth_mobile,
                     deleteFilePermission: PermissionCheck.delFile(this.ctx.session.sessionUser.permission),
                 };
-                if ((tender.data.ledger_status === auditConst.status.uncheck || tender.data.ledger_status === auditConst.status.checkNo) && tender.data.user_id === ctx.session.sessionUser.accountId) {
+                if ((tender.data.ledger_status !== auditConst.status.checked && ctx.session.sessionUser.is_admin) || ((tender.data.ledger_status === auditConst.status.uncheck || tender.data.ledger_status === auditConst.status.checkNo) && tender.data.user_id === ctx.session.sessionUser.accountId)) {
                     // renderData.accountGroup = accountGroup;
                     // 获取所有项目参与者
                     const accountList = await ctx.service.projectAccount.getAllDataByCondition({

+ 224 - 3
app/public/js/ledger.js

@@ -4130,7 +4130,7 @@ $(document).ready(function() {
     });
 
     // 添加审批流程按钮逻辑
-    $('.book-list').on('click', 'dt', function () {
+    $('body').on('click', '.book-list dt', function () {
         const idx = $(this).find('.acc-btn').attr('data-groupid')
         const type = $(this).find('.acc-btn').attr('data-type')
         if (type === 'hide') {
@@ -4149,7 +4149,7 @@ $(document).ready(function() {
     });
 
     // 添加到审批流程中
-    $('dl').on('click', 'dd', function () {
+    $('#book-list').on('click', 'dd', function () {
         const auditorId = parseInt($(this).data('id'))
         if (auditorId) {
             postData('/tender/' + getTenderId() + '/ledger/audit/add', { auditorId }, (datas) => {
@@ -4222,11 +4222,232 @@ $(document).ready(function() {
         $('#sp-list').modal('hide');
     });
 
+    $('a[f-target]').click(function () {
+        $($(this).attr('f-target')).modal('show');
+    });
+
     // 多层modal关闭后的滚动bug修复
     $('#sp-list').on('hidden.bs.modal', function (e) {
         $(document.body).addClass('modal-open');
     });
 
+    // 管理员更改审批流程js部分
+    let timer2 = null;
+    let oldSearchVal2 = null;
+    $('body').on('input propertychange', '.gr-search', function(e) {
+        oldSearchVal2 = e.target.value;
+        timer2 && clearTimeout(timer2);
+        timer2 = setTimeout(() => {
+            const newVal = $(this).val();
+            const code = $(this).attr('data-code');
+            let html = '';
+            if (newVal && newVal === oldSearchVal2) {
+                accountList.filter(item => item && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => {
+                    html += `<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>`
+                });
+                $('#' + code + '_dropdownMenu .book-list').empty();
+                $('#' + code + '_dropdownMenu .book-list').append(html);
+            } else {
+                if (!$('#' + code + '_dropdownMenu .acc-btn').length) {
+                    accountGroup.forEach((group, idx) => {
+                        if (!group) return;
+                        html += `<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 => {
+                            html += `<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>`;
+                        });
+                        html += '</div>';
+                    });
+                    $('#' + code + '_dropdownMenu .book-list').empty();
+                    $('#' + code + '_dropdownMenu .book-list').append(html);
+                }
+            }
+        }, 400);
+    });
+
+    $('body').on('click', '#admin-edit-shenpi dl dd', function () {
+        const id = parseInt($(this).attr('data-id'));
+        if (!id) return;
+
+        let this_aid = parseInt($(this).parents('.book-list').attr('data-aid'));
+        let this_operate = $(this).parents('.book-list').attr('data-operate');
+        const user = _.find(accountList, function (item) {
+            return item.id === id;
+        });
+        const auditorIndex = _.findIndex(auditorList, { audit_id: id });
+        if (auditorIndex !== -1) {
+            toastr.warning('该审核人已存在,请勿重复添加');
+            return;
+        }
+        const order = parseInt($(this).parents('tr').find('.shenpi-order').text());
+        const curAuditorIndex = _.findIndex(auditorList, { audit_id: this_aid });
+        const prop = {
+            operate: this_operate,
+            old_aid: this_aid,
+            new_aid: user.id,
+        };
+        postData('/tender/' + getTenderId() + '/ledger/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, { audit_id: user.id, company: user.company, name: user.name, role: user.role });
+                updateOrder(user.id);
+            } else if (this_operate === 'change') {
+                const this_user = _.find(auditorList, { audit_id: this_aid });
+                this_user.audit_id = 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);
+            }
+            changeLiucheng(datas);
+        });
+    });
+
+    // 移除审批人
+    $('body').on('click', '.remove-audit', function () {
+        const id = parseInt($(this).attr('data-id'));
+        const prop = {
+            operate: 'del',
+            old_aid: id,
+        };
+        postData('/tender/' + getTenderId() + '/ledger/audit/save', prop, (datas) => {
+            updateOrder(id, 0);
+            const curAuditorIndex = _.findIndex(auditorList, { audit_id: id });
+            auditorList.splice(curAuditorIndex, 1);
+            $(this).parents('tr').remove();
+            changeLiucheng(datas);
+        });
+    });
+
+    // 比uid大的序号进行调整
+    function updateOrder(aid, num = 1) {
+        const index = _.findIndex(auditorList, { audit_id: aid });
+        for (let i = index;i < auditorList.length; i++) {
+            $('#admin-edit-shenpi tbody').children('tr').eq(i).find('.shenpi-order').text(i+num);
+        }
+    }
+
+    function changeLiucheng(datas) {
+        const auditorshtml = [];
+        let lastAuditorHtml = '';
+        for (const [index,data] of datas.entries()) {
+            auditorshtml.push('<li class="list-group-item" data-auditorid="' + data.audit_id + '">');
+            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>');
+            if (index === 0) {
+                auditorshtml.push('<span class="pull-right">原报</span>');
+            } else if (index+1 === datas.length) {
+                auditorshtml.push('<span class="pull-right">终审</span>');
+            } else {
+                auditorshtml.push('<span class="pull-right">'+ transFormToChinese(index) +'审</span>');
+            }
+            auditorshtml.push('</li>');
+            if (data.status === 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>';
+            }
+        }
+        $('.last-auditor-list .is_uncheck').remove();
+        $('.last-auditor-list').append(lastAuditorHtml);
+        $('.auditors-list').html(auditorshtml.join(''));
+
+    }
+
+    // 审批流程-选择审批人html 生成
+    function makeSelectAudit(code, aid, status) {
+        let divhtml = '';
+        accountGroup.forEach((group, idx) => {
+            let didivhtml = '';
+            if(group) {
+                group.groupList.forEach(item => {
+                    didivhtml += '<dd class="border-bottom p-2 mb-0 " data-id="' + item.id + '" >\n' +
+                        '<p class="mb-0 d-flex"><span class="text-primary">' + item.name + '</span><span\n' +
+                        '                                                                                class="ml-auto">' + item.mobile + '</span></p>\n' +
+                        '                                                                    <span class="text-muted">' + item.role + '</span>\n' +
+                        '                                                                    </dd>\n';
+                });
+                divhtml += '<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>\n' +
+                    '                                                                <div class="dd-content" data-toggleid="' + idx + '">\n' + didivhtml +
+                    '                                                                </div>\n';
+            }
+        });
+        let html = '<div class="dropdown-menu dropdown-menu-right" id="' + code + '_dropdownMenu" aria-labelledby="' + code + '_dropdownMenuButton" style="width:220px">\n' +
+            '                                                        <div class="mb-2 p-2"><input class="form-control form-control-sm gr-search"\n' +
+            '                                                                                     placeholder="姓名/手机 检索" autocomplete="off" data-code="' + code + '"></div>\n' +
+            '                                                        <dl class="list-unstyled book-list" data-aid="'+ aid +'" data-operate="'+ status +'">\n' + divhtml +
+            '                                                        </dl>\n' +
+            '                                                    </div>\n' +
+            '                                                </div>\n' +
+            '                                            </span>\n' +
+            '                                        </span>\n' +
+            '                                        </li>';
+        return html;
+    }
+
     // 显示层次
     (function (select, sheet) {
         $(select).click(function () {
@@ -4806,4 +5027,4 @@ function auditCheck(i) {
     const opinion = $('textarea[name="opinion"]').eq(i).val().replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' ');
     $('textarea[name="opinion"]').eq(i).val(opinion);
     return true;
-}
+}

+ 1 - 0
app/router.js

@@ -252,6 +252,7 @@ module.exports = app => {
     // 台账审批相关
     app.post('/tender/:id/ledger/audit/add', sessionAuth, tenderCheck, uncheckTenderCheck, 'ledgerAuditController.add');
     app.post('/tender/:id/ledger/audit/delete', sessionAuth, tenderCheck, uncheckTenderCheck, 'ledgerAuditController.remove');
+    app.post('/tender/:id/ledger/audit/save', sessionAuth, tenderCheck, uncheckTenderCheck, 'ledgerAuditController.saveAudit');
     app.post('/tender/:id/ledger/audit/start', sessionAuth, tenderCheck, uncheckTenderCheck, ledgerAuditCheck, tenderBuildCheck, 'ledgerAuditController.start');
     app.post('/tender/:id/ledger/audit/check', sessionAuth, tenderCheck, uncheckTenderCheck, tenderBuildCheck, 'ledgerAuditController.check');
     app.post('/tender/:id/ledger/audit/check/again', sessionAuth, tenderCheck, uncheckTenderCheck, tenderBuildCheck, 'ledgerAuditController.checkAgain');

+ 72 - 3
app/service/ledger_audit.js

@@ -605,13 +605,13 @@ module.exports = app => {
          * @param {Number} times 审核次数
          * @return {Promise<Array>} 查询结果集
          */
-        async getAuditGroupByList(tender_id, times = 1) {
+        async getAuditGroupByList(tender_id, times = 1, transaction = null) {
             const sql =
-                'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`tender_id`, la.`audit_order` ' +
+                'SELECT la.`audit_id`, la.`status`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`tender_id`, la.`audit_order` ' +
                 '  FROM ?? AS la Left Join ?? AS pa On la.`audit_id` = pa.`id`' +
                 '  WHERE la.`tender_id` = ? and la.`times` = ? GROUP BY la.`audit_id` ORDER BY la.`audit_order`';
             const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tender_id, times];
-            return await this.db.query(sql, sqlParam);
+            return transaction ? await transaction.query(sql, sqlParam) : await this.db.query(sql, sqlParam);
         }
 
         /**
@@ -682,6 +682,75 @@ module.exports = app => {
                 throw err;
             }
         }
+
+        /**
+         * 删除本次审批流程
+         * @param {Number} stageId - 标段id
+         * @param {Number} times - 第几次审批
+         * @param {Object} data - 更改参数
+         * @return {Promise<void>}
+         */
+        async saveAudit(tenderId, times, data) {
+            const transaction = await this.db.beginTransaction();
+            try {
+                const auditors = await this.getAuditGroupByList(tenderId, times);
+                const now_audit = this._.find(auditors, { audit_id: data.old_aid });
+                if (data.operate === 'add') {
+                    if (now_audit.status !== auditConst.status.uncheck && now_audit.status !== auditConst.status.checking) {
+                        throw '当前人下无法操作新增';
+                    }
+                    const newAudit = {
+                        tender_id: tenderId,
+                        audit_id: data.new_aid,
+                        audit_order: now_audit.audit_order + 1,
+                        times,
+                        status: auditConst.status.uncheck,
+                    };
+                    // order+1
+                    await this._syncOrderByDelete(transaction, tenderId, now_audit.audit_order + 1, times, '+');
+                    await transaction.insert(this.tableName, newAudit);
+                    // 更新审批流程页数据,如果存在
+                } else if (data.operate === 'del') {
+                    if (now_audit.status !== auditConst.status.uncheck) {
+                        throw '当前人无法操作删除';
+                    }
+                    await transaction.delete(this.tableName, { tender_id: tenderId, times, audit_id: now_audit.audit_id, audit_order: now_audit.audit_order });
+                    await this._syncOrderByDelete(transaction, tenderId, now_audit.audit_order, times);
+                    // // 旧的更新为is_old为1
+                    // await transaction.update(this.tableName, { is_old: 1 }, {
+                    //     where: {
+                    //         sid: stageId,
+                    //         times,
+                    //         aid: data.old_aid,
+                    //     }
+                    // });
+                } else if (data.operate === 'change') {
+                    const nowAudit = await this.getDataByCondition({ tender_id: tenderId, times, audit_id: now_audit.audit_id, audit_order: now_audit.audit_order });
+                    if (now_audit.status !== auditConst.status.uncheck || !nowAudit) {
+                        throw '当前人无法操作替换';
+                    }
+                    nowAudit.audit_id = data.new_aid;
+                    await transaction.update(this.tableName, nowAudit);
+                    // 旧的更新为is_old为1
+                    // await transaction.update(this.tableName, { is_old: 1 }, {
+                    //     where: {
+                    //         sid: stageId,
+                    //         times,
+                    //         aid: data.old_aid,
+                    //     }
+                    // });
+                }
+                if (this.ctx.tender.info.shenpi.ledger === shenpiConst.sp_status.gdspl || this.ctx.tender.info.shenpi.ledger === shenpiConst.sp_status.gdzs) {
+                    const newAuditors = await this.getAuditGroupByList(tenderId, times, transaction);
+                    await this.ctx.service.shenpiAudit.updateAuditList(transaction, this.ctx.tender.id, this.ctx.tender.info.shenpi.ledger, shenpiConst.sp_type.ledger, this._.map(newAuditors, 'audit_id'));
+                }
+                // 更新到审批流程方法
+                await transaction.commit();
+            } catch (err) {
+                await transaction.rollback();
+                throw err;
+            }
+        }
     }
 
     return LedgerAudit;

+ 152 - 9
app/view/ledger/audit_modal.ejs

@@ -9,8 +9,11 @@
             <div class="modal-body">
                 <div class="row">
                     <div class="col-4">
+                        <% if(tender.ledger_status !== auditConst.status.checked && ctx.session.sessionUser.is_admin) { %>
+                            <a class="sp-list-item" href="#sub-sp2" data-toggle="modal" data-target="#sub-sp2" id="hideSp">修改审批流程</a>
+                        <% } %>
                         <div class="card mt-3">
-                            <ul class="list-group list-group-flush">
+                            <ul class="list-group list-group-flush auditors-list">
                                 <% auditors.forEach((item, idx) => { %>
                                 <% if (idx === 0) { %>
                                 <li class="list-group-item" data-auditorId="<%- item.audit_id %>">
@@ -45,7 +48,7 @@
                             <% } %>
                         <div class="<%- idx < auditHistory.length - 1 ? 'fold-card' : '' %>">
                             <div class="text-center text-muted"><%- idx+1 %>#</div>
-                            <ul class="timeline-list list-unstyled mt-2">
+                            <ul class="timeline-list list-unstyled mt-2 <% if (idx === auditHistory.length - 1) { %>last-auditor-list<% } %>">
                                 <% auditors.forEach((auditor, index) => { %>
                                 <% if (index === 0) { %>
                                 <li class="timeline-list-item pb-2">
@@ -70,7 +73,7 @@
                                         </div>
                                     </div>
                                 </li>
-                                <li class="timeline-list-item pb-2">
+                                <li class="timeline-list-item pb-2 <% if (auditor.status === auditConst.status.uncheck && idx === auditHistory.length - 1) { %>is_uncheck<% } %>">
                                     <div class="timeline-item-date">
                                         <%- ctx.helper.formatDate(auditor.end_time) %>
                                     </div>
@@ -119,7 +122,7 @@
                                     </div>
                                 </li>
                                 <% } else {%>
-                                <li class="timeline-list-item pb-2">
+                                <li class="timeline-list-item pb-2 <% if (auditor.status === auditConst.status.uncheck && idx === auditHistory.length - 1) { %>is_uncheck<% } %>">
                                     <div class="timeline-item-date">
                                         <%- ctx.helper.formatDate(auditor.end_time) %>
                                     </div>
@@ -200,8 +203,11 @@
             <div class="modal-body">
                 <div class="row">
                     <div class="col-4">
+                        <% if(tender.ledger_status !== auditConst.status.checked && ctx.session.sessionUser.is_admin) { %>
+                            <a class="sp-list-item" href="#sub-sp2" data-toggle="modal" data-target="#sub-sp2" id="hideSp">修改审批流程</a>
+                        <% } %>
                         <div class="card mt-3">
-                            <ul class="list-group list-group-flush">
+                            <ul class="list-group list-group-flush auditors-list">
                                 <% auditors.forEach((item, idx) => { %>
                                 <% if (idx === 0) { %>
                                 <li class="list-group-item" data-auditorId="<%- item.audit_id %>">
@@ -236,7 +242,7 @@
                             <% } %>
                         <div class="<%- idx < auditHistory.length - 1 ? 'fold-card' : '' %>">
                             <div class="text-center text-muted"><%- idx+1 %>#</div>
-                            <ul class="timeline-list list-unstyled mt-2">
+                            <ul class="timeline-list list-unstyled mt-2 <% if (idx === auditHistory.length - 1) { %>last-auditor-list<% } %>">
                                 <% auditors.forEach((auditor, index) => { %>
                                 <% if (index === 0) { %>
                                 <li class="timeline-list-item pb-2">
@@ -261,7 +267,7 @@
                                         </div>
                                     </div>
                                 </li>
-                                <li class="timeline-list-item pb-2">
+                                <li class="timeline-list-item pb-2 <% if (auditor.status === auditConst.status.uncheck && idx === auditHistory.length - 1) { %>is_uncheck<% } %>">
                                     <div class="timeline-item-date">
                                         <%- ctx.helper.formatDate(auditor.end_time) %>
                                     </div>
@@ -311,7 +317,7 @@
                                     </div>
                                 </li>
                                 <% } else {%>
-                                <li class="timeline-list-item pb-2">
+                                <li class="timeline-list-item pb-2 <% if (auditor.status === auditConst.status.uncheck && idx === auditHistory.length - 1) { %>is_uncheck<% } %>">
                                     <div class="timeline-item-date">
                                         <%- ctx.helper.formatDate(auditor.end_time) %>
                                     </div>
@@ -368,7 +374,6 @@
                                 <% }) %>
                             </ul>
                         </div>
-
                         <% }) %>
                     </div>
                 </div>
@@ -383,6 +388,144 @@
     </div>
 </div>
 <% } %>
+<% if (tender.ledger_status !== auditConst.status.checked && ctx.session.sessionUser.is_admin) { %>
+    <!--上报审批-->
+    <div class="modal fade" id="sub-sp2" data-backdrop="static">
+        <div class="modal-dialog" style="max-width: 650px" role="document">
+            <div class="modal-content">
+                <div class="modal-header">
+                    <h5 class="modal-title">修改审批流程</h5>
+                </div>
+                <div class="modal-body">
+                    <div class="card mt-1">
+                        <div class="modal-height-500" style="overflow: visible">
+                            <style>
+                                #admin-edit-shenpi thead th {
+                                    border-bottom: 0;
+                                }
+                                #admin-edit-shenpi td, #admin-edit-shenpi th {
+                                    padding: 0.75rem;
+                                }
+                                #admin-edit-shenpi th {
+                                    background: none;
+                                    color: #212529;
+                                    border-top: 0;
+                                }
+                            </style>
+                            <table class="table table-hover" id="admin-edit-shenpi">
+                                <thead>
+                                <tr class="card-header">
+                                    <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 = auditors.length; i < iLen; i++) { %>
+                                    <tr>
+                                        <td><span class="shenpi-order"><%- i %></span> <%- auditors[i].name %> <small class="text-muted"><%- auditors[i].role %></small></td>
+                                        <td style="text-align: center"><span class="<%- auditConst.auditStringClass[auditors[i].status] %>"><%- auditors[i].status !== auditConst.status.uncheck ? auditConst.auditString[auditors[i].status] : '待审批'  %></span></td>
+                                        <td style="text-align: center">
+                                            <% if (auditors[i].status === auditConst.status.checking) { %>
+                                                <span class="dropdown mr-2">
+                                    <a href="javascript: void(0)" class="add-audit" id="<%- auditors[i].audit_id %>_add_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">增加</a>
+                                    <div class="dropdown-menu dropdown-menu-right" id="<%- auditors[i].audit_id %>_add_dropdownMenu" aria-labelledby="<%- auditors[i].audit_id %>_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="<%- auditors[i].audit_id %>_add"></div>
+                                        <dl class="list-unstyled book-list" data-aid="<%- auditors[i].audit_id %>" 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>
+                                                <div class="dd-content" data-toggleid="<%- idx %>">
+                                                    <% group.groupList.forEach(item => { %>
+                                                        <% if (item.id !== ctx.tender.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 (auditors[i].status === auditConst.status.uncheck) { %>
+                                                <span class="dropdown mr-2">
+                                    <a href="javascript: void(0)" class="add-audit" id="<%- auditors[i].audit_id %>_add_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">增加</a>
+                                        <div class="dropdown-menu dropdown-menu-right" id="<%- auditors[i].audit_id %>_add_dropdownMenu" aria-labelledby="<%- auditors[i].audit_id %>_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="<%- auditors[i].audit_id %>_add"></div>
+                                            <dl class="list-unstyled book-list" data-aid="<%- auditors[i].audit_id %>" 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>
+                                                    <div class="dd-content" data-toggleid="<%- idx %>">
+                                                        <% group.groupList.forEach(item => { %>
+                                                            <% if (item.id !== ctx.tender.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="<%- auditors[i].audit_id %>_change_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">更换</a>
+                                        <div class="dropdown-menu dropdown-menu-right" id="<%- auditors[i].audit_id %>_change_dropdownMenu" aria-labelledby="<%- auditors[i].audit_id %>_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="<%- auditors[i].audit_id %>_change"></div>
+                                            <dl class="list-unstyled book-list" data-aid="<%- auditors[i].audit_id %>" 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.tender.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">
+                                    <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="<%- auditors[i].audit_id %>">移除</button>
+                                            <button class="btn btn-sm btn-secondary">取消</button>
+                                        </div>
+                                    </div>
+                                    </span>
+                                            <% } %>
+                                        </td>
+                                    </tr>
+                                <% } %>
+                            </table>
+                        </div>
+                    </div>
+                </div>
+                <form class="modal-footer">
+                    <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">关闭</button>
+                </form>
+            </div>
+        </div>
+    </div>
+<% } %>
 <% if (tender.ledger_status === auditConst.status.checked && auditors[auditors.length - 1].audit_id === ctx.session.sessionUser.accountId && !tender.hasStage && !tender.hasRevise) { %>
 <% if (!authMobile && ctx.session.sessionUser.loginStatus === 0) { %>
 <!--终审重新审批-->

+ 2 - 1
app/view/ledger/explode.ejs

@@ -391,9 +391,10 @@
     const syncLedgerUrl = '<%- syncLedgerUrl %>';
     const nodeType = JSON.parse('<%- JSON.stringify(nodeType) %>');
 </script>
-<% if ((tender.ledger_status === auditConst.status.uncheck || tender.ledger_status === auditConst.status.checkNo) && ctx.session.sessionUser.accountId === tender.user_id) { %>
+<% if ((tender.ledger_status !== auditConst.status.checked && ctx.session.sessionUser.is_admin) || ((tender.ledger_status === auditConst.status.uncheck || tender.ledger_status === auditConst.status.checkNo) && ctx.session.sessionUser.accountId === tender.user_id)) { %>
 <script>
     const accountList = JSON.parse('<%- JSON.stringify(accountList) %>');
     const accountGroup = JSON.parse('<%- JSON.stringify(accountGroup) %>');
+    const auditorList = JSON.parse(unescape('<%- escape(JSON.stringify(auditors)) %>'));
 </script>
 <% } %>

+ 9 - 7
app/view/ledger/explode_modal.ejs

@@ -136,7 +136,7 @@
                         style="width:220px">
                         <div class="mb-2 p-2"><input class="form-control form-control-sm"
                                 placeholder="姓名/手机 检索" id="gr-search" autocomplete="off"></div>
-                        <dl class="list-unstyled book-list">
+                        <dl class="list-unstyled book-list" id="book-list">
                             <% 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 %>">
@@ -182,7 +182,7 @@
     </div>
 </div>
 <% } %>
-<% if ((tender.ledger_status !== auditConst.status.unCheck) || (tender.ledger_times > 1)) { %>
+<% if ((tender.ledger_status !== auditConst.status.uncheck) || (tender.ledger_times > 1)) { %>
 <!--审批流程/结果-->
 <div class="modal fade" id="sp-list" data-backdrop="static">
     <div class="modal-dialog modal-lg" role="document">
@@ -195,9 +195,12 @@
                     <div class="col-4">
                         <% if(tender.ledger_status === auditConst.status.checkNo) { %>
                             <a class="sp-list-item" href="#sub-sp" data-toggle="modal" data-target="#sub-sp" id="hideSp">修改审批流程</a>
+                        <% } else if(tender.ledger_status !== auditConst.status.checked && ctx.session.sessionUser.is_admin) { %>
+                            <a class="sp-list-item" href="#sub-sp2" data-toggle="modal" data-target="#sub-sp2"
+                               id="hideSp">修改审批流程</a>
                         <% } %>
                         <div class="card mt-3">
-                            <ul class="list-group list-group-flush" id="auditors-list">
+                            <ul class="list-group list-group-flush auditors-list" id="auditors-list">
                                 <% auditors.forEach((item, idx) => { %>
                                 <% if (idx === 0) { %>
                                 <li class="list-group-item" data-auditorId="<%- item.audit_id %>">
@@ -232,7 +235,7 @@
                         <% } %>
                         <div class="<%- idx < auditHistory.length - 1 ? 'fold-card' : '' %>">
                             <div class="text-center text-muted"><%- idx+1 %>#</div>
-                            <ul class="timeline-list list-unstyled mt-2">
+                            <ul class="timeline-list list-unstyled mt-2 <% if (idx === auditHistory.length - 1) { %>last-auditor-list<% } %>">
                                 <% auditors.forEach((auditor, index) => { %>
                                 <% if (index === 0) { %>
                                 <li class="timeline-list-item pb-2">
@@ -257,7 +260,7 @@
                                         </div>
                                     </div>
                                 </li>
-                                <li class="timeline-list-item pb-2">
+                                <li class="timeline-list-item pb-2 <% if (auditor.status === auditConst.status.uncheck && idx === auditHistory.length - 1) { %>is_uncheck<% } %>">
                                     <div class="timeline-item-date">
                                         <%- ctx.helper.formatDate(auditor.end_time) %>
                                     </div>
@@ -301,7 +304,7 @@
                                     </div>
                                 </li>
                                 <% } else {%>
-                                <li class="timeline-list-item pb-2">
+                                <li class="timeline-list-item pb-2 <% if (auditor.status === auditConst.status.uncheck && idx === auditHistory.length - 1) { %>is_uncheck<% } %>">
                                     <div class="timeline-item-date">
                                         <%- ctx.helper.formatDate(auditor.end_time) %>
                                     </div>
@@ -352,7 +355,6 @@
                                 <% }) %>
                             </ul>
                         </div>
-
                         <% }) %>
                     </div>
                 </div>