lanjianrong 5 лет назад
Родитель
Сommit
03770a8a1e

+ 9 - 0
.vscode/settings.json

@@ -0,0 +1,9 @@
+{
+  "path-intellisense.mappings": {
+    "@": "${workspaceRoot}"
+  },
+  "editor.formatOnSave": false,
+  "editor.codeActionsOnSave": {
+    "source.fixAll.eslint": true
+  }
+}

+ 8 - 5
app/controller/advance_controller.js

@@ -17,6 +17,7 @@ module.exports = app => {
                 advanceList,
                 latestOrder,
                 auditConst,
+                preUrl: `/tender/${ctx.tender.id}/advance/${type}/create`,
                 jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.advance.main),
                 advancePayTotal: ctx.tender.info.deal_param.startAdvance
             }
@@ -36,6 +37,7 @@ module.exports = app => {
                 advanceList,
                 latestOrder,
                 auditConst,
+                preUrl: `/tender/${ctx.tender.id}/advance/${type}/create`,
                 jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.advance.main),
                 advancePayTotal: ctx.tender.info.deal_param.materialAdvance
             }
@@ -45,13 +47,14 @@ module.exports = app => {
         /**
          * 获取通用的renderData(用于layout, Menu, subMenu部分)
          * @param {Object} ctx 全局上下文
-         * @return {{auditConst, jsFiles, accountGroup?, accountList?, auditors, auditHistory}}
+         * @return {{auditConst, jsFiles, accountGroup?, accountList?, auditors, auditHistory, preUrl}}
          * @private
          */
         async _getDefaultRenderData(ctx) {
             const data = {
                 auditConst,
-                jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.advance.info)
+                jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.advance.info),
+                preUrl: `/tender/${ctx.tender.id}/advance/${ctx.advance.id}`
             }
             // 获取所有项目参与者
             if ((ctx.advance.status === auditConst.status.uncheck || ctx.advance.status === auditConst.status.checkNo) && ctx.session.sessionUser.accountId === ctx.advance.uid) {
@@ -194,12 +197,12 @@ module.exports = app => {
                 if (ctx.advance.status === auditConst.status.checking || ctx.advance.status === auditConst.status.checked) {
                     throw '该预付款期数据当前无法上报'
                 }
-                await ctx.service.advanceAudit.check(ctx.advance.id, data, ctx.advance.times, data)
-                ctx.redirect(ctx.request.header.referer)
+                await ctx.service.advanceAudit.start(ctx.advance.id, ctx.advance.times, data)
+                ctx.body = { err: 0, msg: '' }
             } catch (error) {
                 this.log(error)
                 ctx.session.postError = error.toString()
-                ctx.redirect(ctx.request.header.referer)
+                ctx.body = { err: 1, msg: error.toString() }
             }
         }
 

+ 1 - 1
app/controller/stage_controller.js

@@ -730,7 +730,7 @@ module.exports = app => {
                     const payCalculator = new PayCalculator(ctx, ctx.stage, ctx.tender.info);
                     await payCalculator.calculateAll(renderData.dealPay);
                     await this._updateStageCache(ctx, payCalculator);
-                    //renderData.calcBase = payCalculator.bases;
+                    // renderData.calcBase = payCalculator.bases;
                 }
                 await this.layout('stage/pay.ejs', renderData, 'stage/pay_modal.ejs');
             } catch (err) {

+ 2 - 2
app/public/js/advance.js

@@ -22,8 +22,8 @@ $(document).ready(function () {
                 <td><a href="/tender/${res.tid}/advance/${res.id}/detail" class="btn btn-primary btn-sm">编辑</a></td>
                 </tr>`
             $('#advanceList').prepend(html)
-            $('advance_add').remove()
-            // $(`#advanceList a[data-id=${res.id}]`).trigger('click')
+            $('#advance_add').remove()
+            window.location.href = `${window.location.pathname}/${res.id}/detail`
         })
         return false
     })

+ 6 - 3
app/public/js/advance_audit.js

@@ -82,8 +82,6 @@ $(document).ready(function () {
                 const aLi = $('li[auditorId=' + rst.audit_id + ']');
                 $('span', aLi).text(rst.order + ' ' + rst.name + ' ')
             }
-
-
             // 删除左边审核人
             $(`#auditors2 li[data-auditorId='${data.auditorId}']`).remove()
         })
@@ -111,7 +109,12 @@ $(document).ready(function () {
         const prev_total_amount = ZhCalc.add(cur_amount, prev_amount)
         const remark = $('#ad-remark').val() || null
         const data = {pay_ratio, cur_amount, prev_amount, prev_total_amount, remark, status: auditConst.status.checking}
-        postData(getUrlPre() + '/audit/start', data, (data) => {})
+        postData(getUrlPre() + '/audit/start', data, (data) => {
+            window.location.reload()
+        }, () => {
+            window.location.reload()
+
+        })
     })
 
     // 自动转换支付比例和本期金额

+ 259 - 259
app/router.js

@@ -1,47 +1,47 @@
-'use strict'
+'use strict';
 
 module.exports = app => {
     // session验证中间件
-    const sessionAuth = app.middlewares.sessionAuth()
+    const sessionAuth = app.middlewares.sessionAuth();
     // 创建时间自动填充中间件
-    const datetimeFill = app.middlewares.datetimeFill()
+    const datetimeFill = app.middlewares.datetimeFill();
     // 项目管理员判断中间件
-    const projectManagerCheck = app.middlewares.projectManagerCheck()
+    const projectManagerCheck = app.middlewares.projectManagerCheck();
     // 标段读取中间件
-    const tenderCheck = app.middlewares.tenderCheck()
+    const tenderCheck = app.middlewares.tenderCheck();
     // 期读取中间件
-    const stageCheck = app.middlewares.stageCheck()
+    const stageCheck = app.middlewares.stageCheck();
     // 材料调差读取中间件
-    const materialCheck = app.middlewares.materialCheck()
+    const materialCheck = app.middlewares.materialCheck();
     // 第三方接口认证判断中间件
-    const api2otherCheck = app.middlewares.api2otherCheck()
+    const api2otherCheck = app.middlewares.api2otherCheck();
     // 微信验证登录中间件
-    const wechatAuth = app.middlewares.wechatAuth()
+    const wechatAuth = app.middlewares.wechatAuth();
     // 预付款中间件
-    const advanceCheck = app.middlewares.advanceCheck()
+    const advanceCheck = app.middlewares.advanceCheck();
     // 登入登出相关
-    app.get('/login', 'loginController.index')
-    app.get('/login/port', api2otherCheck, 'loginController.port')
-    app.get('/', 'loginController.index')
-    app.get('/logout', 'loginController.logout')
-    app.post('/login', 'loginController.login')
-    app.post('/login/port', 'loginController.loginPort')
-    app.get('/project/name', 'loginController.projectName')
-
-    app.get('/sign', 'signController.index')
-    app.post('/sign/save', 'signController.save')
-    app.post('/reset/password', 'loginController.resetPassword')
+    app.get('/login', 'loginController.index');
+    app.get('/login/port', api2otherCheck, 'loginController.port');
+    app.get('/', 'loginController.index');
+    app.get('/logout', 'loginController.logout');
+    app.post('/login', 'loginController.login');
+    app.post('/login/port', 'loginController.loginPort');
+    app.get('/project/name', 'loginController.projectName');
+
+    app.get('/sign', 'signController.index');
+    app.post('/sign/save', 'signController.save');
+    app.post('/reset/password', 'loginController.resetPassword');
 
     // 用户信息初始化相关
-    app.get('/boot', sessionAuth, 'bootController.index')
-    app.post('/boot', sessionAuth, 'bootController.boot')
+    app.get('/boot', sessionAuth, 'bootController.index');
+    app.post('/boot', sessionAuth, 'bootController.boot');
 
     // 控制面板相关
-    app.get('/dashboard', sessionAuth, 'dashboardController.index')
-    app.get('/dashboard/msg/list', sessionAuth, 'dashboardController.msgList')
-    app.get('/dashboard/msg/add/:id', sessionAuth, 'dashboardController.msgAdd')
-    app.post('/dashboard/msg/set/:id', sessionAuth, datetimeFill, 'dashboardController.msgSet')
-    app.get('/dashboard/msg/del/:id', sessionAuth, 'dashboardController.msgDelete')
+    app.get('/dashboard', sessionAuth, 'dashboardController.index');
+    app.get('/dashboard/msg/list', sessionAuth, 'dashboardController.msgList');
+    app.get('/dashboard/msg/add/:id', sessionAuth, 'dashboardController.msgAdd');
+    app.post('/dashboard/msg/set/:id', sessionAuth, datetimeFill, 'dashboardController.msgSet');
+    app.get('/dashboard/msg/del/:id', sessionAuth, 'dashboardController.msgDelete');
 
     // 推送相关
     // app.post('/dashboard/push', sessionAuth, 'dashboardController.pushSet');
@@ -49,337 +49,337 @@ module.exports = app => {
      * 项目设置
      */
     // 项目信息
-    app.get('/setting/info', sessionAuth, 'settingController.info')
-    app.post('/setting/updateinfo/:id', sessionAuth, 'settingController.updateinfo')
+    app.get('/setting/info', sessionAuth, 'settingController.info');
+    app.post('/setting/updateinfo/:id', sessionAuth, 'settingController.updateinfo');
     // 账号设置
-    app.get('/setting/user', sessionAuth, 'settingController.user')
-    app.get('/setting/user/permission/set', sessionAuth, 'settingController.userPermissionSet')
+    app.get('/setting/user', sessionAuth, 'settingController.user');
+    app.get('/setting/user/permission/set', sessionAuth, 'settingController.userPermissionSet');
     // 账号停用和启用
-    app.post('/setting/user/switch', sessionAuth, 'settingController.userSwitch')
-    app.post('/setting/user/add', sessionAuth, datetimeFill, 'settingController.addUser')
-    app.post('/setting/user/update', sessionAuth, 'settingController.updateUser')
-    app.post('/setting/user/permission', sessionAuth, 'settingController.permission')
-    app.post('/setting/user/reset/password', sessionAuth, 'settingController.resetUserPassword')
-    app.post('/setting/user/exist', sessionAuth, 'settingController.accountExist')
-    app.post('/setting/user/unbind', sessionAuth, 'settingController.userUnbind')
+    app.post('/setting/user/switch', sessionAuth, 'settingController.userSwitch');
+    app.post('/setting/user/add', sessionAuth, datetimeFill, 'settingController.addUser');
+    app.post('/setting/user/update', sessionAuth, 'settingController.updateUser');
+    app.post('/setting/user/permission', sessionAuth, 'settingController.permission');
+    app.post('/setting/user/reset/password', sessionAuth, 'settingController.resetUserPassword');
+    app.post('/setting/user/exist', sessionAuth, 'settingController.accountExist');
+    app.post('/setting/user/unbind', sessionAuth, 'settingController.userUnbind');
 
     // 显示设置
-    app.get('/setting/show', sessionAuth, 'settingController.show')
-    app.post('/setting/show/update', sessionAuth, 'settingController.showListUpdate')
+    app.get('/setting/show', sessionAuth, 'settingController.show');
+    app.post('/setting/show/update', sessionAuth, 'settingController.showListUpdate');
 
     // 标段自定义类别
-    app.get('/setting/category', sessionAuth, 'settingController.category')
-    app.post('/setting/category/add', sessionAuth, 'settingController.addCategory')
-    app.post('/setting/category/del', sessionAuth, 'settingController.deleteCategory')
-    app.post('/setting/category/update', sessionAuth, 'settingController.updateCategory')
-    app.post('/setting/category/value', sessionAuth, 'settingController.setCategoryValue')
-    app.post('/setting/category/level', sessionAuth, 'settingController.resetCategoryLevel')
+    app.get('/setting/category', sessionAuth, 'settingController.category');
+    app.post('/setting/category/add', sessionAuth, 'settingController.addCategory');
+    app.post('/setting/category/del', sessionAuth, 'settingController.deleteCategory');
+    app.post('/setting/category/update', sessionAuth, 'settingController.updateCategory');
+    app.post('/setting/category/value', sessionAuth, 'settingController.setCategoryValue');
+    app.post('/setting/category/level', sessionAuth, 'settingController.resetCategoryLevel');
 
     // 项目相关
-    app.get('/project/info', sessionAuth, 'projectController.info')
-    app.get('/project/account', sessionAuth, projectManagerCheck, 'accountController.index')
-    app.post('/project/account/permission/:accountId', sessionAuth, projectManagerCheck, 'accountController.savePermission')
-    app.get('/project/account/enable/:accountId', sessionAuth, projectManagerCheck, 'accountController.enable')
-    app.get('/project/account/disable/:accountId', sessionAuth, projectManagerCheck, 'accountController.enable')
-    app.get('/project/switch/:projectId', sessionAuth, projectManagerCheck, 'projectController.switchProject')
-    app.post('/project/info', sessionAuth, 'projectController.saveInfo')
+    app.get('/project/info', sessionAuth, 'projectController.info');
+    app.get('/project/account', sessionAuth, projectManagerCheck, 'accountController.index');
+    app.post('/project/account/permission/:accountId', sessionAuth, projectManagerCheck, 'accountController.savePermission');
+    app.get('/project/account/enable/:accountId', sessionAuth, projectManagerCheck, 'accountController.enable');
+    app.get('/project/account/disable/:accountId', sessionAuth, projectManagerCheck, 'accountController.enable');
+    app.get('/project/switch/:projectId', sessionAuth, projectManagerCheck, 'projectController.switchProject');
+    app.post('/project/info', sessionAuth, 'projectController.saveInfo');
 
     /**
      * 标段管理
      */
     // 金额概况
-    app.get('/list', sessionAuth, 'tenderController.listDefault')
-    app.get('/list/info', sessionAuth, 'tenderController.listInfo')
+    app.get('/list', sessionAuth, 'tenderController.listDefault');
+    app.get('/list/info', sessionAuth, 'tenderController.listInfo');
 
     // 计量进度
-    app.get('/list/progress', sessionAuth, 'tenderController.listProgress')
+    app.get('/list/progress', sessionAuth, 'tenderController.listProgress');
 
     // 管理标段
-    app.get('/list/manage', sessionAuth, 'tenderController.listManage')
-    app.post('/list/add', sessionAuth, 'tenderController.addTender')
-    app.post('/list/update', sessionAuth, 'tenderController.updateTender')
-    app.post('/list/del', sessionAuth, 'tenderController.deleteTender')
+    app.get('/list/manage', sessionAuth, 'tenderController.listManage');
+    app.post('/list/add', sessionAuth, 'tenderController.addTender');
+    app.post('/list/update', sessionAuth, 'tenderController.updateTender');
+    app.post('/list/del', sessionAuth, 'tenderController.deleteTender');
 
     // 标段概况
-    app.get('/tender/:id', sessionAuth, tenderCheck, 'tenderController.tenderInfo')
-    app.get('/tender/:id/type', sessionAuth, 'tenderController.tenderType')
-    app.post('/tender/:id/save', sessionAuth, tenderCheck, 'tenderController.saveTenderInfo')
-    app.post('/tender/rule', sessionAuth, 'tenderController.rule')
-    app.post('/tender/:id/rule/first', sessionAuth, tenderCheck, 'tenderController.ruleFirst')
+    app.get('/tender/:id', sessionAuth, tenderCheck, 'tenderController.tenderInfo');
+    app.get('/tender/:id/type', sessionAuth, 'tenderController.tenderType');
+    app.post('/tender/:id/save', sessionAuth, tenderCheck, 'tenderController.saveTenderInfo');
+    app.post('/tender/rule', sessionAuth, 'tenderController.rule');
+    app.post('/tender/:id/rule/first', sessionAuth, tenderCheck, 'tenderController.ruleFirst');
 
     // 预付款
-    app.get('/tender/:id/advance', sessionAuth, tenderCheck, 'advanceController.index')
-    app.get('/tender/:id/advance/material', sessionAuth, tenderCheck, 'advanceController.materialList')
-    app.post('/tender/:id/advance/create', sessionAuth, tenderCheck, 'advanceController.create')
-    app.get('/tender/:id/advance/:order/detail', sessionAuth, tenderCheck, advanceCheck, 'advanceController.detail')
-    app.post('/tender/:id/advance/:type/create', sessionAuth, tenderCheck, 'advanceController.create')
-    app.post('/tender/:id/advance/:order/audit/add', sessionAuth, tenderCheck, advanceCheck, 'advanceController.addAudit')
-    app.post('/tender/:id/advance/:order/audit/delete', sessionAuth, tenderCheck, advanceCheck, 'advanceController.deleteAudit')
-    app.post('/tender/:id/advance/:order/audit/start', sessionAuth, tenderCheck, advanceCheck, 'advanceController.start')
-    app.post('/tender/:id/advance/:order/audit/check', sessionAuth, tenderCheck, advanceCheck, 'advanceController.checkAudit')
+    app.get('/tender/:id/advance', sessionAuth, tenderCheck, 'advanceController.index');
+    app.get('/tender/:id/advance/material', sessionAuth, tenderCheck, 'advanceController.materialList');
+    app.post('/tender/:id/advance/create', sessionAuth, tenderCheck, 'advanceController.create');
+    app.get('/tender/:id/advance/:order/detail', sessionAuth, tenderCheck, advanceCheck, 'advanceController.detail');
+    app.post('/tender/:id/advance/:type/create', sessionAuth, tenderCheck, 'advanceController.create');
+    app.post('/tender/:id/advance/:order/audit/add', sessionAuth, tenderCheck, advanceCheck, 'advanceController.addAudit');
+    app.post('/tender/:id/advance/:order/audit/delete', sessionAuth, tenderCheck, advanceCheck, 'advanceController.deleteAudit');
+    app.post('/tender/:id/advance/:order/audit/start', sessionAuth, tenderCheck, advanceCheck, 'advanceController.start');
+    app.post('/tender/:id/advance/:order/audit/check', sessionAuth, tenderCheck, advanceCheck, 'advanceController.checkAudit');
 
     // 标段协作办公
-    app.get('/tender/:id/cooperation', sessionAuth, tenderCheck, 'tenderController.tenderCooperation')
+    app.get('/tender/:id/cooperation', sessionAuth, tenderCheck, 'tenderController.tenderCooperation');
 
     // 台账管理相关
-    app.get('/tender/:id/ledger', sessionAuth, tenderCheck, 'ledgerController.explode')
-    app.post('/tender/:id/ledger/load', sessionAuth, tenderCheck, 'ledgerController.loadExplodeData')
-    app.post('/tender/:id/ledger/get-children', sessionAuth, tenderCheck, 'ledgerController.getChildren')
-    app.post('/tender/:id/ledger/update', sessionAuth, tenderCheck, 'ledgerController.update')
-    app.post('/tender/:id/ledger/upload-excel/:ueType', sessionAuth, tenderCheck, 'ledgerController.uploadExcel')
-    app.get('/tender/:id/ledger/download/:file', sessionAuth, tenderCheck, 'ledgerController.download')
-    app.post('/tender/:id/pos/update', sessionAuth, tenderCheck, 'ledgerController.posUpdate')
-    app.post('/tender/:id/pos/paste', sessionAuth, tenderCheck, 'ledgerController.posPaste')
-    app.post('/tender/:id/ledger/deal2sgfh', sessionAuth, tenderCheck, 'ledgerController.deal2sgfh')
-    app.post('/tender/:id/ledger/check', sessionAuth, tenderCheck, 'ledgerController.check')
+    app.get('/tender/:id/ledger', sessionAuth, tenderCheck, 'ledgerController.explode');
+    app.post('/tender/:id/ledger/load', sessionAuth, tenderCheck, 'ledgerController.loadExplodeData');
+    app.post('/tender/:id/ledger/get-children', sessionAuth, tenderCheck, 'ledgerController.getChildren');
+    app.post('/tender/:id/ledger/update', sessionAuth, tenderCheck, 'ledgerController.update');
+    app.post('/tender/:id/ledger/upload-excel/:ueType', sessionAuth, tenderCheck, 'ledgerController.uploadExcel');
+    app.get('/tender/:id/ledger/download/:file', sessionAuth, tenderCheck, 'ledgerController.download');
+    app.post('/tender/:id/pos/update', sessionAuth, tenderCheck, 'ledgerController.posUpdate');
+    app.post('/tender/:id/pos/paste', sessionAuth, tenderCheck, 'ledgerController.posPaste');
+    app.post('/tender/:id/ledger/deal2sgfh', sessionAuth, tenderCheck, 'ledgerController.deal2sgfh');
+    app.post('/tender/:id/ledger/check', sessionAuth, tenderCheck, 'ledgerController.check');
 
     // 台账审批相关
-    app.get('/tender/:id/ledger/audit', sessionAuth, tenderCheck, 'ledgerAuditController.index')
-    app.post('/tender/:id/ledger/audit/add', sessionAuth, tenderCheck, 'ledgerAuditController.add')
-    app.post('/tender/:id/ledger/audit/delete', sessionAuth, tenderCheck, 'ledgerAuditController.remove')
-    app.post('/tender/:id/ledger/audit/start', sessionAuth, tenderCheck, 'ledgerAuditController.start')
-    app.post('/tender/:id/ledger/audit/check', sessionAuth, tenderCheck, 'ledgerAuditController.check')
+    app.get('/tender/:id/ledger/audit', sessionAuth, tenderCheck, 'ledgerAuditController.index');
+    app.post('/tender/:id/ledger/audit/add', sessionAuth, tenderCheck, 'ledgerAuditController.add');
+    app.post('/tender/:id/ledger/audit/delete', sessionAuth, tenderCheck, 'ledgerAuditController.remove');
+    app.post('/tender/:id/ledger/audit/start', sessionAuth, tenderCheck, 'ledgerAuditController.start');
+    app.post('/tender/:id/ledger/audit/check', sessionAuth, tenderCheck, 'ledgerAuditController.check');
 
     // 部位台账
-    app.get('/tender/:id/ledger/bwtz', sessionAuth, tenderCheck, 'ledgerController.bwtz')
-    app.post('/tender/:id/ledger/bwtz/load', sessionAuth, tenderCheck, 'ledgerController.loadBwtz')
+    app.get('/tender/:id/ledger/bwtz', sessionAuth, tenderCheck, 'ledgerController.bwtz');
+    app.post('/tender/:id/ledger/bwtz/load', sessionAuth, tenderCheck, 'ledgerController.loadBwtz');
 
     // 台账对比
-    app.get('/tender/:id/ledger/gather', sessionAuth, tenderCheck, 'ledgerController.gather')
-    app.post('/tender/:id/ledger/gather/load', sessionAuth, tenderCheck, 'ledgerController.loadGatherData')
+    app.get('/tender/:id/ledger/gather', sessionAuth, tenderCheck, 'ledgerController.gather');
+    app.post('/tender/:id/ledger/gather/load', sessionAuth, tenderCheck, 'ledgerController.loadGatherData');
 
     // 台账修订
-    app.get('/tender/:id/revise', sessionAuth, tenderCheck, 'reviseController.index')
-    app.post('/tender/:id/revise/add', sessionAuth, tenderCheck, 'reviseController.add')
-    app.post('/tender/:id/revise/cancel', sessionAuth, tenderCheck, 'reviseController.cancel')
-    app.post('/tender/:id/revise/save', sessionAuth, tenderCheck, 'reviseController.save')
+    app.get('/tender/:id/revise', sessionAuth, tenderCheck, 'reviseController.index');
+    app.post('/tender/:id/revise/add', sessionAuth, tenderCheck, 'reviseController.add');
+    app.post('/tender/:id/revise/cancel', sessionAuth, tenderCheck, 'reviseController.cancel');
+    app.post('/tender/:id/revise/save', sessionAuth, tenderCheck, 'reviseController.save');
     // app.post('/tender/:id/revise/deal2sgfh', sessionAuth, tenderCheck, 'reviseController.deal2sgfh');
 
     // 台账修订页面
-    app.get('/tender/:id/revise/info', sessionAuth, tenderCheck, 'reviseController.info')
-    app.post('/tender/:id/revise/auditors', sessionAuth, tenderCheck, 'reviseController.reviseAuditors')
-    app.post('/tender/:id/revise/info/load', sessionAuth, tenderCheck, 'reviseController.loadInfoData')
-    app.post('/tender/:id/revise/info/update', sessionAuth, tenderCheck, 'reviseController.update')
-    app.post('/tender/:id/revise/info/upload-excel/:ueType', sessionAuth, tenderCheck, 'reviseController.uploadExcel')
-    app.post('/tender/:id/revise/info/check', sessionAuth, tenderCheck, 'reviseController.checkData')
+    app.get('/tender/:id/revise/info', sessionAuth, tenderCheck, 'reviseController.info');
+    app.post('/tender/:id/revise/auditors', sessionAuth, tenderCheck, 'reviseController.reviseAuditors');
+    app.post('/tender/:id/revise/info/load', sessionAuth, tenderCheck, 'reviseController.loadInfoData');
+    app.post('/tender/:id/revise/info/update', sessionAuth, tenderCheck, 'reviseController.update');
+    app.post('/tender/:id/revise/info/upload-excel/:ueType', sessionAuth, tenderCheck, 'reviseController.uploadExcel');
+    app.post('/tender/:id/revise/info/check', sessionAuth, tenderCheck, 'reviseController.checkData');
 
     // 查看修订数据
-    app.get('/tender/:id/revise/history', sessionAuth, tenderCheck, 'reviseController.history')
-    app.post('/tender/:id/revise/history/load', sessionAuth, tenderCheck, 'reviseController.loadHistoryData')
-    app.post('/tender/:id/revise/history/info', sessionAuth, tenderCheck, 'reviseController.historyInfo')
+    app.get('/tender/:id/revise/history', sessionAuth, tenderCheck, 'reviseController.history');
+    app.post('/tender/:id/revise/history/load', sessionAuth, tenderCheck, 'reviseController.loadHistoryData');
+    app.post('/tender/:id/revise/history/info', sessionAuth, tenderCheck, 'reviseController.historyInfo');
 
     // 修订审批
-    app.post('/tender/:id/revise/audit/add', sessionAuth, tenderCheck, 'reviseController.addAuditor')
-    app.post('/tender/:id/revise/audit/remove', sessionAuth, tenderCheck, 'reviseController.removeAuditor')
-    app.post('/tender/:id/revise/audit/start', sessionAuth, tenderCheck, 'reviseController.start')
-    app.post('/tender/:id/revise/audit/check', sessionAuth, tenderCheck, 'reviseController.check')
+    app.post('/tender/:id/revise/audit/add', sessionAuth, tenderCheck, 'reviseController.addAuditor');
+    app.post('/tender/:id/revise/audit/remove', sessionAuth, tenderCheck, 'reviseController.removeAuditor');
+    app.post('/tender/:id/revise/audit/start', sessionAuth, tenderCheck, 'reviseController.start');
+    app.post('/tender/:id/revise/audit/check', sessionAuth, tenderCheck, 'reviseController.check');
 
     // 签约清单
-    app.post('/tender/:id/deal/get-data', sessionAuth, tenderCheck, 'dealBillsController.getData')
-    app.post('/tender/:id/deal/upload-excel', sessionAuth, tenderCheck, 'dealBillsController.loadExcel')
-    app.get('/tender/:id/deal/download/:file', sessionAuth, tenderCheck, 'dealBillsController.download')
+    app.post('/tender/:id/deal/get-data', sessionAuth, tenderCheck, 'dealBillsController.getData');
+    app.post('/tender/:id/deal/upload-excel', sessionAuth, tenderCheck, 'dealBillsController.loadExcel');
+    app.get('/tender/:id/deal/download/:file', sessionAuth, tenderCheck, 'dealBillsController.download');
 
     // 计量台账
     // 期计量
-    app.get('/tender/:id/measure/stage', sessionAuth, tenderCheck, 'measureController.stage')
-    app.post('/tender/:id/measure/stage/auditors', sessionAuth, tenderCheck, 'measureController.stageAuditors')
-    app.post('/tender/:id/measure/add', sessionAuth, tenderCheck, 'measureController.add')
-    app.post('/tender/:id/measure/save', sessionAuth, tenderCheck, 'measureController.save')
-    app.post('/tender/:id/measure/stage/delete', sessionAuth, tenderCheck, 'measureController.delete')
+    app.get('/tender/:id/measure/stage', sessionAuth, tenderCheck, 'measureController.stage');
+    app.post('/tender/:id/measure/stage/auditors', sessionAuth, tenderCheck, 'measureController.stageAuditors');
+    app.post('/tender/:id/measure/add', sessionAuth, tenderCheck, 'measureController.add');
+    app.post('/tender/:id/measure/save', sessionAuth, tenderCheck, 'measureController.save');
+    app.post('/tender/:id/measure/stage/delete', sessionAuth, tenderCheck, 'measureController.delete');
 
     // 计量台账 -- 清单汇总
-    app.get('/tender/:id/measure/gather', sessionAuth, tenderCheck, 'measureController.gather')
+    app.get('/tender/:id/measure/gather', sessionAuth, tenderCheck, 'measureController.gather');
 
     // 计量台账 -- 审核比较
-    app.get('/tender/:id/measure/compare', sessionAuth, tenderCheck, 'measureController.compare')
-    app.post('/tender/:id/measure/compare/load', sessionAuth, tenderCheck, 'measureController.loadCompareData')
+    app.get('/tender/:id/measure/compare', sessionAuth, tenderCheck, 'measureController.compare');
+    app.post('/tender/:id/measure/compare/load', sessionAuth, tenderCheck, 'measureController.loadCompareData');
 
     // 期计量详细
     // 本期计量台账
-    app.get('/tender/:id/measure/stage/:order', sessionAuth, tenderCheck, stageCheck, 'stageController.index')
-    app.post('/tender/:id/measure/stage/:order/load', sessionAuth, tenderCheck, stageCheck, 'stageController.getStageData')
-    app.post('/tender/:id/measure/stage/:order/pos', sessionAuth, tenderCheck, stageCheck, 'stageController.getStagePosData')
-    app.post('/tender/:id/measure/stage/:order/update', sessionAuth, tenderCheck, stageCheck, 'stageController.updateStageData')
-    app.post('/tender/:id/measure/stage/:order/valid-change', sessionAuth, tenderCheck, stageCheck, 'stageController.searchValidChange')
-    app.post('/tender/:id/measure/stage/:order/use-change', sessionAuth, tenderCheck, stageCheck, 'stageController.useChange')
-    app.post('/tender/:id/measure/stage/:order/check', sessionAuth, tenderCheck, stageCheck, 'stageController.check')
+    app.get('/tender/:id/measure/stage/:order', sessionAuth, tenderCheck, stageCheck, 'stageController.index');
+    app.post('/tender/:id/measure/stage/:order/load', sessionAuth, tenderCheck, stageCheck, 'stageController.getStageData');
+    app.post('/tender/:id/measure/stage/:order/pos', sessionAuth, tenderCheck, stageCheck, 'stageController.getStagePosData');
+    app.post('/tender/:id/measure/stage/:order/update', sessionAuth, tenderCheck, stageCheck, 'stageController.updateStageData');
+    app.post('/tender/:id/measure/stage/:order/valid-change', sessionAuth, tenderCheck, stageCheck, 'stageController.searchValidChange');
+    app.post('/tender/:id/measure/stage/:order/use-change', sessionAuth, tenderCheck, stageCheck, 'stageController.useChange');
+    app.post('/tender/:id/measure/stage/:order/check', sessionAuth, tenderCheck, stageCheck, 'stageController.check');
 
     // 计量附件
-    app.post('/tender/:id/measure/stage/:order/upload/file', sessionAuth, tenderCheck, stageCheck, 'stageController.uploadFile')
-    app.get('/tender/:id/measure/stage/:order/download/file/:fid', sessionAuth, 'stageController.downloadFile')
-    app.post('/tender/:id/measure/stage/:order/delete/file', sessionAuth, tenderCheck, stageCheck, 'stageController.deleteFile')
-    app.post('/tender/:id/measure/stage/:order/save/file', sessionAuth, tenderCheck, stageCheck, 'stageController.saveFile')
-    app.post('/tender/:id/measure/stage/:order/check/file', sessionAuth, tenderCheck, stageCheck, 'stageController.checkFile')
+    app.post('/tender/:id/measure/stage/:order/upload/file', sessionAuth, tenderCheck, stageCheck, 'stageController.uploadFile');
+    app.get('/tender/:id/measure/stage/:order/download/file/:fid', sessionAuth, 'stageController.downloadFile');
+    app.post('/tender/:id/measure/stage/:order/delete/file', sessionAuth, tenderCheck, stageCheck, 'stageController.deleteFile');
+    app.post('/tender/:id/measure/stage/:order/save/file', sessionAuth, tenderCheck, stageCheck, 'stageController.saveFile');
+    app.post('/tender/:id/measure/stage/:order/check/file', sessionAuth, tenderCheck, stageCheck, 'stageController.checkFile');
 
     // 中间计量
-    app.get('/tender/:id/measure/stage/:order/detail', sessionAuth, tenderCheck, stageCheck, 'stageController.detail')
-    app.post('/tender/:id/measure/stage/:order/detail/build', sessionAuth, tenderCheck, stageCheck, 'stageController.buildDetailData')
-    app.post('/tender/:id/measure/stage/:order/detail/adv', sessionAuth, tenderCheck, stageCheck, 'stageController.setAdvancedConfig')
-    app.post('/tender/:id/measure/stage/:order/detail/load', sessionAuth, tenderCheck, stageCheck, 'stageController.loadDetailRelaData')
-    app.post('/tender/:id/measure/stage/:order/detail/save', sessionAuth, tenderCheck, stageCheck, 'stageController.saveDetailData')
-    app.post('/tender/:id/measure/stage/:order/detail/add-img', sessionAuth, tenderCheck, stageCheck, 'stageController.addCalcImage')
-    app.post('/tender/:id/measure/stage/:order/detail/merge-img', sessionAuth, tenderCheck, stageCheck, 'stageController.mergeCalcImage')
+    app.get('/tender/:id/measure/stage/:order/detail', sessionAuth, tenderCheck, stageCheck, 'stageController.detail');
+    app.post('/tender/:id/measure/stage/:order/detail/build', sessionAuth, tenderCheck, stageCheck, 'stageController.buildDetailData');
+    app.post('/tender/:id/measure/stage/:order/detail/adv', sessionAuth, tenderCheck, stageCheck, 'stageController.setAdvancedConfig');
+    app.post('/tender/:id/measure/stage/:order/detail/load', sessionAuth, tenderCheck, stageCheck, 'stageController.loadDetailRelaData');
+    app.post('/tender/:id/measure/stage/:order/detail/save', sessionAuth, tenderCheck, stageCheck, 'stageController.saveDetailData');
+    app.post('/tender/:id/measure/stage/:order/detail/add-img', sessionAuth, tenderCheck, stageCheck, 'stageController.addCalcImage');
+    app.post('/tender/:id/measure/stage/:order/detail/merge-img', sessionAuth, tenderCheck, stageCheck, 'stageController.mergeCalcImage');
 
     // 合同支付
-    app.get('/tender/:id/measure/stage/:order/pay', sessionAuth, tenderCheck, stageCheck, 'stageController.pay')
-    app.post('/tender/:id/measure/stage/:order/pay/detail', sessionAuth, tenderCheck, stageCheck, 'stageController.chapterDetail')
-    app.post('/tender/:id/measure/stage/:order/pay/save', sessionAuth, tenderCheck, stageCheck, 'stageController.savePayData')
-    app.post('/tender/:id/measure/stage/:order/pay/upload/file', sessionAuth, tenderCheck, stageCheck, 'stageController.payUploadFile')
-    app.get('/tender/:id/measure/stage/:order/pay/download/file/:pid/:index', sessionAuth, 'stageController.payDownloadFile')
-    app.post('/tender/:id/measure/stage/:order/pay/delete/file', sessionAuth, tenderCheck, stageCheck, 'stageController.payDeleteFile')
+    app.get('/tender/:id/measure/stage/:order/pay', sessionAuth, tenderCheck, stageCheck, 'stageController.pay');
+    app.post('/tender/:id/measure/stage/:order/pay/detail', sessionAuth, tenderCheck, stageCheck, 'stageController.chapterDetail');
+    app.post('/tender/:id/measure/stage/:order/pay/save', sessionAuth, tenderCheck, stageCheck, 'stageController.savePayData');
+    app.post('/tender/:id/measure/stage/:order/pay/upload/file', sessionAuth, tenderCheck, stageCheck, 'stageController.payUploadFile');
+    app.get('/tender/:id/measure/stage/:order/pay/download/file/:pid/:index', sessionAuth, 'stageController.payDownloadFile');
+    app.post('/tender/:id/measure/stage/:order/pay/delete/file', sessionAuth, tenderCheck, stageCheck, 'stageController.payDeleteFile');
 
     // 变更概况
-    app.get('/tender/:id/measure/stage/:order/change', sessionAuth, tenderCheck, stageCheck, 'stageController.change')
-    app.post('/tender/:id/measure/stage/:order/change/data', sessionAuth, tenderCheck, stageCheck, 'stageController.getChangeData')
-    app.post('/tender/:id/measure/stage/:order/change/detail', sessionAuth, tenderCheck, stageCheck, 'stageController.changeDetail')
+    app.get('/tender/:id/measure/stage/:order/change', sessionAuth, tenderCheck, stageCheck, 'stageController.change');
+    app.post('/tender/:id/measure/stage/:order/change/data', sessionAuth, tenderCheck, stageCheck, 'stageController.getChangeData');
+    app.post('/tender/:id/measure/stage/:order/change/detail', sessionAuth, tenderCheck, stageCheck, 'stageController.changeDetail');
 
     // 审批
-    app.post('/tender/:id/measure/stage/:order/audit/add', sessionAuth, tenderCheck, stageCheck, 'stageController.addAudit')
-    app.post('/tender/:id/measure/stage/:order/audit/delete', sessionAuth, tenderCheck, stageCheck, 'stageController.deleteAudit')
-    app.post('/tender/:id/measure/stage/:order/audit/start', sessionAuth, tenderCheck, stageCheck, 'stageController.startAudit')
-    app.post('/tender/:id/measure/stage/:order/audit/check', sessionAuth, tenderCheck, stageCheck, 'stageController.checkAudit')
-    app.get('/tender/:id/measure/stage/:order/audit/check/again', sessionAuth, tenderCheck, stageCheck, 'stageController.checkAuditAgain')
+    app.post('/tender/:id/measure/stage/:order/audit/add', sessionAuth, tenderCheck, stageCheck, 'stageController.addAudit');
+    app.post('/tender/:id/measure/stage/:order/audit/delete', sessionAuth, tenderCheck, stageCheck, 'stageController.deleteAudit');
+    app.post('/tender/:id/measure/stage/:order/audit/start', sessionAuth, tenderCheck, stageCheck, 'stageController.startAudit');
+    app.post('/tender/:id/measure/stage/:order/audit/check', sessionAuth, tenderCheck, stageCheck, 'stageController.checkAudit');
+    app.get('/tender/:id/measure/stage/:order/audit/check/again', sessionAuth, tenderCheck, stageCheck, 'stageController.checkAuditAgain');
 
     // 部位台账
-    app.get('/tender/:id/measure/stage/:order/bwtz', sessionAuth, tenderCheck, stageCheck, 'stageController.bwtz')
-    app.post('/tender/:id/measure/stage/:order/bwtz/load', sessionAuth, tenderCheck, stageCheck, 'stageController.loadBwtz')
+    app.get('/tender/:id/measure/stage/:order/bwtz', sessionAuth, tenderCheck, stageCheck, 'stageController.bwtz');
+    app.post('/tender/:id/measure/stage/:order/bwtz/load', sessionAuth, tenderCheck, stageCheck, 'stageController.loadBwtz');
 
     // 清单汇总
-    app.get('/tender/:id/measure/stage/:order/gather', sessionAuth, tenderCheck, stageCheck, 'stageController.gather')
+    app.get('/tender/:id/measure/stage/:order/gather', sessionAuth, tenderCheck, stageCheck, 'stageController.gather');
 
     // 审核比较
-    app.get('/tender/:id/measure/stage/:order/compare', sessionAuth, tenderCheck, stageCheck, 'stageController.compare')
-    app.post('/tender/:id/measure/stage/:order/compare/load', sessionAuth, tenderCheck, stageCheck, 'stageController.compareAuditor')
+    app.get('/tender/:id/measure/stage/:order/compare', sessionAuth, tenderCheck, stageCheck, 'stageController.compare');
+    app.post('/tender/:id/measure/stage/:order/compare/load', sessionAuth, tenderCheck, stageCheck, 'stageController.compareAuditor');
 
     // 附加功能
-    app.get('/tender/:id/measure/stage/:order/extra/jgcl', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.jgcl')
-    app.post('/tender/:id/measure/stage/:order/extra/jgcl/load', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.loadJgcl')
-    app.post('/tender/:id/measure/stage/:order/extra/jgcl/update', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.updateJgcl')
-    app.get('/tender/:id/measure/stage/:order/extra/bonus', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.bonus')
-    app.post('/tender/:id/measure/stage/:order/extra/bonus/load', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.loadBonus')
-    app.post('/tender/:id/measure/stage/:order/extra/bonus/update', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.updateBonus')
-    app.get('/tender/:id/measure/stage/:order/extra/other', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.other')
-    app.post('/tender/:id/measure/stage/:order/extra/other/load', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.loadOther')
-    app.post('/tender/:id/measure/stage/:order/extra/other/update', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.updateOther')
-    app.post('/tender/:id/measure/stage/:order/extra/upload/file', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.uploadFile')
-    app.get('/tender/:id/measure/stage/:order/extra/download/file', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.downloadFile')
-    app.post('/tender/:id/measure/stage/:order/extra/delete/file', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.deleteFile')
+    app.get('/tender/:id/measure/stage/:order/extra/jgcl', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.jgcl');
+    app.post('/tender/:id/measure/stage/:order/extra/jgcl/load', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.loadJgcl');
+    app.post('/tender/:id/measure/stage/:order/extra/jgcl/update', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.updateJgcl');
+    app.get('/tender/:id/measure/stage/:order/extra/bonus', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.bonus');
+    app.post('/tender/:id/measure/stage/:order/extra/bonus/load', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.loadBonus');
+    app.post('/tender/:id/measure/stage/:order/extra/bonus/update', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.updateBonus');
+    app.get('/tender/:id/measure/stage/:order/extra/other', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.other');
+    app.post('/tender/:id/measure/stage/:order/extra/other/load', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.loadOther');
+    app.post('/tender/:id/measure/stage/:order/extra/other/update', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.updateOther');
+    app.post('/tender/:id/measure/stage/:order/extra/upload/file', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.uploadFile');
+    app.get('/tender/:id/measure/stage/:order/extra/download/file', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.downloadFile');
+    app.post('/tender/:id/measure/stage/:order/extra/delete/file', sessionAuth, tenderCheck, stageCheck, 'stageExtraController.deleteFile');
 
     // 期审批管理
-    app.get('/tender/:id/measure/stage/:order/manager', sessionAuth, tenderCheck, stageCheck, 'stageController.manager')
-    app.post('/tender/:id/measure/stage/:order/manager/audit/delete', sessionAuth, tenderCheck, stageCheck, 'stageController.managerAuditDelete')
+    app.get('/tender/:id/measure/stage/:order/manager', sessionAuth, tenderCheck, stageCheck, 'stageController.manager');
+    app.post('/tender/:id/measure/stage/:order/manager/audit/delete', sessionAuth, tenderCheck, stageCheck, 'stageController.managerAuditDelete');
 
     // 报表
-    app.get('/tender/:id/report', sessionAuth, tenderCheck, 'reportController.index')
-    app.get('/tender/:id/measure/stage/:order/report', sessionAuth, tenderCheck, stageCheck, 'reportController.index')
-    app.get('/printReport/:size', sessionAuth, 'reportController.showPrintPage')
-    app.post('/tender/report_api/getReport', sessionAuth, 'reportController.getReport')
-    app.post('/tender/report_api/getMultiReports', sessionAuth, 'reportController.getMultiReportsEx')
-    app.post('/tender/report_api/createExcelFiles', sessionAuth, 'reportController.createExcelFilesEx')
-    app.post('/tender/report_api/createExcelFilesInOneBook', sessionAuth, 'reportController.createExcelFilesInOneBookEx')
-    app.get('/getFileByUUID/:uuid/:rptName/:suffix', sessionAuth, 'reportController.getFileByUUID')
+    app.get('/tender/:id/report', sessionAuth, tenderCheck, 'reportController.index');
+    app.get('/tender/:id/measure/stage/:order/report', sessionAuth, tenderCheck, stageCheck, 'reportController.index');
+    app.get('/printReport/:size', sessionAuth, 'reportController.showPrintPage');
+    app.post('/tender/report_api/getReport', sessionAuth, 'reportController.getReport');
+    app.post('/tender/report_api/getMultiReports', sessionAuth, 'reportController.getMultiReportsEx');
+    app.post('/tender/report_api/createExcelFiles', sessionAuth, 'reportController.createExcelFilesEx');
+    app.post('/tender/report_api/createExcelFilesInOneBook', sessionAuth, 'reportController.createExcelFilesInOneBookEx');
+    app.get('/getFileByUUID/:uuid/:rptName/:suffix', sessionAuth, 'reportController.getFileByUUID');
     // rptRouter.get('/getFileByUUID/:uuid/:rptName/:suffix', reportController.getFileByUUID);
-    app.post('/tender/report_api/createSignatureRole', sessionAuth, 'signatureController.createSignatureRole')
-    app.post('/tender/report_api/updateSignatureUsed', sessionAuth, datetimeFill, 'signatureController.updateSignatureUsed')
-    app.post('/tender/report_api/updateRoleRelationship', sessionAuth, 'signatureController.updateRoleRel')
-    app.post('/tender/report_api/createRoleRelationship', sessionAuth, 'signatureController.createRoleRel')
-    app.post('/tender/report_api/updateCustNode', sessionAuth, 'reportController.updateCustNode')
-    app.post('/report/cDefine', sessionAuth, 'reportController.setCustomDefine')
+    app.post('/tender/report_api/createSignatureRole', sessionAuth, 'signatureController.createSignatureRole');
+    app.post('/tender/report_api/updateSignatureUsed', sessionAuth, datetimeFill, 'signatureController.updateSignatureUsed');
+    app.post('/tender/report_api/updateRoleRelationship', sessionAuth, 'signatureController.updateRoleRel');
+    app.post('/tender/report_api/createRoleRelationship', sessionAuth, 'signatureController.createRoleRel');
+    app.post('/tender/report_api/updateCustNode', sessionAuth, 'reportController.updateCustNode');
+    app.post('/report/cDefine', sessionAuth, 'reportController.setCustomDefine');
 
     // 变更管理
-    app.get('/tender/:id/change', sessionAuth, tenderCheck, 'changeController.index')
-    app.get('/tender/:id/change/status/:status', sessionAuth, tenderCheck, 'changeController.status')
-    app.post('/tender/:id/change/newCode', sessionAuth, tenderCheck, 'changeController.newCode')
-    app.post('/tender/:id/change/add', sessionAuth, tenderCheck, 'changeController.add')
-    app.post('/tender/:id/change/defaultBills', sessionAuth, tenderCheck, 'changeController.defaultBills')
-    app.get('/tender/:id/change/:cid/info', sessionAuth, tenderCheck, 'changeController.info')
-    app.post('/change/upload/file', sessionAuth, 'changeController.uploadFile')
-    app.get('/change/download/file/:id', sessionAuth, 'changeController.downloadFile')
-    app.post('/change/delete/file', sessionAuth, 'changeController.deleteFile')
-    app.post('/tender/:id/change/delete', sessionAuth, tenderCheck, 'changeController.delete')
-    app.post('/tender/:id/change/bills', sessionAuth, tenderCheck, 'changeController.bills')
+    app.get('/tender/:id/change', sessionAuth, tenderCheck, 'changeController.index');
+    app.get('/tender/:id/change/status/:status', sessionAuth, tenderCheck, 'changeController.status');
+    app.post('/tender/:id/change/newCode', sessionAuth, tenderCheck, 'changeController.newCode');
+    app.post('/tender/:id/change/add', sessionAuth, tenderCheck, 'changeController.add');
+    app.post('/tender/:id/change/defaultBills', sessionAuth, tenderCheck, 'changeController.defaultBills');
+    app.get('/tender/:id/change/:cid/info', sessionAuth, tenderCheck, 'changeController.info');
+    app.post('/change/upload/file', sessionAuth, 'changeController.uploadFile');
+    app.get('/change/download/file/:id', sessionAuth, 'changeController.downloadFile');
+    app.post('/change/delete/file', sessionAuth, 'changeController.deleteFile');
+    app.post('/tender/:id/change/delete', sessionAuth, tenderCheck, 'changeController.delete');
+    app.post('/tender/:id/change/bills', sessionAuth, tenderCheck, 'changeController.bills');
 
-    app.post('/tender/:id/change/save', sessionAuth, tenderCheck, 'changeController.save')
+    app.post('/tender/:id/change/save', sessionAuth, tenderCheck, 'changeController.save');
 
-    app.post('/tender/:id/change/approval', sessionAuth, tenderCheck, 'changeController.approval')
-    app.post('/tender/:id/change/check/again', sessionAuth, tenderCheck, 'changeController.checkAgain')
+    app.post('/tender/:id/change/approval', sessionAuth, tenderCheck, 'changeController.approval');
+    app.post('/tender/:id/change/check/again', sessionAuth, tenderCheck, 'changeController.checkAgain');
 
-    app.post('/tender/:id/change/:cid/check/codeRepeat', sessionAuth, tenderCheck, 'changeController.checkCodeRepeat')
+    app.post('/tender/:id/change/:cid/check/codeRepeat', sessionAuth, tenderCheck, 'changeController.checkCodeRepeat');
 
     // 变更单位管理
-    app.post('/change/update/company', sessionAuth, 'changeController.updateCompany')
+    app.post('/change/update/company', sessionAuth, 'changeController.updateCompany');
 
     // 材料调差
-    app.get('/tender/:id/measure/material', sessionAuth, tenderCheck, 'materialController.index')
-    app.post('/tender/:id/measure/material/add', sessionAuth, tenderCheck, 'materialController.add')
-    app.post('/tender/:id/measure/material/delete', sessionAuth, tenderCheck, 'materialController.delete')
-    app.post('/tender/:id/measure/material/auditors', sessionAuth, tenderCheck, 'materialController.materialAuditors')
+    app.get('/tender/:id/measure/material', sessionAuth, tenderCheck, 'materialController.index');
+    app.post('/tender/:id/measure/material/add', sessionAuth, tenderCheck, 'materialController.add');
+    app.post('/tender/:id/measure/material/delete', sessionAuth, tenderCheck, 'materialController.delete');
+    app.post('/tender/:id/measure/material/auditors', sessionAuth, tenderCheck, 'materialController.materialAuditors');
     // 审批
-    app.post('/tender/:id/measure/material/:order/audit/add', sessionAuth, tenderCheck, materialCheck, 'materialController.addAudit')
-    app.post('/tender/:id/measure/material/:order/audit/delete', sessionAuth, tenderCheck, materialCheck, 'materialController.deleteAudit')
-    app.post('/tender/:id/measure/material/:order/audit/start', sessionAuth, tenderCheck, materialCheck, 'materialController.startAudit')
-    app.post('/tender/:id/measure/material/:order/audit/check', sessionAuth, tenderCheck, materialCheck, 'materialController.checkAudit')
+    app.post('/tender/:id/measure/material/:order/audit/add', sessionAuth, tenderCheck, materialCheck, 'materialController.addAudit');
+    app.post('/tender/:id/measure/material/:order/audit/delete', sessionAuth, tenderCheck, materialCheck, 'materialController.deleteAudit');
+    app.post('/tender/:id/measure/material/:order/audit/start', sessionAuth, tenderCheck, materialCheck, 'materialController.startAudit');
+    app.post('/tender/:id/measure/material/:order/audit/check', sessionAuth, tenderCheck, materialCheck, 'materialController.checkAudit');
     // 调差工料
-    app.get('/tender/:id/measure/material/:order', sessionAuth, tenderCheck, materialCheck, 'materialController.info')
-    app.post('/tender/:id/measure/material/:order/save', sessionAuth, tenderCheck, materialCheck, 'materialController.saveBillsData')
+    app.get('/tender/:id/measure/material/:order', sessionAuth, tenderCheck, materialCheck, 'materialController.info');
+    app.post('/tender/:id/measure/material/:order/save', sessionAuth, tenderCheck, materialCheck, 'materialController.saveBillsData');
     // 调差清单
-    app.get('/tender/:id/measure/material/:order/list', sessionAuth, tenderCheck, materialCheck, 'materialController.list')
-    app.post('/tender/:id/measure/material/:order/list/save', sessionAuth, tenderCheck, materialCheck, 'materialController.saveListsData')
+    app.get('/tender/:id/measure/material/:order/list', sessionAuth, tenderCheck, materialCheck, 'materialController.list');
+    app.post('/tender/:id/measure/material/:order/list/save', sessionAuth, tenderCheck, materialCheck, 'materialController.saveListsData');
 
     // 附件
-    app.get('/tender/:id/measure/material/:order/file', sessionAuth, tenderCheck, materialCheck, 'materialController.file')
-    app.post('/tender/:id/measure/material/:order/file/upload', sessionAuth, tenderCheck, materialCheck, 'materialController.upload')
-    app.post('/tender/:id/measure/material/:order/file/find', sessionAuth, tenderCheck, materialCheck, 'materialController.getCurMatericalFiles')
-    app.post('/tender/measure/material/file/delete', sessionAuth, 'materialController.deleteFile')
+    app.get('/tender/:id/measure/material/:order/file', sessionAuth, tenderCheck, materialCheck, 'materialController.file');
+    app.post('/tender/:id/measure/material/:order/file/upload', sessionAuth, tenderCheck, materialCheck, 'materialController.upload');
+    app.post('/tender/:id/measure/material/:order/file/find', sessionAuth, tenderCheck, materialCheck, 'materialController.getCurMatericalFiles');
+    app.post('/tender/measure/material/file/delete', sessionAuth, 'materialController.deleteFile');
 
     // 个人账号相关
-    app.get('/profile/info', sessionAuth, 'profileController.info')
-    app.get('/profile/sms', sessionAuth, 'profileController.sms')
-    app.post('/profile/sms/type', sessionAuth, 'profileController.smsType')
-    app.get('/profile/sign', sessionAuth, 'profileController.sign')
-    app.post('/profile/sign/delete', sessionAuth, 'profileController.signDelete')
-    app.post('/profile/sign/upload', sessionAuth, 'profileController.signUpload')
-    app.get('/profile/safe', sessionAuth, 'profileController.safe')
-    app.post('/profile/save', sessionAuth, 'profileController.saveBase')
-    app.post('/profile/password', sessionAuth, 'profileController.modifyPassword')
-    app.post('/profile/code', sessionAuth, 'profileController.getCode')
-    app.post('/profile/bind', sessionAuth, 'profileController.bindMobile')
-    app.get('/profile/qrCode', sessionAuth, 'profileController.qrCode')
-    app.get('/profile/wechat', sessionAuth, 'profileController.wechat')
-    app.post('/profile/wechat/remove', sessionAuth, 'profileController.removeWechat')
+    app.get('/profile/info', sessionAuth, 'profileController.info');
+    app.get('/profile/sms', sessionAuth, 'profileController.sms');
+    app.post('/profile/sms/type', sessionAuth, 'profileController.smsType');
+    app.get('/profile/sign', sessionAuth, 'profileController.sign');
+    app.post('/profile/sign/delete', sessionAuth, 'profileController.signDelete');
+    app.post('/profile/sign/upload', sessionAuth, 'profileController.signUpload');
+    app.get('/profile/safe', sessionAuth, 'profileController.safe');
+    app.post('/profile/save', sessionAuth, 'profileController.saveBase');
+    app.post('/profile/password', sessionAuth, 'profileController.modifyPassword');
+    app.post('/profile/code', sessionAuth, 'profileController.getCode');
+    app.post('/profile/bind', sessionAuth, 'profileController.bindMobile');
+    app.get('/profile/qrCode', sessionAuth, 'profileController.qrCode');
+    app.get('/profile/wechat', sessionAuth, 'profileController.wechat');
+    app.post('/profile/wechat/remove', sessionAuth, 'profileController.removeWechat');
 
     // 标准库相关
-    app.post('/std-lib/get-data', sessionAuth, 'standardLibController.getData')
+    app.post('/std-lib/get-data', sessionAuth, 'standardLibController.getData');
 
     // 查询
-    app.post('/search/user', sessionAuth, 'projectController.searchAccount')
+    app.post('/search/user', sessionAuth, 'projectController.searchAccount');
 
     // 示例
-    app.get('/template/:file', sessionAuth, 'templateController.download')
+    app.get('/template/:file', sessionAuth, 'templateController.download');
 
     // 标段对比
-    app.get('/compare/tz', sessionAuth, 'spssController.compareTz')
-    app.post('/compare/tz/load', sessionAuth, 'spssController.loadCompareTz')
-    app.get('/compare/stage', sessionAuth, 'spssController.compareStage')
-    app.post('/compare/stage/load', sessionAuth, 'spssController.loadCompareStage')
-    app.get('/gather/tz', sessionAuth, 'spssController.gatherTz')
-    app.post('/gather/tz/load', sessionAuth, 'spssController.loadGatherTz')
-    app.get('/gather/stage', sessionAuth, 'spssController.gatherStage')
-    app.post('/gather/stage/load', sessionAuth, 'spssController.loadGatherStage')
-    app.get('/tools/check-tz', sessionAuth, 'spssController.checkTz')
-    app.post('/tools/load', sessionAuth, 'spssController.loadBaseData')
+    app.get('/compare/tz', sessionAuth, 'spssController.compareTz');
+    app.post('/compare/tz/load', sessionAuth, 'spssController.loadCompareTz');
+    app.get('/compare/stage', sessionAuth, 'spssController.compareStage');
+    app.post('/compare/stage/load', sessionAuth, 'spssController.loadCompareStage');
+    app.get('/gather/tz', sessionAuth, 'spssController.gatherTz');
+    app.post('/gather/tz/load', sessionAuth, 'spssController.loadGatherTz');
+    app.get('/gather/stage', sessionAuth, 'spssController.gatherStage');
+    app.post('/gather/stage/load', sessionAuth, 'spssController.loadGatherStage');
+    app.get('/tools/check-tz', sessionAuth, 'spssController.checkTz');
+    app.post('/tools/load', sessionAuth, 'spssController.loadBaseData');
 
     // wap页面
-    app.get('/wap', 'wapController.index')
-    app.get('/wap/login', 'wapController.index')
-    app.post('/wap/login', 'wapController.login')
-    app.get('/wap/logout', 'wapController.logout')
-    app.get('/wap/dashboard', sessionAuth, 'wapController.dashboard')
-    app.get('/wap/list', sessionAuth, 'wapController.list')
-    app.get('/wap/tender/:id', sessionAuth, tenderCheck, 'wapController.tender')
-    app.get('/wap/tender/:id/stage/:order', sessionAuth, tenderCheck, 'wapController.stage')
-    app.get('/wap/tender/:id/change/:cid/info', sessionAuth, tenderCheck, 'wapController.change')
-    app.post('/wap/tender/:id/change/approval', sessionAuth, tenderCheck, 'wapController.changeApproval')
+    app.get('/wap', 'wapController.index');
+    app.get('/wap/login', 'wapController.index');
+    app.post('/wap/login', 'wapController.login');
+    app.get('/wap/logout', 'wapController.logout');
+    app.get('/wap/dashboard', sessionAuth, 'wapController.dashboard');
+    app.get('/wap/list', sessionAuth, 'wapController.list');
+    app.get('/wap/tender/:id', sessionAuth, tenderCheck, 'wapController.tender');
+    app.get('/wap/tender/:id/stage/:order', sessionAuth, tenderCheck, 'wapController.stage');
+    app.get('/wap/tender/:id/change/:cid/info', sessionAuth, tenderCheck, 'wapController.change');
+    app.post('/wap/tender/:id/change/approval', sessionAuth, tenderCheck, 'wapController.changeApproval');
 
     // 微信
     app.get('/wx', 'wechatController.index');
@@ -390,4 +390,4 @@ module.exports = app => {
     app.get('/wx/project', wechatAuth, 'wechatController.project');
     app.get('/wx/test', 'wechatController.testwx');
     app.get('/MP_verify_t3MkWAMqplVxPjmr.txt', 'wechatController.oauthTxt');
-}
+};

+ 14 - 10
app/service/advance.js

@@ -27,6 +27,20 @@ module.exports = app => {
             this.sqlBuilder.orderBy = [['order', 'desc']]
             const [sql, sqlParam] = this.sqlBuilder.build(this.tableName)
             const advance = await this.db.query(sql, sqlParam)
+            for (const item of advance) {
+                item.curAuditor = await this.ctx.service.advanceAudit.getAuditorByStatus(item.id, item.status, item.times)
+                if (item.status === auditConst.status.checkNoPre) {
+                    item.curAuditor2 = await this.ctx.service.advanceAudit.getAuditorByStatus(item.id, auditConst.status.checking)
+                }
+            }
+            // const newRecord = advance.map(async item => {
+            //     item.curAuditor = await this.ctx.service.advanceAudit.getAuditorByStatus(item.id, item.status, item.times)
+            //     if (item.status === auditConst.status.checkNoPre) {
+            //         item.curAuditor2 = await this.ctx.service.advanceAudit.getAuditorByStatus(item.id, auditConst.status.checking)
+            //     }
+            //     return item
+            // })
+            // console.log('newRecord', newRecord)
             return advance
         }
 
@@ -93,16 +107,6 @@ module.exports = app => {
             const [sql, sqlParam] = this.sqlBuilder.build(this.tableName)
             return await this.db.queryOne(sql, sqlParam)
         }
-
-        // /**
-        //  * 更新预付款记录
-        //  * @param {Object} data 载荷
-        //  * @param {Number} id 预付款id
-        //  */
-        // async updateAdvance(data, id) {
-        //     const result = await this.db.update(this.tableName, data, { where: { id } })
-        //     console.log(result)
-        // }
     }
     return Advance
 }

+ 43 - 6
app/service/advance_audit.js

@@ -146,7 +146,7 @@ module.exports = app => {
          */
         async getCurAuditor(vid, times = 1) {
             const sql =
-                'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
+                'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`order`, la.`status`, la.`opinion`, la.`create_time`, la.`end_time` ' +
                 'FROM ?? AS la, ?? AS pa ' +
                 'WHERE la.`vid` = ? and la.`status` = ? and la.`times` = ?' +
                 '    and la.`audit_id` = pa.`id`'
@@ -162,7 +162,7 @@ module.exports = app => {
          */
         async getAuditors(vid, times = 1) {
             const sql =
-                'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time`, g.`sort` ' +
+                'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`order`, la.`status`, la.`opinion`, la.`create_time`, la.`end_time`, g.`sort` ' +
                 'FROM ?? AS la, ?? AS pa, (SELECT `audit_id`,(@i:=@i+1) as `sort` FROM ??, (select @i:=0) as it WHERE `vid` = ? AND `times` = ? GROUP BY `audit_id`) as g ' +
                 'WHERE la.`vid` = ? and la.`times` = ? and la.`audit_id` = pa.`id` and g.`audit_id` = la.`audit_id` order by la.`order`'
             const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, this.tableName, vid, times, vid, times]
@@ -185,7 +185,7 @@ module.exports = app => {
          */
         async getAuditor(vid, audit_id, times = 1) {
             const sql =
-                'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
+                'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`order`, la.`status`, la.`opinion`, la.`create_time`, la.`end_time` ' +
                 'FROM ?? AS la, ?? AS pa ' +
                 'WHERE la.`vid` = ? and la.`audit_id` = ? and la.`times` = ?' +
                 '    and la.`audit_id` = pa.`id`'
@@ -206,7 +206,7 @@ module.exports = app => {
             }
             const transaction = await this.db.beginTransaction()
             try {
-                await transaction.update(this.tableName, { id: audit.id, status: auditConst.status.checking, begin_time: new Date() })
+                await transaction.update(this.tableName, { id: audit.id, status: auditConst.status.checking, create_time: new Date() })
                 await transaction.update(this.ctx.service.advance.tableName, {
                     id: audit.vid,
                     ...data
@@ -249,7 +249,7 @@ module.exports = app => {
                 // 无下一审核人表示,审核结束
                 if (nextAudit) {
                     // 流程至下一审批人
-                    await transaction.update(this.tableName, { id: nextAudit.id, status: auditConst.status.checking, begin_time: time })
+                    await transaction.update(this.tableName, { id: nextAudit.id, status: auditConst.status.checking, create_time: time })
 
                     // 同步期信息
                     await transaction.update(this.ctx.service.advance.tableName, {
@@ -351,7 +351,7 @@ module.exports = app => {
                     times: audit.times,
                     order: audit.order + 1,
                     status: auditConst.status.checking,
-                    begin_time: time
+                    create_time: time
                 })
                 newAuditors.push({
                     tid: audit.tid,
@@ -426,6 +426,43 @@ module.exports = app => {
             const content = await this.db.query(noticeSql, noticeSqlParam)
             return content.length ? JSON.stringify(content[0]) : ''
         }
+
+        /**
+         * 通过状态获取审核人信息
+         * @param {Number} vid - 预付款id
+         * @param {Number} status - 期状态
+         * @param {Number} times - 审批次数
+         * @return {Object} auditor 审核人信息
+         */
+        async getAuditorByStatus(vid, status, times = 1) {
+            let auditor = null
+            let sql = ''
+            let sqlParam = ''
+            switch (status) {
+                case auditConst.status.checking:
+                case auditConst.status.checked:
+                case auditConst.status.checkNoPre:
+                    sql =
+                        'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`vid`, la.`order` ' +
+                        'FROM ?? AS la, ?? AS pa ' +
+                        'WHERE la.`vid` = ? and la.`status` = ? and la.`audit_id` = pa.`id` order by la.`times` desc, la.`order` desc'
+                    sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, vid, status]
+                    auditor = await this.db.queryOne(sql, sqlParam)
+                    break
+                case auditConst.status.checkNo:
+                    sql =
+                        'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`vid`, la.`order` ' +
+                        'FROM ?? AS la, ?? AS pa ' +
+                        'WHERE la.`vid` = ? and la.`status` = ? and la.`times` = ? and la.`audit_id` = pa.`id` order by la.`times` desc, la.`order` desc'
+                    sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, vid, auditConst.status.checkNo, parseInt(times) - 1]
+                    auditor = await this.db.queryOne(sql, sqlParam)
+                    break
+                case auditConst.status.uncheck:
+                default:
+                    break
+            }
+            return auditor
+        }
     }
     return AdvanceAudit
 }

Разница между файлами не показана из-за своего большого размера
+ 432 - 432
app/service/change.js


+ 1 - 1
app/service/change_att.js

@@ -42,7 +42,7 @@ module.exports = app => {
         /**
          * 获取 变更令 所有附件
          * @param {uuid} cid - 变更令id
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async getChangeAttachment(cid) {
             const sql = 'SELECT ca.*, pa.name As u_name, pa.role As u_role ' +

+ 6 - 7
app/service/change_audit.js

@@ -308,21 +308,20 @@ module.exports = app => {
             //             '  ORDER BY new_t.`cu_time`';
             // const sqlParam = [this.ctx.service.tender.tableName, uid, this.tableName, uid, this.ctx.service.change.tableName, this.tableName, pid, time, audit.flow.status.checking];
             // return await this.db.query(sql, sqlParam);
-            let notice =  await this.db.select('zh_notice', {
+            let notice = await this.db.select('zh_notice', {
                 where: { pid, type: pushType.change, uid },
                 orders: [['create_time', 'desc']],
-                limit: 10, offset: 0
+                limit: 10, offset: 0,
             });
             notice = notice.map(v => {
-                const extra = JSON.parse(v.content)
-                delete v.content
-                return { ...v, ...extra }
-            })
+                const extra = JSON.parse(v.content);
+                delete v.content;
+                return { ...v, ...extra };
+            });
             return notice;
         }
 
 
-
         async getAllAuditors(tenderId) {
             const sql = 'SELECT ca.uid, ca.tid FROM ' + this.tableName + ' ca' +
                 '  LEFT JOIN ' + this.ctx.service.tender.tableName + ' t On ca.tid = t.id' +

+ 1 - 1
app/service/change_audit_list.js

@@ -23,7 +23,7 @@ module.exports = app => {
             this.tableName = 'change_audit_list';
         }
 
-        async gatherBgBills (tid) {
+        async gatherBgBills(tid) {
             const sql = 'SELECT cb.code, cb.name, cb.unit, cb.unit_price, Round(Sum(cb.samount + 0), 6) as quantity' +
                 '  FROM ' + this.tableName + ' cb' +
                 '  LEFT JOIN ' + this.ctx.service.change.tableName + ' c ON cb.cid = c.cid' +

+ 1 - 1
app/service/change_company.js

@@ -40,7 +40,7 @@ module.exports = app => {
                 if (updateIdArray.length !== 0) {
                     for (const index in updateIdArray) {
                         if (updateArray[index].trim() === '') {
-                            await this.transaction.delete(this.tableName, {id: updateIdArray[index]});
+                            await this.transaction.delete(this.tableName, { id: updateIdArray[index] });
                         } else {
                             const updateData = {
                                 id: updateIdArray[index],

+ 16 - 15
app/service/ledger.js

@@ -162,7 +162,7 @@ module.exports = app => {
             const [sql, sqlParam] = this.sqlBuilder.build(this.tableName);
             const data = await this.db.query(sql, sqlParam);
 
-            return this._.sortBy(data, function (d) {
+            return this._.sortBy(data, function(d) {
                 return nodesIds.indexOf(d.ledger_id);
             });
         }
@@ -226,7 +226,7 @@ module.exports = app => {
         /**
          * 获取项目工程量
          * @param tenderId
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async getGatherGclBills(tenderId) {
             const sql = 'SELECT `b_code`, `name`, `unit`, `unit_price`, ' +
@@ -276,7 +276,7 @@ module.exports = app => {
          * 删除相关数据 用于继承
          * @param mid
          * @param deleteData
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          * @private
          */
         async _deleteRelaData(mid, deleteData) {
@@ -325,7 +325,8 @@ module.exports = app => {
                 throw '复制数据错误:仅可操作同层节点';
             }
 
-            const pasteBillsData = [], pastePosData = [];
+            const pasteBillsData = [],
+                pastePosData = [];
             this.transaction = await this.db.beginTransaction();
             try {
                 // 选中节点的所有后兄弟节点,order+粘贴节点个数
@@ -339,13 +340,13 @@ module.exports = app => {
                     datas = this._.sortBy(datas, 'level');
 
                     // 计算粘贴数据中需更新部分
-                    datas.sort(function (x, y) {
+                    datas.sort(function(x, y) {
                         return x.level - y.level;
                     });
                     for (const data of datas) {
-                        data.children = datas.filter(function (x) {
+                        data.children = datas.filter(function(x) {
                             return x.ledger_pid === data.ledger_id;
-                        })
+                        });
                     }
                     for (let index = 0; index < datas.length; index++) {
                         const data = datas[index];
@@ -375,7 +376,7 @@ module.exports = app => {
                         delete data.children;
                         delete data.crid;
                         delete data.is_tp;
-                        const p = datas.find(function (x) {
+                        const p = datas.find(function(x) {
                             return x.ledger_id === data.ledger_pid;
                         });
                         if (p) {
@@ -383,7 +384,7 @@ module.exports = app => {
                         } else {
                             data.full_path = newParentPath + '' + data.ledger_id;
                         }
-                        pasteBillsData.push(data)
+                        pasteBillsData.push(data);
                     }
                     maxId = maxId + datas.length;
                 }
@@ -629,7 +630,7 @@ module.exports = app => {
          *
          * @param node
          * @param transaction
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          * @private
          */
         async calcNode(node, transaction) {
@@ -658,7 +659,7 @@ module.exports = app => {
          * @return {Promise<void>}
          */
         async calc(tid, id, transaction) {
-            const node = await transaction.get(this.tableName, {id: id});
+            const node = await transaction.get(this.tableName, { id });
             if (!node) {
                 throw '数据错误';
             }
@@ -699,7 +700,7 @@ module.exports = app => {
         /**
          * 导入Excel数据
          * @param excelData
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async importExcel(templateId, excelData) {
             const AnalysisExcel = require('../lib/analysis_excel').AnalysisExcelTree;
@@ -710,8 +711,8 @@ module.exports = app => {
             const orgMaxId = parseInt(await this.cache.get(cacheKey));
             const transaction = await this.db.beginTransaction();
             try {
-                await transaction.delete(this.tableName, {tender_id: this.ctx.tender.id});
-                await transaction.delete(this.ctx.service.pos.tableName, {tid: this.ctx.tender.id});
+                await transaction.delete(this.tableName, { tender_id: this.ctx.tender.id });
+                await transaction.delete(this.ctx.service.pos.tableName, { tid: this.ctx.tender.id });
                 const datas = [];
                 for (const node of cacheTree.items) {
                     const data = {
@@ -752,7 +753,7 @@ module.exports = app => {
                 }
                 await transaction.commit();
                 this.cache.set(cacheKey, cacheTree.keyNodeId, 'EX', this.ctx.app.config.cacheTime);
-                return {bills: datas, pos: cacheTree.pos}
+                return { bills: datas, pos: cacheTree.pos };
             } catch (err) {
                 await transaction.rollback();
                 if (orgMaxId) {

+ 138 - 138
app/service/ledger_audit.js

@@ -1,4 +1,4 @@
-'use strict'
+'use strict';
 
 /**
  * 台账审批流程表
@@ -8,11 +8,11 @@
  * @version
  */
 
-const auditConst = require('../const/audit').ledger
-const smsTypeConst = require('../const/sms_type')
-const SMS = require('../lib/sms')
-const SmsAliConst = require('../const/sms_alitemplate')
-const pushType = require('../const/audit').pushType
+const auditConst = require('../const/audit').ledger;
+const smsTypeConst = require('../const/sms_type');
+const SMS = require('../lib/sms');
+const SmsAliConst = require('../const/sms_alitemplate');
+const pushType = require('../const/audit').pushType;
 
 module.exports = app => {
     class LedgerAudit extends app.BaseService {
@@ -23,8 +23,8 @@ module.exports = app => {
          * @return {void}
          */
         constructor(ctx) {
-            super(ctx)
-            this.tableName = 'ledger_audit'
+            super(ctx);
+            this.tableName = 'ledger_audit';
         }
 
         /**
@@ -33,16 +33,16 @@ module.exports = app => {
          * @param {Number} tenderId - 标段id
          * @param {Number} auditorId - 审核人id
          * @param {Number} times - 第几次审批
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async getAuditor(tenderId, auditorId, times = 1) {
             const sql =
                 'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`audit_order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
                 'FROM ?? AS la, ?? AS pa ' +
                 'WHERE la.`tender_id` = ? and la.`audit_id` = ? and la.`times` = ?' +
-                '    and la.`audit_id` = pa.`id`'
-            const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tenderId, auditorId, times]
-            return await this.db.queryOne(sql, sqlParam)
+                '    and la.`audit_id` = pa.`id`';
+            const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tenderId, auditorId, times];
+            return await this.db.queryOne(sql, sqlParam);
         }
 
         /**
@@ -51,16 +51,16 @@ module.exports = app => {
          * @param {Number} tenderId - 标段id
          * @param {Number} auditorId - 审核人id
          * @param {Number} times - 第几次审批
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async getStatusName(tenderId, times) {
             const sql =
                 'SELECT pa.`name` ' +
                 'FROM ?? AS la, ?? AS pa ' +
                 'WHERE la.`tender_id` = ?' +
-                '    and la.`audit_id` = pa.`id` and la.`status` != ? ORDER BY la.`times` DESC, la.`audit_order` DESC'
-            const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tenderId, auditConst.status.uncheck]
-            return await this.db.queryOne(sql, sqlParam)
+                '    and la.`audit_id` = pa.`id` and la.`status` != ? ORDER BY la.`times` DESC, la.`audit_order` DESC';
+            const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tenderId, auditConst.status.uncheck];
+            return await this.db.queryOne(sql, sqlParam);
         }
 
         /**
@@ -68,22 +68,22 @@ module.exports = app => {
          *
          * @param {Number} tenderId - 标段id
          * @param {Number} times - 第几次审批
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async getAuditors(tenderId, times = 1) {
             const sql =
                 'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`audit_order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time`, g.`sort` ' +
                 'FROM ?? AS la, ?? AS pa, (SELECT `audit_id`,(@i:=@i+1) as `sort` FROM ??, (select @i:=0) as it WHERE `tender_id` = ? AND `times` = ? GROUP BY `audit_id`) as g ' +
-                'WHERE la.`tender_id` = ? and la.`times` = ? and la.`audit_id` = pa.`id` and g.`audit_id` = la.`audit_id` order by la.`audit_order`'
-            const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, this.tableName, tenderId, times, tenderId, times]
-            const result = await this.db.query(sql, sqlParam)
-            const sql2 = 'SELECT COUNT(a.`audit_id`) as num FROM (SELECT `audit_id` FROM ?? WHERE `tender_id` = ? AND `times` = ? GROUP BY `audit_id`) as a'
-            const sqlParam2 = [this.tableName, tenderId, times]
-            const count = await this.db.queryOne(sql2, sqlParam2)
+                'WHERE la.`tender_id` = ? and la.`times` = ? and la.`audit_id` = pa.`id` and g.`audit_id` = la.`audit_id` order by la.`audit_order`';
+            const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, this.tableName, tenderId, times, tenderId, times];
+            const result = await this.db.query(sql, sqlParam);
+            const sql2 = 'SELECT COUNT(a.`audit_id`) as num FROM (SELECT `audit_id` FROM ?? WHERE `tender_id` = ? AND `times` = ? GROUP BY `audit_id`) as a';
+            const sqlParam2 = [this.tableName, tenderId, times];
+            const count = await this.db.queryOne(sql2, sqlParam2);
             for (const i in result) {
-                result[i].max_sort = count.num
+                result[i].max_sort = count.num;
             }
-            return result
+            return result;
         }
 
         /**
@@ -91,16 +91,16 @@ module.exports = app => {
          *
          * @param {Number} tenderId - 标段id
          * @param {Number} times - 第几次审批
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async getCurAuditor(tenderId, times = 1) {
             const sql =
                 'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`audit_order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
                 'FROM ?? AS la, ?? AS pa ' +
                 'WHERE la.`tender_id` = ? and la.`status` = ? and la.`times` = ?' +
-                '    and la.`audit_id` = pa.`id`'
-            const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tenderId, auditConst.status.checking, times]
-            return await this.db.queryOne(sql, sqlParam)
+                '    and la.`audit_id` = pa.`id`';
+            const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tenderId, auditConst.status.checking, times];
+            return await this.db.queryOne(sql, sqlParam);
         }
 
         /**
@@ -108,13 +108,13 @@ module.exports = app => {
          *
          * @param {Number} tenderId - 标段id
          * @param {Number} times - 第几次审批
-         * @returns {Promise<number>}
+         * @return {Promise<number>}
          */
         async getNewOrder(tenderId, times = 1) {
-            const sql = 'SELECT Max(??) As max_order FROM ?? Where `tender_id` = ? and `times` = ?'
-            const sqlParam = ['audit_order', this.tableName, tenderId, times]
-            const result = await this.db.queryOne(sql, sqlParam)
-            return result && result.max_order ? result.max_order + 1 : 1
+            const sql = 'SELECT Max(??) As max_order FROM ?? Where `tender_id` = ? and `times` = ?';
+            const sqlParam = ['audit_order', this.tableName, tenderId, times];
+            const result = await this.db.queryOne(sql, sqlParam);
+            return result && result.max_order ? result.max_order + 1 : 1;
         }
 
         /**
@@ -123,19 +123,19 @@ module.exports = app => {
          * @param {Number} tenderId - 标段id
          * @param {Number} auditorId - 审核人id
          * @param {Number} times - 第几次审批
-         * @returns {Promise<number>}
+         * @return {Promise<number>}
          */
         async addAuditor(tenderId, auditorId, times = 1) {
-            const newOrder = await this.getNewOrder(tenderId, times)
+            const newOrder = await this.getNewOrder(tenderId, times);
             const data = {
                 tender_id: tenderId,
                 audit_id: auditorId,
                 times,
                 audit_order: newOrder,
-                status: auditConst.status.uncheck
-            }
-            const result = await this.db.insert(this.tableName, data)
-            return (result.effectRows = 1)
+                status: auditConst.status.uncheck,
+            };
+            const result = await this.db.insert(this.tableName, data);
+            return (result.effectRows = 1);
         }
 
         /**
@@ -144,31 +144,31 @@ module.exports = app => {
          * @param {Number} tenderId - 标段id
          * @param {Number} auditorId - 审核人id
          * @param {Number} times - 第几次审批
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          * @private
          */
         async _syncOrderByDelete(transaction, tenderId, order, times) {
-            this.initSqlBuilder()
+            this.initSqlBuilder();
             this.sqlBuilder.setAndWhere('tender_id', {
                 value: tenderId,
-                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: '-'
-            })
-            const [sql, sqlParam] = this.sqlBuilder.build(this.tableName, 'update')
-            const data = await transaction.query(sql, sqlParam)
+                selfOperate: '-',
+            });
+            const [sql, sqlParam] = this.sqlBuilder.build(this.tableName, 'update');
+            const data = await transaction.query(sql, sqlParam);
 
-            return data
+            return data;
         }
 
         /**
@@ -177,24 +177,24 @@ module.exports = app => {
          * @param {Number} tenderId - 标段id
          * @param {Number} auditorId - 审核人id
          * @param {Number} times - 第几次审批
-         * @returns {Promise<boolean>}
+         * @return {Promise<boolean>}
          */
         async deleteAuditor(tenderId, auditorId, times = 1) {
-            const transaction = await this.db.beginTransaction()
+            const transaction = await this.db.beginTransaction();
             try {
-                const condition = { tender_id: tenderId, audit_id: auditorId, times }
-                const auditor = await this.getDataByCondition(condition)
+                const condition = { tender_id: tenderId, audit_id: auditorId, times };
+                const auditor = await this.getDataByCondition(condition);
                 if (!auditor) {
-                    throw '该审核人不存在'
+                    throw '该审核人不存在';
                 }
-                await this._syncOrderByDelete(transaction, tenderId, auditor.audit_order, times)
-                await transaction.delete(this.tableName, condition)
-                await transaction.commit()
+                await this._syncOrderByDelete(transaction, tenderId, auditor.audit_order, times);
+                await transaction.delete(this.tableName, condition);
+                await transaction.commit();
             } catch (err) {
-                await transaction.rollback()
-                throw err
+                await transaction.rollback();
+                throw err;
             }
-            return true
+            return true;
         }
 
         /**
@@ -202,40 +202,40 @@ module.exports = app => {
          *
          * @param {Number} tenderId - 标段id
          * @param {Number} times - 第几次审批
-         * @returns {Promise<boolean>}
+         * @return {Promise<boolean>}
          */
         async start(tenderId, times = 1) {
-            const audit = await this.getDataByCondition({ tender_id: tenderId, times, audit_order: 1 })
+            const audit = await this.getDataByCondition({ tender_id: tenderId, times, audit_order: 1 });
             if (!audit) {
-                throw '审核人信息错误'
+                throw '审核人信息错误';
             }
-            const sum = await this.ctx.service.ledger.addUp({ tender_id: tenderId /* , is_leaf: true*/ })
+            const sum = await this.ctx.service.ledger.addUp({ tender_id: tenderId /* , is_leaf: true*/ });
 
-            const transaction = await this.db.beginTransaction()
+            const transaction = await this.db.beginTransaction();
             try {
                 await transaction.update(this.tableName, {
                     id: audit.id,
                     status: auditConst.status.checking,
-                    begin_time: new Date()
-                })
+                    begin_time: new Date(),
+                });
                 await transaction.update(this.ctx.service.tender.tableName, {
                     id: tenderId,
                     ledger_status: auditConst.status.checking,
                     total_price: sum.total_price,
-                    deal_tp: sum.deal_tp
-                })
+                    deal_tp: sum.deal_tp,
+                });
 
                 // 添加短信通知-需要审批提醒功能
                 // await this.ctx.helper.sendUserSms(audit.audit_id, smsTypeConst.const.TZ,
                 //     smsTypeConst.judge.approval.toString(), '台帐需要您审批。');
-                await this.ctx.helper.sendAliSms(audit.audit_id, smsTypeConst.const.TZ, smsTypeConst.judge.approval.toString(), SmsAliConst.template.ledger_check)
+                await this.ctx.helper.sendAliSms(audit.audit_id, smsTypeConst.const.TZ, smsTypeConst.judge.approval.toString(), SmsAliConst.template.ledger_check);
 
-                await transaction.commit()
+                await transaction.commit();
             } catch (err) {
-                await transaction.rollback()
-                throw err
+                await transaction.rollback();
+                throw err;
             }
-            return true
+            return true;
         }
 
         /**
@@ -244,73 +244,73 @@ 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(tenderId, checkType, opinion, times = 1) {
             if (checkType !== auditConst.status.checked && checkType !== auditConst.status.checkNo) {
-                throw '提交数据错误'
+                throw '提交数据错误';
             }
-            const pid = this.ctx.session.sessionProject.id
-            const transaction = await this.db.beginTransaction()
+            const pid = this.ctx.session.sessionProject.id;
+            const transaction = await this.db.beginTransaction();
             try {
                 // 整理当前流程审核人状态更新
-                const time = new Date()
+                const time = new Date();
                 const audit = await this.getDataByCondition({
                     tender_id: tenderId,
                     times,
-                    status: auditConst.status.checking
-                })
+                    status: auditConst.status.checking,
+                });
                 if (!audit) {
-                    throw '审核数据错误'
+                    throw '审核数据错误';
                 }
 
                 // 获取审核人列表
-                const auditList = await this.getAuditors(tenderId, times)
+                const auditList = await this.getAuditors(tenderId, times);
                 // 添加推送
-                const noticeContent = await this.getNoticeContent(audit.tender_id, pid, audit.audit_id)
+                const noticeContent = await this.getNoticeContent(audit.tender_id, pid, audit.audit_id);
                 const records = [
                     {
                         pid,
                         type: pushType.ledger,
                         uid: this.ctx.tender.data.user_id,
                         status: checkType,
-                        content: noticeContent
-                    }
-                ]
+                        content: noticeContent,
+                    },
+                ];
                 auditList.forEach(audit => {
                     records.push({
                         pid,
                         type: pushType.ledger,
                         uid: audit.audit_id,
                         status: checkType,
-                        content: noticeContent
-                    })
-                })
-                await transaction.insert('zh_notice', records)
+                        content: noticeContent,
+                    });
+                });
+                await transaction.insert('zh_notice', records);
                 // 更新当前审核流程
-                await transaction.update(this.tableName, { id: audit.id, status: checkType, opinion, end_time: time })
+                await transaction.update(this.tableName, { id: audit.id, status: checkType, opinion, end_time: time });
                 if (checkType === auditConst.status.checked) {
                     const nextAudit = await this.getDataByCondition({
                         tender_id: tenderId,
                         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,
+                        });
                         // await this.ctx.helper.sendUserSms(nextAudit.audit_id, smsTypeConst.const.TZ,
                         //     smsTypeConst.judge.approval.toString(), '台帐需要您审批。');
-                        await this.ctx.helper.sendAliSms(nextAudit.audit_id, smsTypeConst.const.TZ, smsTypeConst.judge.approval.toString(), SmsAliConst.template.ledger_check)
+                        await this.ctx.helper.sendAliSms(nextAudit.audit_id, smsTypeConst.const.TZ, smsTypeConst.judge.approval.toString(), SmsAliConst.template.ledger_check);
                     } else {
                         // 同步标段信息
                         await transaction.update(this.ctx.service.tender.tableName, {
                             id: tenderId,
-                            ledger_status: checkType
-                        })
+                            ledger_status: checkType,
+                        });
 
                         // 添加短信通知-审批通过提醒功能
                         // const mobile_array = [];
@@ -340,30 +340,30 @@ module.exports = app => {
                         //     const content = '【纵横计量支付】' + ptmsg + '台账审批通过,请登录系统处理。';
                         //     sms.send(mobile_array, content);
                         // }
-                        const users = this._.pull(this._.map(auditList, 'audit_id'), audit.id)
+                        const users = this._.pull(this._.map(auditList, 'audit_id'), audit.id);
                         // await this.ctx.helper.sendUserSms(users, smsTypeConst.const.TZ,
                         //     smsTypeConst.judge.result.toString(), '台账审批通过,请登录系统处理。');
                         await this.ctx.helper.sendAliSms(users, smsTypeConst.const.TZ, smsTypeConst.judge.result.toString(), SmsAliConst.template.ledger_result, {
-                            status: SmsAliConst.status.success
-                        })
+                            status: SmsAliConst.status.success,
+                        });
                     }
                 } else {
                     // 同步标段信息
                     await transaction.update(this.ctx.service.tender.tableName, {
                         id: tenderId,
                         ledger_times: times + 1,
-                        ledger_status: checkType
-                    })
+                        ledger_status: checkType,
+                    });
                     // 拷贝新一次审核流程列表
                     const auditors = await this.getAllDataByCondition({
                         where: { tender_id: tenderId, times },
-                        columns: ['tender_id', 'audit_order', 'audit_id']
-                    })
+                        columns: ['tender_id', 'audit_order', 'audit_id'],
+                    });
                     for (const a of auditors) {
-                        a.times = times + 1
-                        a.status = auditConst.status.uncheck
+                        a.times = times + 1;
+                        a.status = auditConst.status.uncheck;
                     }
-                    await transaction.insert(this.tableName, auditors)
+                    await transaction.insert(this.tableName, auditors);
 
                     // 添加短信通知-审批退回提醒功能
                     // const mobile_array = [];
@@ -392,18 +392,18 @@ module.exports = app => {
                     //     const content = '【纵横计量支付】' + ptmsg + '台账审批退回,请登录系统处理。';
                     //     sms.send(mobile_array, content);
                     // }
-                    const users = this._.pull(this._.map(auditList, 'audit_id'), audit.id)
+                    const users = this._.pull(this._.map(auditList, 'audit_id'), audit.id);
                     // await this.ctx.helper.sendUserSms(users, smsTypeConst.const.TZ,
                     //     smsTypeConst.judge.result.toString(), '台账审批退回,请登录系统处理。');
                     await this.ctx.helper.sendAliSms(users, smsTypeConst.const.TZ, smsTypeConst.judge.result.toString(), SmsAliConst.template.ledger_result, {
-                        status: SmsAliConst.status.back
-                    })
+                        status: SmsAliConst.status.back,
+                    });
                 }
 
-                await transaction.commit()
+                await transaction.commit();
             } catch (err) {
-                await transaction.rollback()
-                throw err
+                await transaction.rollback();
+                throw err;
             }
         }
 
@@ -411,14 +411,14 @@ module.exports = app => {
          * 获取审核人需要审核的标段列表
          *
          * @param auditorId
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async getAuditTender(auditorId) {
             const sql =
                 'SELECT la.`audit_id`, la.`times`, la.`audit_order`, la.`begin_time`, la.`end_time`, t.`id`, t.`name`, t.`project_id`, t.`type`, t.`user_id`, t.`ledger_status` ' +
                 'FROM ?? AS la, ?? AS t ' +
                 'WHERE ((la.`audit_id` = ? and la.`status` = ?) OR (t.`user_id` = ? and t.`ledger_status` = ? and la.`status` = ? and la.`times` = (t.`ledger_times`-1)))' +
-                '    and la.`tender_id` = t.`id`'
+                '    and la.`tender_id` = t.`id`';
             const sqlParam = [
                 this.tableName,
                 this.ctx.service.tender.tableName,
@@ -426,9 +426,9 @@ module.exports = app => {
                 auditConst.status.checking,
                 auditorId,
                 auditConst.status.checkNo,
-                auditConst.status.checkNo
-            ]
-            return await this.db.query(sql, sqlParam)
+                auditConst.status.checkNo,
+            ];
+            return await this.db.query(sql, sqlParam);
         }
 
         /**
@@ -436,7 +436,7 @@ module.exports = app => {
          * @param {Integer} pid - 项目id
          * @param {Integer} uid - 查询人id
          * @param {Date} noticeTime - 查询事件
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async getNoticeTender(pid, uid, noticeTime) {
             // const sql = 'SELECT * FROM (SELECT la.`audit_id`, la.`times`, la.`audit_order`, la.`end_time`, la.`status`, t.`id`, t.`name`, t.`project_id`, t.`type`, t.`user_id`, ' +
@@ -454,14 +454,14 @@ module.exports = app => {
                 where: { pid, type: pushType.ledger, uid },
                 orders: [['create_time', 'desc']],
                 limit: 10,
-                offset: 0
-            })
+                offset: 0,
+            });
             notice = notice.map(v => {
-                const extra = JSON.parse(v.content)
-                delete v.content
-                return { ...v, ...extra }
-            })
-            return notice
+                const extra = JSON.parse(v.content);
+                delete v.content;
+                return { ...v, ...extra };
+            });
+            return notice;
         }
 
         /**
@@ -476,12 +476,12 @@ module.exports = app => {
                 '  t.`id` As `tid`, t.`name`,  pa.`name` As `su_name`, pa.role As `su_role`' +
                 '  FROM (SELECT * FROM ?? WHERE `id` = ? ) As t' +
                 '  LEFT JOIN ?? As pa ON pa.`id` = ?' +
-                '  WHERE  t.`project_id` = ? ) as new_t GROUP BY new_t.`tid`'
-            const noticeSqlParam = [this.ctx.service.tender.tableName, id, this.ctx.service.projectAccount.tableName, uid, pid]
-            const content = await this.db.query(noticeSql, noticeSqlParam)
-            return content.length ? JSON.stringify(content[0]) : ''
+                '  WHERE  t.`project_id` = ? ) as new_t GROUP BY new_t.`tid`';
+            const noticeSqlParam = [this.ctx.service.tender.tableName, id, this.ctx.service.projectAccount.tableName, uid, pid];
+            const content = await this.db.query(noticeSql, noticeSqlParam);
+            return content.length ? JSON.stringify(content[0]) : '';
         }
     }
 
-    return LedgerAudit
-}
+    return LedgerAudit;
+};

+ 21 - 22
app/service/material_audit.js

@@ -267,12 +267,12 @@ module.exports = app => {
                 await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time });
 
                 // 获取推送必要信息
-                const noticeContent = await this.getNoticeContent(pid, audit.tid, materialId, audit.aid)
+                const noticeContent = await this.getNoticeContent(pid, audit.tid, materialId, audit.aid);
                 // 添加推送
-                const records = [{ pid, type: pushType.material, uid: this.ctx.material.user_id, status: auditConst.status.checked, content: noticeContent }]
+                const records = [{ pid, type: pushType.material, uid: this.ctx.material.user_id, status: auditConst.status.checked, content: noticeContent }];
                 auditors.forEach(audit => {
-                    records.push({ pid, type: pushType.material, uid: audit.aid, status: auditConst.status.checked, content: noticeContent })
-                })
+                    records.push({ pid, type: pushType.material, uid: audit.aid, status: auditConst.status.checked, content: noticeContent });
+                });
                 await transaction.insert('zh_notice', records);
                 // 无下一审核人表示,审核结束
                 if (nextAudit) {
@@ -287,7 +287,6 @@ module.exports = app => {
                     });
 
 
-
                     // 添加短信通知-需要审批提醒功能
                     // const smsUser = await this.ctx.service.projectAccount.getDataById(nextAudit.aid);
                     // if (smsUser.auth_mobile !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
@@ -369,11 +368,11 @@ module.exports = app => {
             try {
                 await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time });
                 // 添加到消息推送表
-                const noticeContent = await this.getNoticeContent(pid, audit.tid, materialId, audit.aid)
-                const records = [{ pid, type: pushType.material, uid: this.ctx.material.user_id, status: auditConst.status.checkNo, content: noticeContent }]
-                auditors.forEach( audit => {
-                    records.push({ pid, type: pushType.material, uid: audit.aid, status: auditConst.status.checkNo, content: noticeContent })
-                })
+                const noticeContent = await this.getNoticeContent(pid, audit.tid, materialId, audit.aid);
+                const records = [{ pid, type: pushType.material, uid: this.ctx.material.user_id, status: auditConst.status.checkNo, content: noticeContent }];
+                auditors.forEach(audit => {
+                    records.push({ pid, type: pushType.material, uid: audit.aid, status: auditConst.status.checkNo, content: noticeContent });
+                });
                 await transaction.insert('zh_notice', records);
                 // 同步期信息
                 await transaction.update(this.ctx.service.material.tableName, {
@@ -441,14 +440,14 @@ module.exports = app => {
                 return item.aid === audit.aid;
             });
             const preAuditor = auditors2[auditorIndex - 1];
-            const noticeContent = await this.getNoticeContent(pid, audit.tid, materialId, audit.aid)
+            const noticeContent = await this.getNoticeContent(pid, audit.tid, materialId, audit.aid);
             const transaction = await this.db.beginTransaction();
             try {
                 // 添加到消息推送表
-                const records = [{ pid, type: pushType.material, uid: this.ctx.material.user_id, status: auditConst.status.checkNoPre, content: noticeContent }]
-                auditors2.forEach( audit => {
-                    records.push({ pid, type: pushType.material, uid: audit.aid, status: auditConst.status.checkNoPre, content: noticeContent })
-                })
+                const records = [{ pid, type: pushType.material, uid: this.ctx.material.user_id, status: auditConst.status.checkNoPre, content: noticeContent }];
+                auditors2.forEach(audit => {
+                    records.push({ pid, type: pushType.material, uid: audit.aid, status: auditConst.status.checkNoPre, content: noticeContent });
+                });
                 await transaction.insert('zh_notice', records);
                 await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time });
                 // 顺移气候审核人流程顺序
@@ -624,16 +623,16 @@ module.exports = app => {
             // const sqlParam = [this.ctx.service.tender.tableName, uid, this.tableName, uid, this.ctx.service.material.tableName, this.tableName,
             //     this.ctx.service.projectAccount.tableName, time, pid];
             // return await this.db.query(sql, sqlParam);
-            let notice =  await this.db.select('zh_notice', {
-                where: { pid, type: pushType.material, uid},
+            let notice = await this.db.select('zh_notice', {
+                where: { pid, type: pushType.material, uid },
                 orders: [['create_time', 'desc']],
-                limit: 10, offset: 0
+                limit: 10, offset: 0,
             });
             notice = notice.map(v => {
-                const extra = JSON.parse(v.content)
-                delete v.content
-                return { ...v, ...extra }
-            })
+                const extra = JSON.parse(v.content);
+                delete v.content;
+                return { ...v, ...extra };
+            });
             return notice;
         }
 

+ 2 - 2
app/service/material_list.js

@@ -174,7 +174,7 @@ module.exports = app => {
          * 修改material_bills的quantity值和计算本期金额
          * @param transaction
          * @param mb_id
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async calcQuantityByML(transaction, mb_id) {
             // 修改material_bills值
@@ -225,7 +225,7 @@ module.exports = app => {
          * @param transaction
          * @param preMaterial
          * @param newMid
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async copyPreMaterialList(transaction, preMaterial, newMaterial) {
             const materialListData = await this.getAllDataByCondition({ where: { tid: this.ctx.tender.id, mid: preMaterial.id } });

+ 37 - 37
app/service/measure_audit.js

@@ -29,7 +29,7 @@ module.exports = app => {
          * @param {uuid} mid - 中间计量id
          * @param {Number} auditorId - 审核人id
          * @param {Number} times - 第几次审批
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async getAuditor(mid, auditorId, times = 1) {
             const sql = 'SELECT ma.*, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone` ' +
@@ -45,7 +45,7 @@ module.exports = app => {
          *
          * @param {uuid} mid - 中间计量id
          * @param {Number} times - 第几次审批
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async getAuditors(mid, times = 1) {
             const sql = 'SELECT ma.*, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone` ' +
@@ -61,7 +61,7 @@ module.exports = app => {
          *
          * @param {uuid} mid - 中间计量id
          * @param {Number} times - 第几次审批
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async getCurAuditor(mid, times = 1) {
             const sql = 'SELECT ma.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, ma.`times`, ma.`order`, ma.`status`, ma.`opinion`, ma.`begin_time`, ma.`end_time` ' +
@@ -77,7 +77,7 @@ module.exports = app => {
          *
          * @param {uuid} mid - 中间计量id
          * @param {Number} times - 第几次审批
-         * @returns {Promise<number>}
+         * @return {Promise<number>}
          */
         async getNewOrder(mid, times = 1) {
             const sql = 'SELECT Max(??) As max_order FROM ?? Where `mid` = ? and `times` = ? and `order` > 0';
@@ -93,15 +93,15 @@ module.exports = app => {
          * @param {uuid} mid - 中间计量id
          * @param {Number} auditorId - 审核人id
          * @param {Number} times - 第几次审批
-         * @returns {Promise<number>}
+         * @return {Promise<number>}
          */
         async addAuditor(tenderId, mid, auditorId, times = 1) {
             const newOrder = await this.getNewOrder(mid, times);
             const data = {
                 tender_id: tenderId,
-                mid: mid,
+                mid,
                 audit_id: auditorId,
-                times: times,
+                times,
                 order: newOrder,
                 status: auditConst.status.uncheck,
             };
@@ -115,14 +115,14 @@ module.exports = app => {
          * @param {uuid} mid - 中间计量id
          * @param {Number} auditorId - 审核人id
          * @param {Number} times - 第几次审批
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          * @private
          */
         async _syncOrderByDelete(transaction, mid, order, times) {
             this.initSqlBuilder();
             this.sqlBuilder.setAndWhere('mid', {
                 value: this.db.escape(mid),
-                operate: '='
+                operate: '=',
             });
             this.sqlBuilder.setAndWhere('order', {
                 value: order,
@@ -148,12 +148,12 @@ module.exports = app => {
          * @param {uuid} mid - 中间计量id
          * @param {Number} auditorId - 审核人id
          * @param {Number} times - 第几次审批
-         * @returns {Promise<boolean>}
+         * @return {Promise<boolean>}
          */
         async deleteAuditor(mid, auditorId, times = 1) {
             const transaction = await this.db.beginTransaction();
             try {
-                const condition = {mid: mid, audit_id: auditorId, times: times};
+                const condition = { mid, audit_id: auditorId, times };
                 const auditor = await this.getDataByCondition(condition);
                 if (!auditor) {
                     throw '该审核人不存在';
@@ -161,7 +161,7 @@ module.exports = app => {
                 await this._syncOrderByDelete(transaction, mid, auditor.order, times);
                 await transaction.delete(this.tableName, condition);
                 await transaction.commit();
-            } catch(err) {
+            } catch (err) {
                 await transaction.rollback();
                 throw err;
             }
@@ -169,7 +169,7 @@ module.exports = app => {
         }
 
         _sumBills(bills) {
-            const result = {deal: 0, qc: 0};
+            const result = { deal: 0, qc: 0 };
             for (const b of bills) {
                 result.deal = result.deal + (b.deal_totalprice ? b.deal_totalprice : 0);
                 result.qc = result.qc + (b.qc_totalprice ? b.qc_totalprice : 0);
@@ -182,13 +182,13 @@ module.exports = app => {
          * @param transacation - 事务
          * @param {uuid} mid - 中间计量
          * @param {Number} times - 次数
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          * @private
          */
         async _copyReportBillsHistory(transacation, mid, times) {
-            const bills = await this.ctx.service.measureBills.getAllDataByCondition({ where: {mid: mid}});
+            const bills = await this.ctx.service.measureBills.getAllDataByCondition({ where: { mid } });
             const sum = this._sumBills(bills);
-            const history = await this.getDataByCondition({mid: mid, times: times, order: 0});
+            const history = await this.getDataByCondition({ mid, times, order: 0 });
             if (history) {
                 await transacation.update(this.tableName, {
                     id: history.id,
@@ -197,11 +197,11 @@ module.exports = app => {
                     qc_sum: sum.qc,
                 });
             } else {
-                const measure = await this.ctx.service.measure.getDataByCondition({mid: mid});
+                const measure = await this.ctx.service.measure.getDataByCondition({ mid });
                 await transacation.insert(this.tableName, {
                     tender_id: measure.tender_id,
-                    mid: mid,
-                    times: times,
+                    mid,
+                    times,
                     order: 0,
                     audit_id: measure.user_id,
                     status: 0,
@@ -217,10 +217,10 @@ module.exports = app => {
          *
          * @param {uuid} mid - 中间计量id
          * @param {Number} times - 第几次审批
-         * @returns {Promise<boolean>}
+         * @return {Promise<boolean>}
          */
         async start(mid, times = 1) {
-            const audit = await this.getDataByCondition({mid: mid, times: times, order: 1});
+            const audit = await this.getDataByCondition({ mid, times, order: 1 });
             if (!audit) {
                 throw '审核人信息错误';
             }
@@ -237,13 +237,13 @@ module.exports = app => {
                 });
                 // 改变中间计量状态
                 await transaction.update(this.ctx.service.measure.tableName, {
-                    times: times,
+                    times,
                     status: auditConst.status.checking,
                     deal_sum: sum.deal,
                     qc_sum: sum.qc,
-                }, {where: {mid: mid}});
+                }, { where: { mid } });
                 await transaction.commit();
-            } catch(err) {
+            } catch (err) {
                 await transaction.rollback();
                 throw err;
             }
@@ -255,7 +255,7 @@ module.exports = app => {
          * @param {uuid} mid - 中间计量id
          * @param {auditConst.status.checked|auditConst.status.checkNo} checkType - 审批结果
          * @param {Number} times - 第几次审批
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async check(mid, checkType, opinion, times = 1) {
             if (checkType !== auditConst.status.checked && checkType !== auditConst.status.checkNo) {
@@ -266,17 +266,17 @@ module.exports = app => {
             try {
                 // 整理当前流程审核人状态更新
                 const time = new Date();
-                const audit = await this.getDataByCondition({mid: mid, times: times, status: auditConst.status.checking});
+                const audit = await this.getDataByCondition({ mid, times, status: auditConst.status.checking });
                 if (!audit) {
                     throw '审核数据错误';
                 }
                 // 更新当前审核流程
-                const bills = await this.ctx.service.measureBills.getAllDataByCondition({ where: {mid: mid}});
+                const bills = await this.ctx.service.measureBills.getAllDataByCondition({ where: { mid } });
                 const sum = this._sumBills(bills);
                 await transaction.update(this.tableName, {
                     id: audit.id,
                     status: checkType,
-                    opinion: opinion,
+                    opinion,
                     end_time: time,
                     bills: JSON.stringify(bills),
                     deal_sum: sum.deal,
@@ -284,22 +284,22 @@ module.exports = app => {
                 });
                 const measureTable = this.ctx.service.measure.tableName;
                 if (checkType === auditConst.status.checked) {
-                    const nextAudit = await this.getDataByCondition({mid: mid, times: times, order: audit.order + 1});
+                    const nextAudit = await this.getDataByCondition({ mid, times, order: audit.order + 1 });
                     // 无下一审核人表示,审核结束
                     if (nextAudit) {
-                        await transaction.update(this.tableName, {id: nextAudit.id, status: auditConst.status.checking, begin_time: time});
-                        await transaction.update(measureTable, {deal_sum: sum.deal, qc_sum: sum.qc,}, {where: {mid: mid}});
+                        await transaction.update(this.tableName, { id: nextAudit.id, status: auditConst.status.checking, begin_time: time });
+                        await transaction.update(measureTable, { deal_sum: sum.deal, qc_sum: sum.qc }, { where: { mid } });
                     } else {
                         // 同步标段信息
-                        await transaction.update(measureTable, {status: checkType, deal_sum: sum.deal, qc_sum: sum.qc,}, {where: {mid: mid}});
+                        await transaction.update(measureTable, { status: checkType, deal_sum: sum.deal, qc_sum: sum.qc }, { where: { mid } });
                     }
                 } else {
                     // 同步标段信息
-                    await transaction.update(measureTable, {times: times+1, status: checkType, deal_sum: sum.deal, qc_sum: sum.qc,}, {where: {mid: mid}});
+                    await transaction.update(measureTable, { times: times + 1, status: checkType, deal_sum: sum.deal, qc_sum: sum.qc }, { where: { mid } });
                     // 拷贝新一次审核流程列表
                     const auditors = await this.getAllDataByCondition({
-                        where: {mid: mid, times: times},
-                        columns: ['tender_id', 'order', 'audit_id', 'mid']
+                        where: { mid, times },
+                        columns: ['tender_id', 'order', 'audit_id', 'mid'],
                     });
                     for (const a of auditors) {
                         a.times = times + 1;
@@ -319,7 +319,7 @@ module.exports = app => {
          * 获取审核人需要审核的标段列表
          *
          * @param auditorId
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async getAuditTender(auditorId) {
             const sql = 'SELECT ma.`audit_id`, ma.`times`, ma.`order`, ma.`begin_time`, t.`id`, t.`name`, t.`project_id`, t.`type`, t.`user_id` ' +
@@ -332,4 +332,4 @@ module.exports = app => {
     }
 
     return MeasureAudit;
-};
+};

+ 22 - 22
app/service/measure_bills.js

@@ -28,7 +28,7 @@ module.exports = app => {
          *
          * @param {Number} tenderId - 标段id
          * @param {uuid} mid - 中间计量id
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async getBillsDetail(tenderId, mid) {
             const sql = 'SELECT MB.`tender_id`, MB.`mid`, MB.`bid`, L.`code`, L.`name`, L.`full_path` ' +
@@ -44,7 +44,7 @@ module.exports = app => {
          * @param tenderId
          * @param mid
          * @param ids
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          * @private
          */
         async _getUnionBillsData(tenderId, mid, ids) {
@@ -59,13 +59,13 @@ module.exports = app => {
             const sqlParam = [this.ctx.service.ledger.tableName, this.tableName, tenderId, tenderId, mid,
                 this.ctx.service.ledger.tableName, tenderId];
             return await this.db.query(sql, sqlParam);
-        };
+        }
 
         /**
          * 查询中间计量下清单(含父项)
          * @param {Number} tenderId - 标段id
          * @param {uuid} mid - 中间计量id
-         * @returns {Promise<Array>}
+         * @return {Promise<Array>}
          */
         async getBillsDetailWithParent(tenderId, mid) {
             const bills = await this.getBillsDetail(tenderId, mid);
@@ -75,10 +75,10 @@ module.exports = app => {
                     ids = ids.concat(b.full_path.split('.'));
                 }
                 return await this._getUnionBillsData(tenderId, mid, ids);
-                //return await this.ctx.service.ledger.getDataByNodeIds(tenderId, ids);
-            } else {
-                return [];
+                // return await this.ctx.service.ledger.getDataByNodeIds(tenderId, ids);
             }
+            return [];
+
         }
 
         /**
@@ -86,7 +86,7 @@ module.exports = app => {
          * @param {Number} tenderId - 标段id
          * @param {uuid} mid - 计量id
          * @param {Number} bid - 清单id
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async getBillsData(tenderId, mid, bid) {
             const sql = 'SELECT MB.`tender_id`, MB.`mid`, MB.`bid`, L.`code`, L.`name`, L.`full_path` ' +
@@ -102,13 +102,13 @@ module.exports = app => {
          * @param {Number} tenderId - 标段id
          * @param {uuid} mid - 计量id
          * @param {Number} bid - 清单id
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async getBillsDataWithParent(tenderId, mid, bid) {
             const bills = await this.getBillsData(tenderId, mid, bid);
             const ids = bills.full_path.split('.');
             return await this._getUnionBillsData(tenderId, mid, ids);
-            //return await this.ctx.service.ledger.getDataByNodeIds(tenderId, bills.full_path.split('.'));
+            // return await this.ctx.service.ledger.getDataByNodeIds(tenderId, bills.full_path.split('.'));
         }
 
         /**
@@ -116,13 +116,13 @@ module.exports = app => {
          * @param {Number} tenderId - 标段id
          * @param {uuid} mid - 计量id
          * @param {Number} bid - 清单id
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async addBills(tenderId, mid, bid) {
             const result = await this.db.insert(this.tableName, {
                 tender_id: tenderId,
-                mid: mid,
-                bid: bid,
+                mid,
+                bid,
                 in_time: new Date(),
                 in_user: this.ctx.session.sessionUser.accountId,
             });
@@ -133,13 +133,13 @@ module.exports = app => {
          * @param {Number} tenderId - 标段id
          * @param {uuid} mid - 计量id
          * @param {Number} bid - 清单id
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async removeBills(tenderId, mid, bid) {
             await this.db.delete(this.tableName, {
                 tender_id: tenderId,
-                mid: mid,
-                bid: bid,
+                mid,
+                bid,
             });
         }
 
@@ -149,7 +149,7 @@ module.exports = app => {
          * @param {uuid} mid - 计量id
          * @param {Number} bid - 清单id
          * @param {Object} data - 更新数据
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async updateBills(tenderId, mid, bid, data) {
             const bills = await this.ctx.service.ledger.getDataByNodeId(tenderId, bid);
@@ -162,17 +162,17 @@ module.exports = app => {
             }
             const result = await this.update(data, {
                 tender_id: tenderId,
-                mid: mid,
-                bid: bid,
+                mid,
+                bid,
             });
             if (result) {
                 data.ledger_id = bid;
                 return data;
-            } else {
-                throw '更新数据失败';
             }
+            throw '更新数据失败';
+
         }
     }
 
     return MeasureBills;
-};
+};

+ 9 - 9
app/service/measure_pos.js

@@ -28,7 +28,7 @@ module.exports = app => {
          *
          * @param {Number} tenderId - 标段id
          * @param {uuid} mid - 计量id
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async getPosDetail(tenderId, mid) {
             const sql = 'SELECT MP.`tender_id`, MP.`mid`, MP.`pid`, L.`code`, L.`name`, L.`full_path` ' +
@@ -44,7 +44,7 @@ module.exports = app => {
          * @param tenderId
          * @param mid
          * @param pid
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async getPosData(tenderId, mid, pid) {
             const sql = 'SELECT MP.`tender_id`, MP.`mid`, MP.`pid`, L.`code`, L.`name`, L.`full_path` ' +
@@ -61,13 +61,13 @@ module.exports = app => {
          * @param {Number} tenderId - 标段id
          * @param {uuid} mid - 计量id
          * @param {Number} pid -- 计量范围id
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async addPos(tenderId, mid, pid) {
             const result = await this.db.insert(this.tableName, {
                 tender_id: tenderId,
-                mid: mid,
-                pid: pid,
+                mid,
+                pid,
                 in_time: new Date(),
                 in_user: this.ctx.session.sessionUser.accountId,
             });
@@ -80,16 +80,16 @@ module.exports = app => {
          * @param {Number} tenderId - 标段id
          * @param {uuid} mid - 计量id
          * @param {Number} pid -- 计量范围id
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async removePos(tenderId, mid, pid) {
             await this.db.delete(this.tableName, {
                 tender_id: tenderId,
-                mid: mid,
-                pid: pid,
+                mid,
+                pid,
             });
         }
     }
 
     return MeasurePos;
-};
+};

+ 27 - 27
app/service/stage.js

@@ -36,8 +36,7 @@ module.exports = app => {
          */
         async getDataById(id) {
             const result = await this.db.get(this.tableName, { id });
-            if (result)
-                result.tp_history = result.tp_history ? JSON.parse(result.tp_history) : [];
+            if (result) { result.tp_history = result.tp_history ? JSON.parse(result.tp_history) : []; }
             return result;
         }
 
@@ -49,8 +48,7 @@ module.exports = app => {
          */
         async getDataByCondition(condition) {
             const result = await this.db.get(this.tableName, condition);
-            if (result)
-                result.tp_history = result.tp_history ? JSON.parse(result.tp_history) : [];
+            if (result) { result.tp_history = result.tp_history ? JSON.parse(result.tp_history) : []; }
             return result;
         }
 
@@ -73,7 +71,9 @@ module.exports = app => {
             stage.auditors = await this.ctx.service.stageAudit.getAuditors(stage.id, stage.times);
             stage.curAuditor = await this.ctx.service.stageAudit.getCurAuditor(stage.id, stage.times);
 
-            const accountId = this.ctx.session.sessionUser.accountId, auditorIds = this._.map(stage.auditors, 'aid'), shareIds = [];
+            const accountId = this.ctx.session.sessionUser.accountId,
+                auditorIds = this._.map(stage.auditors, 'aid'),
+                shareIds = [];
             const permission = this.ctx.session.sessionUser.permission;
             if (accountId === stage.user_id) { // 原报
                 if (stage.curAuditor) {
@@ -98,7 +98,7 @@ module.exports = app => {
                     stage.curOrder = this._.max(this._.map(stage.auditors, 'order'));
                 } else if (stage.status === status.checkNo) {
                     const audit = await this.service.stageAudit.getDataByCondition({
-                        sid: stage.id, times: stage.times - 1, status: status.checkNo
+                        sid: stage.id, times: stage.times - 1, status: status.checkNo,
                     });
                     stage.curOrder = audit.order;
                 } else {
@@ -125,7 +125,7 @@ module.exports = app => {
             if (!time) {
                 time = stage.in_time ? stage.in_time : new Date();
             }
-            stage.cacheTime = time.getTime();//this.ctx.stage.readOnly ? (this.ctx.stage.cache_time_r).getTime(): (this.ctx.stage.cache_time_l).getTime();
+            stage.cacheTime = time.getTime();// this.ctx.stage.readOnly ? (this.ctx.stage.cache_time_r).getTime(): (this.ctx.stage.cache_time_l).getTime();
 
             return stage;
         }
@@ -142,7 +142,7 @@ module.exports = app => {
          * 获取 最新一期 期计量
          * @param tenderId
          * @param includeUnCheck
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async getLastestStage(tenderId, includeUnCheck = false) {
             this.initSqlBuilder();
@@ -166,7 +166,7 @@ module.exports = app => {
         /**
          * 获取 最新一期 审批完成的 期计量
          * @param tenderId
-         * @returns {Promise<*>}
+         * @return {Promise<*>}
          */
         async getLastestCompleteStage(tenderId) {
             this.initSqlBuilder();
@@ -188,7 +188,7 @@ module.exports = app => {
         /**
          * 获取标段下的期列表(报表选择用,只需要一些key信息,不需要计算详细数据,也懒得一个个字段写了,用*来处理)
          * @param tenderId
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async getValidStagesShort(tenderId) {
             const sql = 'select * from zh_stage where tid = ? order by zh_stage.order';
@@ -199,7 +199,7 @@ module.exports = app => {
         /**
          * 获取某一期信息(报表用)
          * @param stageId
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async getStageById(stageId) {
             const sql = 'select * from zh_stage where id = ? order by zh_stage.order';
@@ -221,10 +221,10 @@ module.exports = app => {
                     await this.update({
                         check_calc: false,
                         contract_tp: stage.contract_tp, qc_tp: stage.qc_tp,
-                        yf_tp: stage.yf_tp, sf_tp: stage.sf_tp
-                    }, {id: stage.id});
+                        yf_tp: stage.yf_tp, sf_tp: stage.sf_tp,
+                    }, { id: stage.id });
                 } else if (stage.tp_history) {
-                    const his = this.ctx.helper._.find(stage.tp_history, {times: stage.curTimes, order: stage.curOrder});
+                    const his = this.ctx.helper._.find(stage.tp_history, { times: stage.curTimes, order: stage.curOrder });
                     // console.log(his);
                     if (his) {
                         stage.contract_tp = his.contract_tp;
@@ -240,7 +240,7 @@ module.exports = app => {
         /**
          * 获取标段下的全部计量期,按倒序
          * @param tenderId
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async getValidStages(tenderId) {
             const stages = await this.db.select(this.tableName, {
@@ -275,7 +275,7 @@ module.exports = app => {
                     stage.tp = this.ctx.helper.add(stage.contract_tp, stage.qc_tp);
                     stage.end_tp = this.ctx.helper.add(stage.pre_tp, stage.tp);
                 } else {
-                    const his = this.ctx.helper._.find(stage.tp_history, {times: stage.curTimes, order: stage.curOrder});
+                    const his = this.ctx.helper._.find(stage.tp_history, { times: stage.curTimes, order: stage.curOrder });
                     if (his) {
                         stage.contract_tp = his.contract_tp;
                         stage.qc_tp = his.qc_tp;
@@ -290,7 +290,7 @@ module.exports = app => {
                 if (s.yf_tp && s.sf_tp === 0) {
                     const sf = await this.ctx.service.stagePay.getHistorySf(s);
                     if (sf && s.readOnly) {
-                        await this.ctx.service.stage.update({ sf_tp: sf.tp, pre_sf_tp: sf.pre_tp}, {id: s.id});
+                        await this.ctx.service.stage.update({ sf_tp: sf.tp, pre_sf_tp: sf.pre_tp }, { id: s.id });
                     }
                     s.sf_tp = sf.tp;
                 }
@@ -303,7 +303,7 @@ module.exports = app => {
          * @param tenderId - 标段id
          * @param date - 计量年月
          * @param period - 开始-截止日期
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async addStage(tenderId, date, period) {
             const stages = await this.getAllDataByCondition({
@@ -387,7 +387,7 @@ module.exports = app => {
          * @param {Number} order - 第N期
          * @param {String} date - 计量年月
          * @param {String} period - 开始-截止时间
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async saveStage(tenderId, order, date, period) {
             await this.db.update(this.tableName, {
@@ -401,7 +401,7 @@ module.exports = app => {
          * @param {Number} tenderId - 标段id
          * @param {Number} order - 期序号
          * @param {Number} data - 中间计量生成规则
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async buildDetailData(tenderId, order, data) {
             const conn = await this.db.beginTransaction();
@@ -417,7 +417,7 @@ module.exports = app => {
 
         /**
          * 获取 当期的 计算基数
-         * @returns {Promise<any>}
+         * @return {Promise<any>}
          */
         async getStagePayCalcBase(stage, tenderInfo) {
             const calcBase = JSON.parse(JSON.stringify(payConst.calcBase));
@@ -461,12 +461,12 @@ module.exports = app => {
         }
 
         async updateCheckCalcFlag(stage, check) {
-            const result = await this.db.update(this.tableName, {id: stage.id, check_calc: check});
+            const result = await this.db.update(this.tableName, { id: stage.id, check_calc: check });
             return result.affectedRows === 1;
         }
 
         async updateCacheTime(sid) {
-            const result = await this.db.update(this.tableName, {id: sid, cache_time_l: new Date()});
+            const result = await this.db.update(this.tableName, { id: sid, cache_time_l: new Date() });
             return result.affectedRows === 1;
         }
 
@@ -474,14 +474,14 @@ module.exports = app => {
          * 删除计量期
          *
          * @param {Number} id - 期Id
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async deleteStage(id) {
             const transaction = await this.db.beginTransaction();
             try {
                 const stageInfo = await this.getDataById(id);
                 await transaction.delete(this.tableName, { id });
-                await transaction.delete(this.ctx.service.pos.tableName, {add_stage: id});
+                await transaction.delete(this.ctx.service.pos.tableName, { add_stage: id });
                 await transaction.delete(this.ctx.service.stageAudit.tableName, { sid: id });
                 await transaction.delete(this.ctx.service.stageBills.tableName, { sid: id });
                 await transaction.delete(this.ctx.service.stageChange.tableName, { sid: id });
@@ -539,7 +539,7 @@ module.exports = app => {
 
         /**
          * 获取 多期的 计算基数 -(材料调差调用)
-         * @returns {Promise<any>}
+         * @return {Promise<any>}
          */
         async getMaterialCalcBase(stage_list, tenderInfo) {
             const calcBase = JSON.parse(JSON.stringify(payConst.calcBase));
@@ -585,7 +585,7 @@ module.exports = app => {
         /**
          * 获取必要的stage信息调用curTimes, curOrder, id , times, curAuditor(材料调差)
          * @param stage_id_list
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async getStageMsgByStageId(stage_id_list) {
             const list = [];

Разница между файлами не показана из-за своего большого размера
+ 344 - 344
app/service/stage_audit.js


+ 25 - 20
app/service/tender_info.js

@@ -34,17 +34,17 @@ module.exports = app => {
          * @param tenderId - 标段Id
          * @param projectId - 项目Id
          * @param transaction - 事务
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async addTenderInfo(tenderId, projectId, transaction) {
             const info = JSON.parse(JSON.stringify(defaultInfo));
             info.tid = tenderId;
             info.pid = projectId;
             for (const pi of parseInfo) {
-                info[pi] = JSON.stringify(info[pi])
+                info[pi] = JSON.stringify(info[pi]);
             }
             for (const pi of arrayInfo) {
-                info[pi] = JSON.stringify(info[pi])
+                info[pi] = JSON.stringify(info[pi]);
             }
 
             if (transaction) {
@@ -58,10 +58,10 @@ module.exports = app => {
         /**
          * 获取标段相关信息
          * @param tenderId
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async getTenderInfo(tenderId) {
-            let info = await this.getDataByCondition({tid: tenderId});
+            let info = await this.getDataByCondition({ tid: tenderId });
             // 兼容不存在info的情况
             if (!info) {
                 info = await this.addTenderInfo(tenderId, this.ctx.session.sessionProject.id);
@@ -82,7 +82,7 @@ module.exports = app => {
         /**
          * 获取标段相关信息(报表用)
          * @param tenderId
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async getTenderInfoEx(tenderId) {
             const sql = 'select t2.name, t1.* from zh_tender_info t1 inner join zh_tender t2 on t2.id = t1.tid where t1.tid = ?';
@@ -110,7 +110,7 @@ module.exports = app => {
          * 保存标段相关信息
          *
          * @param data
-         * @returns {Promise<void>}
+         * @return {Promise<void>}
          */
         async saveTenderInfo(tenderId, data) {
             for (const di in data) {
@@ -118,14 +118,14 @@ module.exports = app => {
                     data[di] = JSON.stringify(data[di]);
                 }
             }
-            await this.db.update(this.tableName, data, {where: {tid: tenderId}});
+            await this.db.update(this.tableName, data, { where: { tid: tenderId } });
         }
 
         async savePrecision(tenderId, newPrecision, oldPrecision, decimal) {
             const changePrecision = [];
             const units = await this.ctx.service.ledger.getTenderUsedUnits(tenderId);
             const defUnits = this._.map(newPrecision, 'units');
-            const otherUnits = units.filter(function (u) {return defUnits.indexOf(u) === -1});
+            const otherUnits = units.filter(function(u) { return defUnits.indexOf(u) === -1; });
             let changeUnits = [];
             for (const prop in newPrecision) {
                 if (oldPrecision[prop]) {
@@ -148,15 +148,18 @@ module.exports = app => {
             if (changeUnits.length > 0) {
                 const bills = await this.ctx.service.ledger.getAllDataByCondition({
                     columns: ['id', 'unit', 'unit_price', 'sgfh_qty', 'sjcl_qty', 'qtcl_qty', 'deal_qty'],
-                    where: {tender_id: tenderId, unit: changeUnits, is_leaf: true}
+                    where: { tender_id: tenderId, unit: changeUnits, is_leaf: true },
                 });
                 const pos = changeUnits.length > 0 ? await this.ctx.service.pos.getPosDataByUnits(tenderId, changeUnits) : [];
 
                 for (const b of bills) {
                     const precision = this.ctx.helper.findPrecision(newPrecision, b.unit);
-                    const bPos = this._.filter(pos, {lid: b.id});
+                    const bPos = this._.filter(pos, { lid: b.id });
                     if (bPos.length > 0) {
-                        let sgfh_qty = 0, sjcl_qty = 0, qtcl_qty = 0, quantity = 0;
+                        let sgfh_qty = 0,
+                            sjcl_qty = 0,
+                            qtcl_qty = 0,
+                            quantity = 0;
                         for (const p of bPos) {
                             this.ctx.helper.checkFieldPrecision(p, ['sgfh_qty', 'sjcl_qty', 'qtcl_qty'], precision.value);
                             p.quantity = this.ctx.helper.add(this.ctx.helper.add(p.sgfh_qty, p.sjcl_qty), p.qtcl_qty);
@@ -183,7 +186,7 @@ module.exports = app => {
                 const transaction = await this.db.beginTransaction();
                 try {
                     await transaction.update(this.tableName,
-                        {precision: JSON.stringify(newPrecision)}, {where: {tid: tenderId}});
+                        { precision: JSON.stringify(newPrecision) }, { where: { tid: tenderId } });
                     if (bills.length > 0) await transaction.updateRows(this.ctx.service.ledger.tableName, bills);
                     if (pos.length > 0) await transaction.updateRows(this.ctx.service.pos.tableName, pos);
                     await transaction.commit();
@@ -193,16 +196,18 @@ module.exports = app => {
                 }
             } else {
                 await this.db.update(this.tableName,
-                    {precision: JSON.stringify(newPrecision)}, {where: {tid: tenderId}});
+                    { precision: JSON.stringify(newPrecision) }, { where: { tid: tenderId } });
             }
         }
 
         async saveDecimal(tenderId, newDecimal, oldDecimal) {
-            const changeBills = [], calcUp = newDecimal.up < oldDecimal.up, calcTp = newDecimal.tp !== oldDecimal.tp;
+            const changeBills = [],
+                calcUp = newDecimal.up < oldDecimal.up,
+                calcTp = newDecimal.tp !== oldDecimal.tp;
             if (calcUp || calcTp) {
                 const bills = await this.ctx.service.ledger.getAllDataByCondition({
                     columns: ['id', 'unit_price', 'sgfh_qty', 'sjcl_qty', 'qtcl_qty', 'deal_qty', 'quantity'],
-                    where: {tender_id: tenderId, is_leaf: true}
+                    where: { tender_id: tenderId, is_leaf: true },
                 });
                 for (const b of bills) {
                     const cb = { id: b.id };
@@ -219,19 +224,19 @@ module.exports = app => {
                 const transaction = await this.db.beginTransaction();
                 try {
                     await transaction.update(this.tableName,
-                        {decimal: JSON.stringify(newDecimal)}, { where: { tid: tenderId }});
+                        { decimal: JSON.stringify(newDecimal) }, { where: { tid: tenderId } });
                     await transaction.updateRows(this.ctx.service.ledger.tableName, changeBills);
                     await transaction.commit();
-                } catch(error) {
+                } catch (error) {
                     await transaction.rollback();
                     throw error;
                 }
             } else {
                 await this.db.update(this.tableName,
-                    {decimal: JSON.stringify(newDecimal)}, { where: { tid: tenderId }});
+                    { decimal: JSON.stringify(newDecimal) }, { where: { tid: tenderId } });
             }
         }
     }
 
     return TenderInfo;
-};
+};

+ 7 - 70
app/view/advance/detail.ejs

@@ -53,7 +53,7 @@
                                     </td>
                                     <th width="150">本期金额</th>
                                     <td class="text-right">
-                                        <h5><%- advance.cur_amount %></h5>
+                                        <h5><%- ctx.helper.formatMoney(advance.cur_amount) %></h5>
                                     </td>
                                 </tr>
                             <% } %>
@@ -206,9 +206,9 @@
                                     </div>
                                 </td>
                                 <td width="70%">
-                                    <div class="card mb-1">
-                                        <ul class="list-group list-group-flush">
-                                            <% auditHistory.forEach(auditors => { %>
+                                    <% auditHistory.forEach(auditors => { %>
+                                        <div class="card mb-1">
+                                            <ul class="list-group list-group-flush">
                                                 <% auditors.forEach(auditor => { %>
                                                     <li class="list-group-item">
                                                         <span class="text-success pull-right">上报</span>
@@ -218,72 +218,9 @@
                                                         <p class="card-text">2017-11-25</p>
                                                     </li>
                                                 <% }) %>
-                                            <% }) %>
-                                            <!-- <li class="list-group-item">
-                                                <span class="text-success pull-right">上报</span>
-                                                <h5 class="card-title"><i
-                                                        class="fa fa-play-circle fa-rotate-90 text-success"></i> 布尔
-                                                    <small class="text-muted">施工</small></h5>
-                                                <p class="card-text">2017-11-25</p>
-                                            </li>
-                                            <li class="list-group-item">
-                                                <span class="text-success pull-right">审批通过</span>
-                                                <h5 class="card-title"><i
-                                                        class="fa fa-chevron-circle-down text-success"></i> 张三 <small
-                                                        class="text-muted">监理</small></h5>
-                                                <p class="card-text">审批意见。2017-11-25</p>
-                                            </li>
-                                            <li class="list-group-item">
-                                                <span class="text-success pull-right">审批通过</span>
-                                                <h5 class="card-title"><i
-                                                        class="fa fa-chevron-circle-down text-success"></i> 王五 <small
-                                                        class="text-muted">监理</small></h5>
-                                                <p class="card-text">审批通过。2017-11-26</p>
-                                            </li>
-                                            <li class="list-group-item">
-                                                <span class="text-warning pull-right">审批退回 布尔</span>
-                                                <h5 class="card-title"><i class="fa fa-stop-circle text-warning"></i> 李四
-                                                    <small class="text-muted">监理</small></h5>
-                                                <p class="card-text">审批退回,审批意见文本。2017-11-27</p>
-                                            </li> -->
-                                        </ul>
-                                    </div>
-                                    <div class="card mb-1">
-                                        <ul class="list-group list-group-flush">
-                                            <li class="list-group-item">
-                                                <span class="text-success pull-right">重新上报</span>
-                                                <h5 class="card-title"><i
-                                                        class="fa fa-play-circle fa-rotate-90 text-success"></i> 布尔
-                                                    <small class="text-muted">施工</small></h5>
-                                                <p class="card-text">2017-12-01</p>
-                                            </li>
-                                            <li class="list-group-item">
-                                                <span class="text-success pull-right">审批通过</span>
-                                                <h5 class="card-title"><i
-                                                        class="fa fa-chevron-circle-down text-success"></i> 张三 <small
-                                                        class="text-muted">监理</small></h5>
-                                                <p class="card-text">审批通过 2017-12-02</p>
-                                            </li>
-                                            <li class="list-group-item">
-                                                <span class="text-warning pull-right">审批退回 张三</span>
-                                                <h5 class="card-title"><i
-                                                        class="fa fa-chevron-circle-down text-warning"></i> 王五 <small
-                                                        class="text-muted">监理</small></h5>
-                                                <p class="card-text">审批退回 2017-12-02</p>
-                                            </li>
-                                            <!--王五退回上一审批人 张三,张三重新审批-->
-                                            <li class="list-group-item">
-                                                <span class="pull-right">审批中</span>
-                                                <h5 class="card-title"><i class="fa fa-chevron-circle-down"></i> 张三
-                                                    <small class="text-muted">监理</small></h5>
-                                                <p class="card-text"></p>
-                                            </li>
-                                            <li class="list-group-item">
-                                                <h5 class="card-title"><i class="fa fa-stop-circle"></i> 李四 <small
-                                                        class="text-muted">监理</small></h5>
-                                            </li>
-                                        </ul>
-                                    </div>
+                                            </ul>
+                                        </div>
+                                    <% }) %>
                                 </td>
                             </tr>
                         </tbody>

+ 19 - 3
app/view/advance/index.ejs

@@ -29,7 +29,11 @@
                 </div>
             </div>
             <div>
-                <% if(latestOrder.status === auditConst.status.checked) { %>
+                <% if(!latestOrder || latestOrder.status === auditConst.status.checked) { %>
+                    <form action="<%- preUrl %>">
+
+                        <button type="submit" class="btn btn-primary btn-sm pull-right"></button>
+                    </form>
                     <a id="advance_add" href="" class="btn btn-primary btn-sm pull-right">开始新一期</a>
                 <% } %>
             </div>
@@ -61,8 +65,19 @@
                                 <td class="text-right"><%- item.prev_total_amount%></td>
                                 <td><a class="btn btn-sm" href="#file" data-toggle="modal" data-target="#file"><i
                                             class="fa fa-paperclip "></i> 3</a></td>
-                                <td><%- auditConst.statusString[item.status]%></td>
-                                <td><a href="/tender/<%- ctx.tender.id %>/advance/<%- item.id %>/detail" class="btn btn-primary btn-sm">编辑</a></td>
+                                <td>
+                                    <% if (item.curAuditor) { %>
+                                        <a href="#sp-list" data-toggle="modal" data-target="#sp-list" m-order="<%- item.order %>"><%- item.curAuditor.name %><%if (item.curAuditor.role !== '' && item.curAuditor.role !== null) { %>-<%- item.curAuditor.role %><% } %></a>
+                                    <% } %>
+                                    <span class="<%- auditConst.statusClass[item.status] %>">
+                                        <%- auditConst.statusString[item.status] %>
+                                    </span>
+                                </td>
+                                <td>
+                                    <% if(item.status === auditConst.status.uncheck || item.status === auditConst.status.checkNo) { %>
+                                        <a href="/tender/<%- ctx.tender.id %>/advance/<%- item.id %>/detail" class="btn btn-primary btn-sm">编辑</a>
+                                    <% }%>
+                                </td>
                             </tr>
                         <% }) %>
                     </tbody>
@@ -75,4 +90,5 @@
 <script>
     const type = parseInt('<%- type %>');
     const auditConst = JSON.parse('<%- JSON.stringify(auditConst) %>');
+    const advanceList = JSON.parse('<%- JSON.stringify(advanceList) %>');
 </script>