Browse Source

feat: 台账修订审核弹窗改版

lanjianrong 5 years ago
parent
commit
e3ec2b87c9

+ 60 - 52
app/controller/revise_controller.js

@@ -37,7 +37,7 @@ module.exports = app => {
         /**
          * 是否可以新增修订
          * @param ctx
-         * @returns {Promise<boolean>}
+         * @return {Promise<boolean>}
          * @private
          */
         async _getAddReviseValid(ctx) {
@@ -58,7 +58,7 @@ module.exports = app => {
         async index(ctx) {
             try {
                 // 分页相关
-                const count = await ctx.service.ledgerRevise.count({tid: ctx.tender.id});
+                const count = await ctx.service.ledgerRevise.count({ tid: ctx.tender.id });
                 const ledgerRevise = await ctx.service.ledgerRevise.getReviseList(ctx.tender.id);
                 if (ledgerRevise.length > 0) {
                     const revise = ledgerRevise[0];
@@ -85,7 +85,7 @@ module.exports = app => {
                     preUrl: '/tender/' + ctx.tender.id,
                     pageInfo: {
                         page: ctx.page,
-                        total: Math.ceil(count/app.config.pageSize),
+                        total: Math.ceil(count / app.config.pageSize),
                         queryData: JSON.stringify(ctx.urlInfo.query),
                     },
                     ledgerRevise,
@@ -105,7 +105,7 @@ module.exports = app => {
         /**
          * 修订审批流程(Get)
          * @param ctx
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async reviseAuditors(ctx) {
             try {
@@ -124,7 +124,7 @@ module.exports = app => {
                 }
                 responseData.data.auditHistory = auditHistory;
                 // 获取审批流程中左边列表
-                responseData.data.auditors = await ctx.service.reviseAudit.getAuditGroupByList(reviseInfo.id, times);
+                responseData.data.auditors = await ctx.service.reviseAudit.getAuditorsWithOwner(reviseInfo.id, times);
                 // 获取原报信息
                 const reviseAuditor = await ctx.service.projectAccount.getAccountInfoById(reviseInfo.uid);
                 responseData.data.reviseAuditor = reviseAuditor;
@@ -138,7 +138,7 @@ module.exports = app => {
         /**
          * 新增 修订 (Post)
          * @param ctx
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async add(ctx) {
             try {
@@ -149,7 +149,7 @@ module.exports = app => {
                 const revise = await ctx.service.ledgerRevise.add(ctx.tender.id, ctx.session.sessionUser.accountId);
 
                 ctx.redirect('/tender/' + ctx.tender.id + '/revise/info');
-            } catch(err) {
+            } catch (err) {
                 this.log(err);
                 ctx.redirect(ctx.request.header.referer);
             }
@@ -158,7 +158,7 @@ module.exports = app => {
         /**
          * 作废 修订 (Post)
          * @param ctx
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async cancel(ctx) {
             try {
@@ -176,7 +176,7 @@ module.exports = app => {
                 }
 
                 ctx.redirect('/tender/' + ctx.tender.id + '/revise/');
-            } catch(err) {
+            } catch (err) {
                 this.log(err);
                 ctx.redirect(ctx.request.header.referer);
             }
@@ -185,7 +185,7 @@ module.exports = app => {
         /**
          * 保存 修订详情 (Ajax-post)
          * @param ctx
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async save(ctx) {
             try {
@@ -203,14 +203,14 @@ module.exports = app => {
                 }
                 const data = JSON.parse(ctx.request.body.data);
                 if (data.content === undefined) {
-                    throw '保存数据有误'
+                    throw '保存数据有误';
                 }
-                const result = await ctx.service.ledgerRevise.defaultUpdate({id: revise.id, content: data.content});
+                const result = await ctx.service.ledgerRevise.defaultUpdate({ id: revise.id, content: data.content });
                 if (result.affectedRows !== 1) {
                     throw '保存数据失败,请重试';
                 }
-                ctx.body = {err: 0, msg: '', data: null};
-            } catch(err) {
+                ctx.body = { err: 0, msg: '', data: null };
+            } catch (err) {
                 this.log(err);
                 ctx.body = this.ajaxErrorBody(err, '保存数据失败,请重试');
             }
@@ -259,22 +259,24 @@ module.exports = app => {
             const [stdBills, stdChapters] = await this.ctx.service.valuation.getValuationStdList(
                 ctx.tender.data.valuation, ctx.tender.data.measure_type);
             const curAuditor = await ctx.service.reviseAudit.getCurAuditor(revise.id, revise.times);
-            const auditors = await ctx.service.reviseAudit.getAuditors(revise.id, revise.times);
+            const auditors = await ctx.service.reviseAudit.getAuditorsWithOwner(revise.id, revise.times);
             const user = await ctx.service.projectAccount.getAccountInfoById(revise.uid);
+            const times = revise.status === audit.revise.status.checkNo ? revise.times - 1 : revise.times;
             const auditHistory = [];
-            if (revise.times > 1) {
-                for (let i = 1; i < revise.times; i++) {
+            if (times >= 1) {
+                for (let i = 1; i <= times; i++) {
                     auditHistory.push(await ctx.service.reviseAudit.getAuditors(revise.id, i));
                 }
             }
             return {
-                revise: revise, tender: ctx.tender.data,
-                //reviseBills, revisePos,
+                revise, tender: ctx.tender.data,
+                // reviseBills, revisePos,
                 ledgerSpread, posSpread, tenderMenu, measureType,
                 preUrl: '/tender/' + ctx.tender.id,
                 audit: audit.revise,
                 jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.revise.info),
                 stdBills,
+                auditConst: audit.revise,
                 stdChapters,
                 curAuditor,
                 auditors,
@@ -287,7 +289,7 @@ module.exports = app => {
          * 历史修订页面(修订完成后,用于查看)
          * @param ctx
          * @param revise
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          * @private
          */
         async _getHistoryReviseInfo(ctx, revise) {
@@ -304,7 +306,7 @@ module.exports = app => {
          * 修订页面(草稿,审批中)
          * @param ctx
          * @param revise
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          * @private
          */
         async _getAuditReviseInfo(ctx, revise) {
@@ -350,10 +352,14 @@ module.exports = app => {
             renderData.history = false;
             renderData.historyRevise = [];
             // 添加审批人相关
-            renderData.accountGroup = accountGroup;
+            // renderData.accountGroup = accountGroup;
             renderData.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'],
+                columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
+            });
+            renderData.accountGroup = accountGroup.map((item, idx) => {
+                const groupList = renderData.accountList.filter(item => item.account_group === idx);
+                return { groupName: item, groupList };
             });
             renderData.auditorList = await ctx.service.reviseAudit.getAuditors(revise.id, revise.times);
             renderData.curAuditor = await ctx.service.reviseAudit.getCurAuditor(revise.id, revise.times);
@@ -363,7 +369,7 @@ module.exports = app => {
         /**
          * 修订 详细页面(Get)
          * @param ctx
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async info(ctx) {
             try {
@@ -430,8 +436,8 @@ module.exports = app => {
                         }
                     }
                 }
-                ctx.body = {err: 0, msg: '', data: {bills: reviseBills, pos: revisePos}};
-            } catch(err) {
+                ctx.body = { err: 0, msg: '', data: { bills: reviseBills, pos: revisePos } };
+            } catch (err) {
                 ctx.helper.log(err);
                 this.ajaxErrorBody(err, '加载台账修订数据错误');
             }
@@ -454,7 +460,7 @@ module.exports = app => {
 
                 const data = ctx.helper.checkBillsWithPos(reviseBills, revisePos,
                     ['sgfh_qty', 'qtcl_qty', 'sjcl_qty', 'quantity']);
-                ctx.body = { err: 0, msg: '', data: data };
+                ctx.body = { err: 0, msg: '', data };
             } catch (err) {
                 this.log(err);
                 ctx.body = this.ajaxErrorBody(err, '检查数据错误');
@@ -466,8 +472,8 @@ module.exports = app => {
                 const revise = await ctx.service.ledgerRevise.getLastestRevise(ctx.tender.id, false);
                 if (!revise) throw '台账修订数据有误';
 
-                //const reviseBills = await ctx.service.ledger.getData(ctx.tender.id);
-                //const revisePos = await ctx.service.pos.getPosData({tid: ctx.tender.id});
+                // const reviseBills = await ctx.service.ledger.getData(ctx.tender.id);
+                // const revisePos = await ctx.service.pos.getPosData({tid: ctx.tender.id});
                 const [ledgerSpread, posSpread] = this._getSpreadSetting(revise);
                 ledgerSpread.readOnly = true;
                 posSpread.readOnly = true;
@@ -475,7 +481,7 @@ module.exports = app => {
                 const renderData = {
                     measureType, audit, revise,
                     ledgerSpread, posSpread,
-                    //reviseBills, revisePos,
+                    // reviseBills, revisePos,
                     readOnly: true,
                     historyRevise,
                     jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.revise.history),
@@ -494,7 +500,7 @@ module.exports = app => {
                 const reviseInfo = await ctx.service.ledgerRevise.getRevise(ctx.tender.id, data.rid);
                 reviseInfo.end_time_str = reviseInfo.end_time ? reviseInfo.end_time.toLocaleString() : '';
                 ctx.body = { err: 0, msg: '', data: reviseInfo };
-            } catch(err) {
+            } catch (err) {
                 this.log(err);
                 ctx.body = this.ajaxErrorBody(err, '获取台账修订历史数据错误');
             }
@@ -510,8 +516,8 @@ module.exports = app => {
                 if (!revise) throw '台账修订数据有误';
 
                 const reviseBills = await ctx.service.ledger.getData(ctx.tender.id);
-                const revisePos = await ctx.service.pos.getPosData({tid: ctx.tender.id});
-                ctx.body = {err: 0, msg: '', data: {bills: reviseBills, pos: revisePos}};
+                const revisePos = await ctx.service.pos.getPosData({ tid: ctx.tender.id });
+                ctx.body = { err: 0, msg: '', data: { bills: reviseBills, pos: revisePos } };
             } catch (error) {
                 ctx.helper.log(error);
                 this.ajaxErrorBody(error, '获取台账修订数据错误,请刷新页面');
@@ -567,13 +573,14 @@ module.exports = app => {
             if ((isNaN(data.id) || data.id <= 0) ||
                 (!data.tid && data.tid <= 0) ||
                 (!data.block || data.block.length <= 0)) throw '参数错误';
-            return await this.ctx.service.reviseBills.pasteBlockData(this.ctx.tender.id, data.id, data.block, {crid: revise.id});
+            return await this.ctx.service.reviseBills.pasteBlockData(this.ctx.tender.id, data.id, data.block, { crid: revise.id });
         }
         async _addStd(revise, data) {
             if ((isNaN(data.id) || data.id <= 0) || !data.stdType || !data.stdNode) throw '参数错误';
             // todo 校验项目是否使用该库的权限
 
-            let stdLib, addType;
+            let stdLib,
+                addType;
             switch (data.stdType) {
                 case 'xmj':
                     stdLib = this.ctx.service.stdXmj;
@@ -594,7 +601,6 @@ module.exports = app => {
             const stdData = await stdLib.getDataByDataId(data.stdLibId, data.stdNode);
             switch (addType) {
                 case stdDataAddType.child:
-                    return await this.ctx.service.reviseBills.addStdNodeAsChild(revise.tid, data.id, stdData, revise.id);
                     break;
                 case stdDataAddType.next:
                     return await this.ctx.service.reviseBills.addStdNode(revise.tid, data.id, stdData, revise.id);
@@ -611,9 +617,9 @@ module.exports = app => {
                 return await this.ctx.service.reviseBills.addChild(revise.tid, data.id, data.dealBills, revise.id);
             } else if (data.type === 'next') {
                 return await this.ctx.service.reviseBills.addBillsNode(revise.tid, data.id, data.dealBills, revise.id);
-            } else {
-                throw '数据错误';
             }
+            throw '数据错误';
+
         }
         async _addBg(revise, data) {
             if (!data.type || !data.bgBills) throw '数据错误';
@@ -622,9 +628,9 @@ module.exports = app => {
                 return await this.ctx.service.reviseBills.addChild(revise.tid, data.id, data.bgBills, revise.id);
             } else if (data.type === 'next') {
                 return await this.ctx.service.reviseBills.addBillsNode(revise.tid, data.id, data.bgBills, revise.id);
-            } else {
-                throw '数据错误';
             }
+            throw '数据错误';
+
         }
         async _updatePos(revise, data) {
             await this.checkMeasureType(measureType.tz.value);
@@ -635,9 +641,9 @@ module.exports = app => {
                 case 'update':
                     if (data.postData instanceof Array) {
                         return await this.ctx.service.revisePos.updatePosArr(revise.tid, data.postData);
-                    } else {
-                        return await this.ctx.service.revisePos.updatePos(revise.tid, data.postData);
                     }
+                    return await this.ctx.service.revisePos.updatePos(revise.tid, data.postData);
+
                 case 'delete':
                     return await this.ctx.service.revisePos.deletePos(revise.tid, data.postData);
                 case 'paste':
@@ -651,7 +657,7 @@ module.exports = app => {
                 if (!ctx.tender.data) throw '标段数据错误';
                 const data = JSON.parse(ctx.request.body.data);
                 if (!data.postType || !data.postData) throw '数据错误';
-                const responseData = {err: 0, msg: '', data: {}};
+                const responseData = { err: 0, msg: '', data: {} };
 
                 const revise = await this.checkRevise(ctx);
 
@@ -707,10 +713,10 @@ module.exports = app => {
                 const ueType = ctx.params.ueType;
                 const compressData = ctx.request.body.data;
                 const data = JSON.parse(LzString.decompressFromUTF16(compressData));
-                const responseData = { err: 0, msg: '', data: {}, };
+                const responseData = { err: 0, msg: '', data: {} };
                 switch (ueType) {
                     case 'gcl2xmj':
-                        responseData.data = await ctx.service.reviseBills.importGclExcel(data.id, data.sheet, {crid: revise.id});
+                        responseData.data = await ctx.service.reviseBills.importGclExcel(data.id, data.sheet, { crid: revise.id });
                         break;
                 }
                 ctx.body = responseData;
@@ -725,7 +731,7 @@ module.exports = app => {
          * 填设计量(Ajax)
          *
          * @param ctx
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async deal2sgfh(ctx) {
             try {
@@ -734,7 +740,7 @@ module.exports = app => {
 
                 await this.ctx.service.revise.deal2sgfh(ctx.tender.id);
                 const ledgerData = await ctx.service.revise.getData(ctx.tender.id);
-                ctx.body = {err: 0, msg: '', data: {bills: ledgerData}};
+                ctx.body = { err: 0, msg: '', data: { bills: ledgerData } };
             } catch (err) {
                 this.log(err);
                 ctx.body = { err: 1, msg: err.toString(), data: null };
@@ -769,7 +775,7 @@ module.exports = app => {
                 if (!result) throw '添加审核人失败';
 
                 const resultData = await ctx.service.reviseAudit.getAuditor(revise.id, id, revise.times);
-                ctx.body = {err: 0, msg: '', data: resultData};
+                ctx.body = { err: 0, msg: '', data: resultData };
             } catch (err) {
                 this.log(err, '数据错误');
                 ctx.body = this.ajaxErrorBody(err);
@@ -797,7 +803,7 @@ module.exports = app => {
                 }
 
                 const resultData = await ctx.service.reviseAudit.getAuditors(revise.id, revise.times);
-                ctx.body = {err: 0, msg: '', data: resultData};
+                ctx.body = { err: 0, msg: '', data: resultData };
             } catch (err) {
                 this.log(err, '数据错误');
                 ctx.body = this.ajaxErrorBody(err);
@@ -821,11 +827,13 @@ module.exports = app => {
                 if (revise.uid !== ctx.session.sessionUser.accountId) throw '上报失败';
 
                 await ctx.service.reviseAudit.start(revise, revise.times);
-
-                ctx.body = {err: 0, msg: '', data: {}};
+                ctx.redirect('/tender/' + ctx.tender.id + '/revise/info');
+                // ctx.body = { err: 0, msg: '', data: {} };
             } catch (err) {
                 this.log(err);
-                ctx.body = this.ajaxErrorBody(err, '上报失败');
+                // ctx.body = this.ajaxErrorBody(err, '上报失败');
+                this.postError(err, '审批失败');
+                ctx.redirect('/tender/' + ctx.tender.id + '/revise/info');
             }
         }
         /**

+ 2 - 19
app/public/js/material_audit.js

@@ -57,22 +57,6 @@ $(document).ready(function () {
             }
         }, 400);
     })
-    // 添加审批人
-    $('dl').on('click', 'dd', function() {
-        const id = parseInt($(this).data('id'))
-        postData(getUrlPre() + '/audit/add', { auditorId: id }, (data) => {
-            const html = [];
-            html.push('<li class="list-group-item" auditorId="'+ data.aid +'"><a href="javascript: void(0)" class="text-danger pull-right">移除</a>');
-            html.push('<span>');
-            html.push(data.order + ' ');
-            html.push(data.name + ' ');
-            html.push('</span>');
-            html.push('<small class="text-muted">');
-            html.push(data.role);
-            html.push('</small></li>');
-            $('#auditors').append(html.join(''));
-        });
-    });
 
     // 添加审批流程按钮逻辑
     $('.book-list').on('click', '.acc-btn', function () {
@@ -95,9 +79,8 @@ $(document).ready(function () {
 
     // 添加到审批流程中
     $('dl').on('click', 'dd', function () {
-        let id = $(this).val();
-        id = parseInt(id);
-        if (id !== 0) {
+        const id = parseInt($(this).data('id'))
+        if (id) {
             postData(getUrlPre() + '/audit/add', { auditorId: id }, (data) => {
                 const html = [];
                 html.push('<li class="list-group-item" auditorId="'+ data.aid +'"><a href="javascript: void(0)" class="text-danger pull-right">移除</a>');

+ 76 - 51
app/service/revise_audit.js

@@ -1,4 +1,4 @@
-'use strict'
+'use strict';
 
 /**
  *
@@ -33,7 +33,7 @@ module.exports = app => {
          * @param {Number} reviseId - 修订id
          * @param {Number} auditorId - 审核人id
          * @param {Number} times - 第几次审批
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async getAuditor(reviseId, auditorId, times = 1) {
             const sql =
@@ -50,7 +50,7 @@ module.exports = app => {
          *
          * @param {Number} reviseId - 修订id
          * @param {Number} times - 第几次审批
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async getAuditors(reviseId, times = 1) {
             const sql =
@@ -72,7 +72,7 @@ module.exports = app => {
          *
          * @param {Number} rid - 修订id
          * @param {Number} times - 第几次审批
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async getAuditors2ReviseList(rid, times = 1) {
             const sql =
@@ -95,7 +95,7 @@ module.exports = app => {
          *
          * @param {Number} reviseId - 修订id
          * @param {Number} times - 第几次审批
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async getCurAuditor(reviseId, times = 1) {
             const sql =
@@ -112,7 +112,7 @@ module.exports = app => {
          *
          * @param {Number} reviseId - 修订id
          * @param {Number} times - 第几次审批
-         * @returns {Promise<number>}
+         * @return {Promise<number>}
          */
         async getNewOrder(reviseId, times = 1) {
             const sql = 'SELECT Max(??) As max_order FROM ?? Where `rid` = ? and `times` = ?';
@@ -127,7 +127,7 @@ module.exports = app => {
          * @param {Object} revise - 修订
          * @param {Number} auditorId - 审核人id
          * @param {Number} times - 第几次审批
-         * @returns {Promise<number>}
+         * @return {Promise<number>}
          */
         async addAuditor(revise, auditorId) {
             const times = revise.times ? revise.times : 1;
@@ -139,7 +139,7 @@ module.exports = app => {
                 audit_order: newOrder,
                 status: auditConst.status.uncheck,
                 rid: revise.id,
-                in_time: new Date()
+                in_time: new Date(),
             };
             const result = await this.db.insert(this.tableName, data);
             return (result.effectRows = 1);
@@ -151,26 +151,26 @@ module.exports = app => {
          * @param {Number} reviseId - 修订id
          * @param {Number} auditorId - 审核人id
          * @param {Number} times - 第几次审批
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          * @private
          */
         async _syncOrderByDelete(transaction, reviseId, order, times) {
             this.initSqlBuilder();
             this.sqlBuilder.setAndWhere('rid', {
                 value: this.db.escape(reviseId),
-                operate: '='
+                operate: '=',
             });
             this.sqlBuilder.setAndWhere('audit_order', {
                 value: order,
-                operate: '>='
+                operate: '>=',
             });
             this.sqlBuilder.setAndWhere('times', {
                 value: times,
-                operate: '='
+                operate: '=',
             });
             this.sqlBuilder.setUpdateData('audit_order', {
                 value: 1,
-                selfOperate: '-'
+                selfOperate: '-',
             });
             const [sql, sqlParam] = this.sqlBuilder.build(this.tableName, 'update');
             const data = await transaction.query(sql, sqlParam);
@@ -184,7 +184,7 @@ module.exports = app => {
          * @param {Object} revise - 修订
          * @param {Number} auditorId - 审核人id
          * @param {Number} times - 第几次审批
-         * @returns {Promise<boolean>}
+         * @return {Promise<boolean>}
          */
         async deleteAuditor(revise, auditorId) {
             const times = revise.times ? revise.times : 1;
@@ -193,7 +193,7 @@ module.exports = app => {
                 const condition = { rid: revise.id, audit_id: auditorId, times };
                 const auditor = await this.getDataByCondition(condition);
                 if (!auditor) {
-                    throw '该审核人不存在'
+                    throw '该审核人不存在';
                 }
                 await this._syncOrderByDelete(transaction, revise.id, auditor.audit_order, times);
                 await transaction.delete(this.tableName, condition);
@@ -210,7 +210,7 @@ module.exports = app => {
          *
          * @param {Object} revise - 修订
          * @param {Number} times - 第几次审批
-         * @returns {Promise<boolean>}
+         * @return {Promise<boolean>}
          */
         async start(revise, times = 1) {
             const audit = await this.getDataByCondition({ rid: revise.id, times, audit_order: 1 });
@@ -227,13 +227,13 @@ module.exports = app => {
                     status: auditConst.status.checking,
                     begin_time: time,
                     bills_file: revise.bills_file,
-                    pos_file: revise.pos_file
+                    pos_file: revise.pos_file,
                 });
                 const reviseData = {
                     id: revise.id,
                     status: auditConst.status.checking,
                     bills_file: billsHis,
-                    pos_file: posHis
+                    pos_file: posHis,
                 };
                 if (revise.times === 1) {
                     reviseData.begin_time = time;
@@ -253,8 +253,8 @@ module.exports = app => {
                 };
                 await this.ctx.helper.sendWechat(audit.audit_id, smsTypeConst.const.XD, smsTypeConst.judge.approval.toString(), wxConst.template.revise, wechatData);
                 // 其他参与人
-                const auditList = await this.getAuditors(revise.id, times)
-                const users = this._.pull(this._.map(auditList, 'user_id'), audit.id)
+                const auditList = await this.getAuditors(revise.id, times);
+                const users = this._.pull(this._.map(auditList, 'user_id'), audit.id);
                 // await this.ctx.helper.sendUserSms(users, smsTypeConst.const.XD,
                 //     smsTypeConst.judge.result.toString(), '台账修订已上报。');
                 await this.ctx.helper.sendAliSms(users, smsTypeConst.const.XD, smsTypeConst.judge.result.toString(), SmsAliConst.template.revise_report);
@@ -313,14 +313,14 @@ module.exports = app => {
          * @param {auditConst.status.checked|auditConst.status.checkNo} checkType - 审批结果
          * @param {String} opinion - 审批意见
          * @param {Number} times - 第几次审批
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async check(revise, checkType, opinion, times = 1) {
-            if (checkType !== auditConst.status.checked && checkType !== auditConst.status.checkNo) throw '提交数据错误'
+            if (checkType !== auditConst.status.checked && checkType !== auditConst.status.checkNo) throw '提交数据错误';
             const audit = await this.getDataByCondition({
                 rid: revise.id,
                 times,
-                status: auditConst.status.checking
+                status: auditConst.status.checking,
             });
             if (!audit) throw '审核数据错误';
             const pid = this.ctx.session.sessionProject.id;
@@ -335,8 +335,8 @@ module.exports = app => {
                         type: pushType.revise,
                         uid: revise.uid,
                         status: checkType,
-                        content: noticeContent
-                    }
+                        content: noticeContent,
+                    },
                 ];
                 auditList.forEach(audit => {
                     records.push({
@@ -344,8 +344,8 @@ module.exports = app => {
                         type: pushType.revise,
                         uid: audit.audit_id,
                         status: checkType,
-                        content: noticeContent
-                    })
+                        content: noticeContent,
+                    });
                 });
                 await transaction.insert('zh_notice', records);
 
@@ -356,21 +356,21 @@ module.exports = app => {
                     id: audit.id,
                     status: checkType,
                     opinion,
-                    end_time: time
+                    end_time: time,
                 });
                 if (checkType === auditConst.status.checked) {
                     const nextAudit = await this.getDataByCondition({
                         rid: revise.id,
                         times,
-                        audit_order: audit.audit_order + 1
+                        audit_order: audit.audit_order + 1,
                     });
                     // 无下一审核人表示,审核结束
                     if (nextAudit) {
                         await transaction.update(this.tableName, {
                             id: nextAudit.id,
                             status: auditConst.status.checking,
-                            begin_time: time
-                        })
+                            begin_time: time,
+                        });
 
                         // 短信通知-需要审批提醒功能
                         // 下一人
@@ -390,8 +390,8 @@ module.exports = app => {
                         // await this.ctx.helper.sendUserSms(users, smsTypeConst.const.XD,
                         //     smsTypeConst.judge.result.toString(), '台账修订审批通过。');
                         await this.ctx.helper.sendAliSms(users, smsTypeConst.const.XD, smsTypeConst.judge.result.toString(), SmsAliConst.template.revise_result2, {
-                            status: SmsAliConst.status.success
-                        })
+                            status: SmsAliConst.status.success,
+                        });
                         // 微信模板通知
                         const wechatData2 = {
                             status: wxConst.status.success,
@@ -404,26 +404,27 @@ module.exports = app => {
                         await transaction.update(this.ctx.service.ledgerRevise.tableName, {
                             id: revise.id,
                             status: checkType,
-                            end_time: time
+                            end_time: time,
                         });
                         // 最新一期跟台账相关的缓存数据应过期
                         const lastStage = await this.ctx.service.stage.getLastestStage(revise.tid, true);
                         const cacheTime = new Date();
-                        if (lastStage)
+                        if (lastStage) {
                             await transaction.update(this.ctx.service.stage.tableName, {
                                 id: lastStage.id,
                                 cache_time_l: cacheTime,
-                                cache_time_r: cacheTime
+                                cache_time_r: cacheTime,
                             });
+                        }
                         // 拷贝修订数据至台账
                         await this._replaceLedgerByRevise(transaction, revise);
                         const sum = await this.ctx.service.reviseBills.addUp({
-                            tender_id: revise.tid /* , is_leaf: true*/
+                            tender_id: revise.tid, /* , is_leaf: true*/
                         });
                         await transaction.update(this.ctx.service.tender.tableName, {
                             id: revise.tid,
                             total_price: sum.total_price,
-                            deal_tp: sum.deal_tp
+                            deal_tp: sum.deal_tp,
                         });
                         // 短信通知-审批通过提醒功能
                         // 下一人
@@ -431,7 +432,7 @@ module.exports = app => {
                         // await this.ctx.helper.sendUserSms(revise.uid, smsTypeConst.const.XD,
                         //     smsTypeConst.judge.result.toString(), msg);
                         await this.ctx.helper.sendAliSms(revise.uid, smsTypeConst.const.XD, smsTypeConst.judge.result.toString(), SmsAliConst.template.revise_result, {
-                            status: SmsAliConst.status.success
+                            status: SmsAliConst.status.success,
                         });
                         // 微信模板通知
                         const wechatData = {
@@ -441,12 +442,12 @@ module.exports = app => {
                         };
                         await this.ctx.helper.sendWechat(revise.uid, smsTypeConst.const.XD, smsTypeConst.judge.result.toString(), wxConst.template.revise, wechatData);
                         // 其他参与人
-                        const users = this._.pull(this._.map(auditList, 'user_id'), audit.id)
+                        const users = this._.pull(this._.map(auditList, 'user_id'), audit.id);
                         // await this.ctx.helper.sendUserSms(users, smsTypeConst.const.XD,
                         //     smsTypeConst.judge.result.toString(), '台账修订审批通过。');
                         await this.ctx.helper.sendAliSms(users, smsTypeConst.const.XD, smsTypeConst.judge.result.toString(), SmsAliConst.template.revise_result2, {
-                            status: SmsAliConst.status.success
-                        })
+                            status: SmsAliConst.status.success,
+                        });
                         // 微信模板通知
                         const wechatData2 = {
                             status: wxConst.status.success,
@@ -460,12 +461,12 @@ module.exports = app => {
                     await transaction.update(this.ctx.service.ledgerRevise.tableName, {
                         id: revise.id,
                         times: times + 1,
-                        status: checkType
+                        status: checkType,
                     });
                     // 拷贝新一次审核流程列表
                     const auditors = await this.getAllDataByCondition({
                         where: { rid: revise.id, times },
-                        columns: ['tender_id', 'rid', 'audit_order', 'audit_id']
+                        columns: ['tender_id', 'rid', 'audit_order', 'audit_id'],
                     });
                     for (const a of auditors) {
                         a.times = times + 1;
@@ -479,7 +480,7 @@ module.exports = app => {
                     // await this.ctx.helper.sendUserSms(revise.uid, smsTypeConst.const.XD,
                     //     smsTypeConst.judge.result.toString(), '台账修订审批退回,请登录系统处理。');
                     await this.ctx.helper.sendAliSms(revise.uid, smsTypeConst.const.XD, smsTypeConst.judge.result.toString(), SmsAliConst.template.revise_result, {
-                        status: SmsAliConst.status.back
+                        status: SmsAliConst.status.back,
                     });
                     // 微信模板通知
                     const wechatData = {
@@ -497,7 +498,7 @@ module.exports = app => {
                         smsTypeConst.judge.result.toString(),
                         SmsAliConst.template.revise_result2,
                         {
-                            status: SmsAliConst.status.back
+                            status: SmsAliConst.status.back,
                         }
                     );
                     // 微信模板通知
@@ -520,7 +521,7 @@ module.exports = app => {
          * 获取审核人需要审核的标段列表
          *
          * @param auditorId
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async getAuditRevise(auditorId) {
             const sql =
@@ -543,7 +544,7 @@ module.exports = app => {
          * @param {Integer} pid - 项目id
          * @param {Integer} uid - 查询人id
          * @param {Date} noticeTime - 查询事件
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async getNoticeRevise(pid, uid, noticeTime) {
             // const sql = 'SELECT * FROM (SELECT ra.`audit_id`, ra.`times`, ra.`audit_order`, ra.`end_time`, ra.`status`,' +
@@ -563,7 +564,7 @@ module.exports = app => {
                 where: { pid, type: pushType.revise, uid },
                 orders: [['create_time', 'desc']],
                 limit: 10,
-                offset: 0
+                offset: 0,
             });
             notice = notice.map(v => {
                 const extra = JSON.parse(v.content);
@@ -635,7 +636,7 @@ module.exports = app => {
          * 获取审核人流程列表
          *
          * @param auditorId
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async getAuditGroupByList(rid, times) {
             const sql =
@@ -649,6 +650,30 @@ module.exports = app => {
             // return await this.db.query(sql, sqlParam);
         }
 
+        /**
+         * 获取审核人流程列表(包括原报)
+         * @param {Number} rid 修订id
+         * @param {Number} times 审核次数
+         * @return {Promise<Array>} 查询结果集(包括原报)
+         */
+        async getAuditorsWithOwner(rid, times = 1) {
+            const result = await this.getAuditGroupByList(rid, times);
+            const sql =
+                'SELECT pa.`id` As aid, pa.`name`, pa.`company`, pa.`role`, ? As times, ? As rid, 0 As `order`' +
+                '  FROM ' +
+                this.ctx.service.ledgerRevise.tableName +
+                ' As s' +
+                '  LEFT JOIN ' +
+                this.ctx.service.projectAccount.tableName +
+                ' As pa' +
+                '  ON s.uid = pa.id' +
+                '  WHERE s.id = ?';
+            const sqlParam = [times, rid, rid];
+            const user = await this.db.queryOne(sql, sqlParam);
+            result.unshift(user);
+            return result;
+        }
+
         async getAllAuditors(tenderId) {
             const sql =
                 'SELECT ra.audit_id, ra.tender_id FROM ' +
@@ -664,5 +689,5 @@ module.exports = app => {
         }
     }
 
-    return ReviseAudit
+    return ReviseAudit;
 };

+ 0 - 10
app/view/material/audit_btn.ejs

@@ -19,13 +19,3 @@
         <% } %>
     <% } %>
 </div>
-<script>
-    $('.sp-list-btn').click(function () {
-        const type = $(this).data('type')
-        if (type === 'hide') {
-            $('.sp-list-item').hide()
-        } else {
-            $('.sp-list-item').show()
-        }
-    });
-</script>

+ 11 - 3
app/view/revise/info.ejs

@@ -51,9 +51,9 @@
                 <a href="#sub-sp" data-toggle="modal" data-target="#sub-sp" class="btn btn-primary btn-sm pull-right mr-1">上报审批</a>
                 <% } %>
                 <% if (revise.status === audit.status.checkNo) { %>
-                <a href="#sp-list" data-toggle="modal" data-target="#sp-list" class="btn btn-outline-secondary btn-sm pull-right mr-1">审批退回</a>
+                <a href="#sp-list" data-type="hide" data-toggle="modal" data-target="#sp-list" class="btn btn-outline-secondary btn-sm pull-right mr-1 sp-list-btn">审批退回</a>
                     <% if (revise.uid === ctx.session.sessionUser.accountId) { %>
-                    <a href="#sub-sp" data-toggle="modal" data-target="#sub-sp2" class="btn btn-primary btn-sm pull-right mr-1">重新上报</a>
+                    <a href="#sp-list" data-type="show" data-toggle="modal" data-target="#sp-list" class="btn btn-primary btn-sm pull-right mr-1 sp-list-btn">重新上报</a>
                     <% } %>
                 <% } %>
                 <% if (revise.status === audit.status.checking) { %>
@@ -225,4 +225,12 @@
     const billsSpreadSetting = JSON.parse('<%- JSON.stringify(ledgerSpread) %>');
     const posSpreadSetting = JSON.parse('<%- JSON.stringify(posSpread) %>');
     const thousandth = <%- ctx.tender.info.display.thousandth %>;
-</script>
+    $('.sp-list-btn').click(function () {
+        const type = $(this).data('type')
+        if (type === 'hide') {
+            $('.sp-list-item').hide()
+        } else {
+            $('.sp-list-item').show()
+        }
+    });
+</script>

File diff suppressed because it is too large
+ 777 - 506
app/view/revise/info_modal.ejs