Forráskód Böngészése

变更审批流设置

laiguoran 4 éve
szülő
commit
35ba9c9bb3

+ 7 - 1
app/controller/change_controller.js

@@ -16,6 +16,7 @@ const audit = require('../const/audit');
 const codeRuleConst = require('../const/code_rule');
 const changeConst = require('../const/change');
 const accountGroup = require('../const/account_group').group;
+const shenpiConst = require('../const/shenpi');
 // const tenderMenu = require('../../config/menu').tenderMenu;
 
 module.exports = app => {
@@ -291,18 +292,23 @@ module.exports = app => {
                     tpUnit: ctx.tender.info.decimal.tp,
                     upUnit: ctx.tender.info.decimal.up,
                     authMobile: auth_mobile,
+                    shenpiConst,
                 };
                 // 根据auditStatus状态获取的不同的数据
                 if (auditStatus === 1 || auditStatus === 2) {
                     renderData.changeUnits = changeConst.units;
                     renderData.precision = ctx.tender.info.precision;
-                    renderData.accountGroup = accountGroup;
+                    // renderData.accountGroup = accountGroup;
                     // 获取所有项目参与者
                     const accountList = await ctx.service.projectAccount.getAllDataByCondition({
                         where: { project_id: ctx.session.sessionProject.id, enable: 1 },
                         columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group'],
                     });
                     renderData.accountList = accountList;
+                    renderData.accountGroup = accountGroup.map((item, idx) => {
+                        const groupList = accountList.filter(item => item.account_group === idx);
+                        return { groupName: item, groupList };
+                    });
                     // 重新上报获取审批流程
                     if (auditStatus === 2) {
                         const auditList2 = await ctx.service.changeAudit.getListByBack(change.cid, change.times);

+ 75 - 0
app/middleware/change_audit_check.js

@@ -0,0 +1,75 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Ellisran
+ * @date 2020/10/15
+ * @version
+ */
+
+const status = require('../const/audit').flow.status;
+const shenpiConst = require('../const/shenpi');
+const _ = require('lodash');
+
+module.exports = options => {
+    /**
+     * 标段校验 中间件
+     * 1. 读取标段数据(包括属性)
+     * 2. 检验用户是否可见标段(不校验具体权限)
+     *
+     * @param {function} next - 中间件继续执行的方法
+     * @return {void}
+     */
+    return function* changeAuditCheck(next) {
+        try {
+            // 获取revise
+            const cid = this.params.cid || this.request.body.cid;
+            if (!cid) {
+                throw '您访问的变更令不存在';
+            }
+            const change = yield this.service.change.getDataByCondition({ cid });
+            if (!change) throw '变更令数据有误';
+            if ((change.status === status.uncheck || change.status === status.back) && this.tender.info.shenpi.change !== shenpiConst.sp_status.sqspr) {
+                const shenpi_status = this.tender.info.shenpi.change;
+                // 进一步比较审批流是否与审批流程设置的相同,不同则替换为固定审批流或固定的终审
+                const auditList = yield this.service.changeAudit.getAllDataByCondition({ where: { cid: change.cid, times: change.times } });
+                auditList.shift();
+                const auditIdList = _.map(auditList, 'uid');
+                if (shenpi_status === shenpiConst.sp_status.gdspl) {
+                    const shenpiList = yield this.service.shenpiAudit.getAllDataByCondition({ where: { tid: this.tender.id, sp_type: shenpiConst.sp_type.change, sp_status: shenpi_status } });
+                    const shenpiIdList = _.map(shenpiList, 'audit_id');
+                    // 判断2个id数组是否相同,不同则删除原审批流,切换成固定的审批流
+                    if (!_.isEqual(auditIdList, shenpiIdList)) {
+                        yield this.service.changeAudit.updateNewAuditList(change, shenpiIdList);
+                    }
+                } else if (shenpi_status === shenpiConst.sp_status.gdzs) {
+                    const shenpiInfo = yield this.service.shenpiAudit.getDataByCondition({ tid: this.tender.id, sp_type: shenpiConst.sp_type.change, sp_status: shenpi_status });
+                    // 判断最后一个id是否与固定终审id相同,不同则删除原审批流中如果存在的id和添加终审
+                    if (shenpiInfo && shenpiInfo.audit_id !== _.last(auditIdList)) {
+                        yield this.service.changeAudit.updateLastAudit(change, auditList, shenpiInfo.audit_id);
+                    } else if (!shenpiInfo) {
+                        // 不存在终审人的状态下这里恢复为授权审批人
+                        this.tender.info.shenpi.change = shenpiConst.sp_status.sqspr;
+                    }
+                }
+            }
+            yield next;
+        } catch (err) {
+            console.log(err);
+            // 输出错误到日志
+            if (err.stack) {
+                this.logger.error(err);
+            } else {
+                this.getLogger('fail').info(JSON.stringify({
+                    error: err,
+                    project: this.session.sessionProject,
+                    user: this.session.sessionUser,
+                    body: this.session.body,
+                }));
+            }
+            // 重定向值标段管理
+            this.redirect(this.request.headers.referer);
+        }
+    };
+};

+ 110 - 56
app/public/js/change_set.js

@@ -236,17 +236,72 @@ $(document).ready(() => {
         toastr.success('已还原到上次保存状态');
     });
 
-    // 审批人分组选择
-    $('#account_group').change(function () {
-        let account_html = '<option value="0">选择审批人</option>';
-        for (const account of accountList) {
-            if (parseInt($(this).val()) === 0 || parseInt($(this).val()) === account.account_group) {
-                const role = account.role !== '' ? '(' + account.role + ')' : '';
-                const company = account.company !== '' ? ' -' + account.company : '';
-                account_html += '<option value="' + account.id + '">' + account.name + role + company + '</option>';
+    let timer = null
+    let oldSearchVal = null
+    // 获取审核相关url
+    function getUrlPre () {
+        const path = window.location.pathname.split('/');
+        return _.take(path, 6).join('/');
+    }
+
+    $('#gr-search').bind('input propertychange', function(e) {
+        oldSearchVal = e.target.value
+        timer && clearTimeout(timer)
+        timer = setTimeout(() => {
+            const newVal = $('#gr-search').val()
+            let html = ''
+            if (newVal && newVal === oldSearchVal) {
+                accountList.filter(item => item && cur_uid !== item.id && (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>`
+                })
+                $('.book-list').empty()
+                $('.book-list').append(html)
+            } else {
+                if (!$('.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 => {
+                            if (item.id !== cur_uid) {
+                                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>'
+                    })
+                    $('.book-list').empty()
+                    $('.book-list').append(html)
+                }
             }
+        }, 400);
+    })
+
+    // 添加审批流程按钮逻辑
+    $('.book-list').on('click', 'dt', function () {
+        const idx = $(this).find('.acc-btn').attr('data-groupid')
+        const type = $(this).find('.acc-btn').attr('data-type')
+        if (type === 'hide') {
+            $(this).parent().find(`div[data-toggleid="${idx}"]`).show(() => {
+                $(this).children().find('i').removeClass('fa-plus-square').addClass('fa-minus-square-o')
+                $(this).find('.acc-btn').attr('data-type', 'show')
+
+            })
+        } else {
+            $(this).parent().find(`div[data-toggleid="${idx}"]`).hide(() => {
+                $(this).children().find('i').removeClass('fa-minus-square-o').addClass('fa-plus-square')
+                $(this).find('.acc-btn').attr('data-type', 'hide')
+            })
         }
-        $('#account_list').html(account_html);
+        return false
     });
 
     $('#hideSp').click(function () {
@@ -254,50 +309,56 @@ $(document).ready(() => {
     });
 
     // 添加到审批流程中
-    $('body').on('change', '#account_list', function () {
-        let id = $(this).val();
-        id = parseInt(id);
-        if (id !== 0) {
-            let auditListIdData = [];
+    $('dl').on('click', 'dd', function () {
+        const id = parseInt($(this).data('id'));
+        if (id) {
+            const auditListIdData = [];
             $('#auditList li').each(function () {
-                let aid = $(this).data('auditid');
+                const aid = $(this).data('auditid');
                 auditListIdData.push(aid);
             });
             if (!in_array(auditListIdData, id)) {
-                const accountInfo = accountList.find(function (item) {
-                    return item.id === id;
-                });
-                const user = accountInfo.id + '/%/' + accountInfo.name + '/%/' + accountInfo.role + '/%/' + accountInfo.company;
-                const addhtml = '<li class="list-group-item" data-auditmsg="' + user + '"' +
-                    'data-auditid="' + accountInfo.id + '" >' +
-                    '<a href="javascript:void(0);" class="text-danger pull-right remove_audit_btn">移除</a>' +
-                    '<span>' + (auditListIdData.length+1) + '</span> ' + accountInfo.name + '  <small class="text-muted">' + accountInfo.role + '</small>' +
-                    '<p class="m-0 ml-2"><small class="text-muted">' + accountInfo.company + '</small></p>' +
-                    '</li>';
-                $('#auditList').append(addhtml);
-
-                // 重新上报时。令其它的审批人流程图标转换
-                $('#shenpi-audit-list li i').removeClass('fa-stop-circle').addClass('fa-chevron-circle-down');
-                $('#shenpi-audit-list2 li i').removeClass('fa-stop-circle').addClass('fa-chevron-circle-down');
-                // 添加新审批人
-                const addhtml1 = '<li class="list-group-item" data-auditid="' + accountInfo.id + '" >' +
-                    '<i class="fa fa-stop-circle"></i> ' +
-                    accountInfo.name + ' <small class="text-muted">' + accountInfo.role + '</small><span class="pull-right">终审</span>' +
-                    '</li>';
-                const addhtml2 = '<li class="list-group-item" data-auditid="' + accountInfo.id + '" >' +
-                    '<h5 class="card-title"><i class="fa fa-stop-circle"></i> ' +
-                    accountInfo.name + ' <small class="text-muted">' + accountInfo.role + '</small><span class="pull-right">终审</span>' +
-                    '</h5></li>';
-                for (let i = 0; i < $('#shenpi-audit-list li').length; i++) {
-                    $('#shenpi-audit-list li').eq(i).find('.pull-right').text(transFormToChinese(i) + '审');
-                    $('#shenpi-audit-list2 li').eq(i).find('.pull-right').text(transFormToChinese(i) + '审');
+                if (shenpi_status === shenpiConst.sp_status.gdzs) {
+                    auditListIdData.splice(-1,0,id);
+                } else {
+                    auditListIdData.push(id);
+                }
+                const html = [];
+                const auditorshtml = [];
+                auditListIdData.unshift(changesUid);
+                for (const [index,ids] of auditListIdData.entries()) {
+                    const accountInfo = _.find(accountList, { 'id': ids });
+                    if (index !== 0) {
+                        const user = accountInfo.id + '/%/' + accountInfo.name + '/%/' + accountInfo.role + '/%/' + accountInfo.company;
+                        html.push('<li class="list-group-item" data-auditmsg="' + user + '" data-auditid="'+ ids +'">');
+                        if (shenpi_status === shenpiConst.sp_status.sqspr || (shenpi_status === shenpiConst.sp_status.gdzs && index+1 !== auditListIdData.length)) {
+                            html.push('<a href="javascript:void(0);" class="text-danger pull-right remove_audit_btn">移除</a>');
+                        }
+                        html.push('<span>');
+                        html.push(index + ' ');
+                        html.push('</span> ');
+                        html.push(accountInfo.name + ' ');
+                        html.push('<small class="text-muted">');
+                        html.push(accountInfo.role);
+                        html.push('</small>');
+                        html.push('<p class="m-0 ml-2"><small class="text-muted">' + accountInfo.company + '</small></p>');
+                        html.push('</li>');
+                    }
+                    // 添加新审批人流程修改
+                    auditorshtml.push('<li class="list-group-item" ' + (index !== 0 ? 'data-auditid="' + accountInfo.id + '"' : '') + '>');
+                    auditorshtml.push('<i class="fa ' + (index+1 === auditListIdData.length ? 'fa-stop-circle' : 'fa-chevron-circle-down') + '"></i> ');
+                    auditorshtml.push(accountInfo.name + ' <small class="text-muted">' + accountInfo.role + '</small>');
+                    if (index === 0) {
+                        auditorshtml.push('<span class="pull-right">原报</span>');
+                    } else if (index+1 === auditListIdData.length) {
+                        auditorshtml.push('<span class="pull-right">终审</span>');
+                    } else {
+                        auditorshtml.push('<span class="pull-right">'+ transFormToChinese(index) +'审</span>');
+                    }
+                    auditorshtml.push('</li>');
                 }
-                $('#shenpi-audit-list li').eq(0).find('.pull-right').text('原报');
-                $('#shenpi-audit-list2 li').eq(0).find('.pull-right').text('原报');
-                $('#shenpi-audit-list li i').eq(0).removeClass('fa-chevron-circle-down').addClass('fa-play-circle');
-                $('#shenpi-audit-list2 li i').eq(0).removeClass('fa-chevron-circle-down').addClass('fa-play-circle');
-                $('#shenpi-audit-list').append(addhtml1);
-                $('#shenpi-audit-list2').append(addhtml2);
+                $('#auditList').html(html.join(''));
+                $('#shenpi-audit-list').html(auditorshtml.join(''));
             } else {
                 toastr.error('审批流程中已存在该用户!');
             }
@@ -320,21 +381,14 @@ $(document).ready(() => {
         // 重新上报时。移除审批流程
         // 令最后一个图标转换
         $('#shenpi-audit-list li[data-auditid="' + uid + '"]').remove();
-        $('#shenpi-audit-list2 li[data-auditid="' + uid + '"]').remove();
         if ($('#shenpi-audit-list li').length !== 0 && !$('#shenpi-audit-list li i').hasClass('fa-stop-circle')) {
             $('#shenpi-audit-list li').eq($('#shenpi-audit-list li').length-1).children('i')
                 .removeClass('fa-chevron-circle-down').addClass('fa-stop-circle');
-            $('#shenpi-audit-list2 li').eq($('#shenpi-audit-list2 li').length-1).children('i')
-                .removeClass('fa-chevron-circle-down').addClass('fa-stop-circle');
         }
         for (let i = 0; i < $('#shenpi-audit-list li').length; i++) {
-            $('#shenpi-audit-list li').eq(i).find('.pull-right').text((i+1 === $('#shenpi-audit-list li').length ? '终' : transFormToChinese(i+1)) + '审');
-            $('#shenpi-audit-list2 li').eq(i).find('.pull-right').text((i+1 === $('#shenpi-audit-list2 li').length ? '终' : transFormToChinese(i+1)) + '审');
+            $('#shenpi-audit-list li').eq(i).find('.pull-right').text(i === 0 ? '原报' : (i+1 === $('#shenpi-audit-list li').length ? '终' : transFormToChinese(i)) + '审');
         }
-        $('#shenpi-audit-list li').eq(0).find('.pull-right').text('原报');
-        $('#shenpi-audit-list2 li').eq(0).find('.pull-right').text('原报');
         $('#shenpi-audit-list li i').eq(0).removeClass('fa-chevron-circle-down').addClass('fa-play-circle');
-        $('#shenpi-audit-list2 li i').eq(0).removeClass('fa-chevron-circle-down').addClass('fa-play-circle');
     });
 
     // 打开签约清单modal并删除之前的操作

+ 3 - 2
app/router.js

@@ -11,6 +11,7 @@ module.exports = app => {
     const tenderCheck = app.middlewares.tenderCheck();
     const ledgerAuditCheck = app.middlewares.ledgerAuditCheck();
     const reviseAuditCheck = app.middlewares.reviseAuditCheck();
+    const changeAuditCheck = app.middlewares.changeAuditCheck();
     const uncheckTenderCheck = app.middlewares.uncheckTenderCheck();
     // 期读取中间件
     const stageCheck = app.middlewares.stageCheck();
@@ -305,7 +306,7 @@ module.exports = app => {
     app.post('/tender/:id/change/newCode', sessionAuth, tenderCheck, uncheckTenderCheck, 'changeController.newCode');
     app.post('/tender/:id/change/add', sessionAuth, tenderCheck, uncheckTenderCheck, 'changeController.add');
     app.post('/tender/:id/change/defaultBills', sessionAuth, tenderCheck, uncheckTenderCheck, 'changeController.defaultBills');
-    app.get('/tender/:id/change/:cid/info', sessionAuth, tenderCheck, uncheckTenderCheck, 'changeController.info');
+    app.get('/tender/:id/change/:cid/info', sessionAuth, tenderCheck, uncheckTenderCheck, changeAuditCheck, 'changeController.info');
     app.post('/tender/:id/change/:cid/info/file/upload', sessionAuth, 'changeController.uploadFile');
     app.get('/change/download/file/:id', sessionAuth, 'changeController.downloadFile');
     app.post('/change/download/file/:id', sessionAuth, 'changeController.checkFile');
@@ -314,7 +315,7 @@ module.exports = app => {
     app.post('/tender/:id/change/delete', sessionAuth, tenderCheck, uncheckTenderCheck, 'changeController.delete');
     app.post('/tender/:id/change/bills', sessionAuth, tenderCheck, uncheckTenderCheck, 'changeController.bills');
 
-    app.post('/tender/:id/change/save', sessionAuth, tenderCheck, uncheckTenderCheck, 'changeController.save');
+    app.post('/tender/:id/change/save', sessionAuth, tenderCheck, uncheckTenderCheck, changeAuditCheck, 'changeController.save');
 
     app.post('/tender/:id/change/approval', sessionAuth, tenderCheck, uncheckTenderCheck, 'changeController.approval');
     app.post('/tender/:id/change/check/again', sessionAuth, tenderCheck, uncheckTenderCheck, 'changeController.checkAgain');

+ 2 - 2
app/service/advance_audit.js

@@ -515,7 +515,7 @@ module.exports = app => {
             const transaction = await this.db.beginTransaction();
             try {
                 // 先删除旧的审批流,再添加新的
-                transaction.delete(this.tableName, { vid: advance.id, times: advance.times });
+                await transaction.delete(this.tableName, { vid: advance.id, times: advance.times });
                 const newAuditors = [];
                 let order = 1;
                 for (const aid of newIdList) {
@@ -540,7 +540,7 @@ module.exports = app => {
                 const idList = this._.map(auditList, 'audit_id');
                 let order = idList.length + 1;
                 if (idList.indexOf(lastId) !== -1) {
-                    transaction.delete(this.tableName, { vid: advance.id, times: advance.times, audit_id: lastId });
+                    await transaction.delete(this.tableName, { vid: advance.id, times: advance.times, audit_id: lastId });
                     const audit = this._.find(auditList, { 'audit_id': lastId });
                     // 顺移之后审核人流程顺序
                     await this._syncOrderByDelete(transaction, advance.id, audit.order, advance.times);

+ 100 - 0
app/service/change_audit.js

@@ -355,6 +355,106 @@ module.exports = app => {
             }
             return await this.db.query(sql, sqlParam);
         }
+
+        async updateNewAuditList(change, newIdList) {
+            const transaction = await this.db.beginTransaction();
+            try {
+                // 先删除旧的审批流(除了原报),再添加新的
+                const sql = 'DELETE FROM ?? WHERE `cid`= ? AND `times` = ? AND `usite` != 0';
+                const sqlParam = [this.tableName, change.cid, change.times];
+                await transaction.query(sql, sqlParam);
+
+                const newAuditors = [];
+                let order = 1;
+                let uSort = await transaction.count(this.tableName, { cid: change.cid });
+                for (const aid of newIdList) {
+                    const accountInfo = await this.ctx.service.projectAccount.getDataById(aid);
+                    newAuditors.push({
+                        tid: change.tid, cid: change.cid, uid: aid,
+                        name: accountInfo.name, jobs: accountInfo.role, company: accountInfo.company,
+                        times: change.times, usite: order, usort: uSort, status: audit.flow.auditStatus.uncheck,
+                    });
+                    order++;
+                    uSort++;
+                }
+                await transaction.insert(this.tableName, newAuditors);
+                await transaction.commit();
+            } catch (err) {
+                await transaction.rollback();
+                throw err;
+            }
+        }
+
+        async updateLastAudit(change, auditList, lastId) {
+            const transaction = await this.db.beginTransaction();
+            try {
+                // 先判断auditList里的aid是否与lastId相同,相同则删除并重新更新order
+                const idList = this._.map(auditList, 'uid');
+                let order = idList.length + 1;
+                if (idList.indexOf(lastId) !== -1) {
+                    const sql = 'DELETE FROM ?? WHERE `cid`= ? AND `times` = ? AND `uid` = ? AND `usite` != 0';
+                    const sqlParam = [this.tableName, change.cid, change.times, lastId];
+                    await transaction.query(sql, sqlParam);
+                    // await transaction.delete(this.tableName, { cid: change.cid, times: change.times, uid: lastId, usite: 0 });
+                    const user = this._.find(auditList, { 'uid': lastId });
+                    // 顺移之后审核人流程顺序
+                    await this._syncOrderByDelete(transaction, change.cid, user.usite, user.usort, change.times);
+                    order = order - 1;
+                }
+
+                // 添加终审
+                const userInfo = await this.ctx.service.projectAccount.getDataById(lastId);
+                let uSort = await transaction.count(this.tableName, { cid: change.cid });
+                const newAuditor = {
+                    tid: change.tid, cid: change.cid, uid: lastId,
+                    name: userInfo.name, jobs: userInfo.role, company: userInfo.company,
+                    times: change.times, usite: order, usort: uSort, status: audit.flow.auditStatus.uncheck,
+                };
+                await transaction.insert(this.tableName, newAuditor);
+                await transaction.commit();
+            } catch (err) {
+                await transaction.rollback();
+                throw err;
+            }
+        }
+        /**
+         * 移除审核人时,同步其后审核人order
+         * @param transaction - 事务
+         * @param {Number} changeId - 变更令id
+         * @param {Number} usite - 审核人id
+         * @param {Number} usort - 审核人id
+         * @param {Number} times - 第几次审批
+         * @return {Promise<*>}
+         * @private
+         */
+        async _syncOrderByDelete(transaction, changeId, usite, usort, times, selfOperate = '-') {
+            this.initSqlBuilder();
+            this.sqlBuilder.setAndWhere('cid', {
+                value: this.db.escape(changeId),
+                operate: '=',
+            });
+            this.sqlBuilder.setAndWhere('usite', {
+                value: usite,
+                operate: '>=',
+            });
+            this.sqlBuilder.setAndWhere('times', {
+                value: times,
+                operate: '=',
+            });
+            this.sqlBuilder.setUpdateData('usite', {
+                value: 1,
+                selfOperate: selfOperate,
+            });
+            this.sqlBuilder.setUpdateData('usort', {
+                value: 1,
+                selfOperate: selfOperate,
+            });
+            const [sql, sqlParam] = this.sqlBuilder.build(this.tableName, 'update');
+            const data = await transaction.query(sql, sqlParam);
+
+            return data;
+        }
+
     }
 
     return ChangeAudit;

+ 2 - 2
app/service/ledger_audit.js

@@ -532,7 +532,7 @@ module.exports = app => {
             const transaction = await this.db.beginTransaction();
             try {
                 // 先删除旧的审批流,再添加新的
-                transaction.delete(this.tableName, { tender_id: tender.id, times: tender.ledger_times });
+                await transaction.delete(this.tableName, { tender_id: tender.id, times: tender.ledger_times });
                 const newAuditors = [];
                 let order = 1;
                 for (const aid of newIdList) {
@@ -557,7 +557,7 @@ module.exports = app => {
                 const idList = this._.map(auditList, 'audit_id');
                 let order = idList.length + 1;
                 if (idList.indexOf(lastId) !== -1) {
-                    transaction.delete(this.tableName, { tender_id: tender.id, times: tender.ledger_times, audit_id: lastId });
+                    await transaction.delete(this.tableName, { tender_id: tender.id, times: tender.ledger_times, audit_id: lastId });
                     const audit = this._.find(auditList, { 'audit_id': lastId });
                     // 顺移之后审核人流程顺序
                     await this._syncOrderByDelete(transaction, tender.id, audit.audit_order, tender.ledger_times);

+ 2 - 2
app/service/material_audit.js

@@ -868,7 +868,7 @@ module.exports = app => {
             const transaction = await this.db.beginTransaction();
             try {
                 // 先删除旧的审批流,再添加新的
-                transaction.delete(this.tableName, { mid: material.id, times: material.times });
+                await transaction.delete(this.tableName, { mid: material.id, times: material.times });
                 const newAuditors = [];
                 let order = 1;
                 for (const aid of newIdList) {
@@ -893,7 +893,7 @@ module.exports = app => {
                 const idList = this._.map(auditList, 'aid');
                 let order = idList.length + 1;
                 if (idList.indexOf(lastId) !== -1) {
-                    transaction.delete(this.tableName, { mid: material.id, times: material.times, aid: lastId });
+                    await transaction.delete(this.tableName, { mid: material.id, times: material.times, aid: lastId });
                     const audit = this._.find(auditList, { 'aid': lastId });
                     // 顺移之后审核人流程顺序
                     await this._syncOrderByDelete(transaction, material.id, audit.order, material.times);

+ 2 - 2
app/service/revise_audit.js

@@ -706,7 +706,7 @@ module.exports = app => {
             const transaction = await this.db.beginTransaction();
             try {
                 // 先删除旧的审批流,再添加新的
-                transaction.delete(this.tableName, { rid: revise.id, times: revise.times });
+                await transaction.delete(this.tableName, { rid: revise.id, times: revise.times });
                 const newAuditors = [];
                 let order = 1;
                 for (const aid of newIdList) {
@@ -732,7 +732,7 @@ module.exports = app => {
                 const idList = this._.map(auditList, 'audit_id');
                 let order = idList.length + 1;
                 if (idList.indexOf(lastId) !== -1) {
-                    transaction.delete(this.tableName, { rid: revise.id, times: revise.times, audit_id: lastId });
+                    await transaction.delete(this.tableName, { rid: revise.id, times: revise.times, audit_id: lastId });
                     const audit = this._.find(auditList, { 'audit_id': lastId });
                     // 顺移之后审核人流程顺序
                     await this._syncOrderByDelete(transaction, revise.id, audit.audit_order, revise.times);

+ 2 - 2
app/service/stage_audit.js

@@ -1260,7 +1260,7 @@ module.exports = app => {
             const transaction = await this.db.beginTransaction();
             try {
                 // 先删除旧的审批流,再添加新的
-                transaction.delete(this.tableName, { sid: stage.id, times: stage.times });
+                await transaction.delete(this.tableName, { sid: stage.id, times: stage.times });
                 const newAuditors = [];
                 let order = 1;
                 for (const aid of newIdList) {
@@ -1286,7 +1286,7 @@ module.exports = app => {
                 const idList = this._.map(auditList, 'aid');
                 let order = idList.length + 1;
                 if (idList.indexOf(lastId) !== -1) {
-                    transaction.delete(this.tableName, { sid: stage.id, times: stage.times, aid: lastId });
+                    await transaction.delete(this.tableName, { sid: stage.id, times: stage.times, aid: lastId });
                     const audit = this._.find(auditList, { 'aid': lastId });
                     // 顺移之后审核人流程顺序
                     await this._syncOrderByDelete(transaction, stage.id, audit.order, stage.times);

+ 4 - 0
app/view/change/info.ejs

@@ -767,7 +767,11 @@
 <script>
     const changeUnits = JSON.parse('<%- JSON.stringify(changeUnits) %>');
     const precision = JSON.parse('<%- JSON.stringify(precision) %>');
+    const accountGroup = JSON.parse('<%- JSON.stringify(accountGroup) %>');
     const accountList = JSON.parse('<%- JSON.stringify(accountList) %>');
+    const shenpi_status = <%- ctx.tender.info.shenpi.change %>;
+    const shenpiConst =  JSON.parse('<%- JSON.stringify(shenpiConst) %>');
+    const changesUid =  <%- change.uid %>;
     const billsTable = {
         columnDefs: [
             { className: 'allwidth1', width: 100, targets: 0 },

+ 31 - 44
app/view/change/info_modal.ejs

@@ -41,26 +41,33 @@
             </div>
             <form method="post" action="/tender/<%- tender.id %>/change/<%- change.cid %>/save">
                 <div class="modal-body">
-                    <div class="form-group">
-                        <label>选择审批人</label>
-                        <div class="input-group">
-                            <div class="input-group-prepend">
-                                <select class="form-control form-control-sm" id="account_group">
-                                    <option value="0">所有分组</option>
-                                    <% for (const dw in accountGroup) { %>
-                                        <option value="<%= dw %>"><%= accountGroup[dw] %></option>
-                                    <% } %>
-                                </select>
+                    <div class="dropdown text-right">
+                        <% if (ctx.tender.info.shenpi.change !== shenpiConst.sp_status.gdspl) { %>
+                            <button class="btn btn-outline-primary btn-sm dropdown-toggle" type="button"
+                                    id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true"
+                                    aria-expanded="false">
+                                添加审批流程
+                            </button>
+                            <div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton"
+                                 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">
+                                    <% 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 => { %>
+                                                <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>
-                            <select class="form-control form-control-sm" id="account_list">
-                                <option value="0">选择审批人</option>
-                                <% for (const account of accountList) { %>
-                                    <option value="<%= account.id %>"><%= account.name %><% if (account.role !== '') { %>(<%= account.role %>)<% } %><% if (account.company !== '') { %> -<%= account.company %><% } %></option>
-                                <% } %>
-                            </select>
-                        </div>
-                    </div>
-                    <div id="search_audit_list">
+                        <% } %>
                     </div>
                     <div class="card mt-3">
                         <div class="card-header">
@@ -72,7 +79,10 @@
                                 <% if (audit.usite !== 0) { %>
                                 <li class="list-group-item" data-auditmsg="<%= audit.uid + '/%/' + audit.name + '/%/' + audit.jobs + '/%/' + audit.company %>"
                                     data-auditid="<%= audit.uid %>">
+                                    <% if (ctx.tender.info.shenpi.change === shenpiConst.sp_status.sqspr ||
+                                            (ctx.tender.info.shenpi.change === shenpiConst.sp_status.gdzs && index+1 !== auditList.length)) { %>
                                     <a href="javascript:void(0)" class="text-danger pull-right remove_audit_btn">移除</a>
+                                    <% } %>
                                     <span><%= index %></span> <%= audit.name %>  <small class="text-muted"><%= audit.jobs %></small>
                                     <p class="m-0 ml-2"><small class="text-muted"><%= audit.company %></small></p>
                                 </li>
@@ -84,7 +94,9 @@
                     </div>
                 </div>
                 <div class="modal-footer">
+                    <% if (ctx.tender.info.shenpi.change !== shenpiConst.sp_status.gdspl) { %>
                     <button type="button" class="btn btn-success btn-sm save_change_btn">保存审批流程</button>
+                    <% } %>
                     <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">关闭</button>
                     <button type="button" data-sumbit="sumbit_change" data-category="up_change" class="btn btn-primary btn-sm up-change">确认上报</button>
                     <!--<button type="button" data-sumbit="sumbit_change" data-category="save_change" class="btn btn-success btn-sm save-change">保存修改</button>-->
@@ -232,31 +244,6 @@
                                 </div>
                             <% } %>
                             <% } %>
-                                <div class="card mt-3">
-                                    <ul class="list-group list-group-flush" id="shenpi-audit-list2">
-                                        <% for (const [index, audit] of auditList.entries()) { %>
-                                            <% if (audit.usite === 0) { %>
-                                            <li class="list-group-item">
-                                                <h5 class="card-title">
-                                                    <i class="fa fa-play-circle fa-rotate-90"></i>
-                                                    <%= audit.name %>  <small class="text-muted"><%= audit.jobs %></small><span class="pull-right">原报</span>
-                                                </h5>
-                                            </li>
-                                            <% } else { %>
-                                            <li class="list-group-item" data-auditid="<%= audit.uid %>">
-                                                <h5 class="card-title">
-                                                    <% if (index+1 !== auditList.length) { %>
-                                                        <i class="fa fa-chevron-circle-down"></i>
-                                                    <% } else if (index+1 === auditList.length) { %>
-                                                        <i class="fa fa-stop-circle"></i>
-                                                    <% } %>
-                                                    <%= audit.name %>  <small class="text-muted"><%= audit.jobs %></small><span class="pull-right"><%= index+1 === auditList.length ? '终' : ctx.helper.transFormToChinese(index) %>审</span>
-                                                </h5>
-                                            </li>
-                                            <% } %>
-                                        <% } %>
-                                    </ul>
-                                </div>
                         </div>
                     </div>
                 </div>