Browse Source

1. 新增一期计量,复制上一期审批流程
2. 中间计量,来源为部位的中间计量,保存数据报错

MaiXinRong 6 years ago
parent
commit
6f9e76c21d
3 changed files with 34 additions and 1 deletions
  1. 1 1
      app/public/js/stage_im.js
  2. 7 0
      app/service/stage.js
  3. 26 0
      app/service/stage_audit.js

+ 1 - 1
app/public/js/stage_im.js

@@ -196,7 +196,7 @@ const stageIm = (function () {
             if (!im) {
                 const peg = getPegNode(node);
                 im = {
-                    lid: node.lid,
+                    lid: node.id,
                     code: p.b_code,
                     name: p.name,
                     unit: p.unit,

+ 7 - 0
app/service/stage.js

@@ -147,6 +147,13 @@ module.exports = app => {
                 } else {
                     throw '新增期数据失败';
                 }
+                // 存在上一期时,复制上一期审批流程
+                if (preStage) {
+                    const auditResult = await this.ctx.service.stageAudit.copyPreStageAuditors(transaction, preStage, newStage);
+                    if (!auditResult) {
+                        throw '复制上一期审批流程失败';
+                    }
+                }
                 // 新增期合同支付数据
                 const dealResult = await this.ctx.service.stagePay.addInitialStageData(newStage, transaction);
                 if (!dealResult) {

+ 26 - 0
app/service/stage_audit.js

@@ -389,6 +389,32 @@ module.exports = app => {
             // const sqlParam = [this.tableName, stageId, times];
             // return await this.db.query(sql, sqlParam);
         }
+
+        /**
+         * 复制上一期的审批人列表给最新一期
+         *
+         * @param transaction - 新增一期的事务
+         * @param {Object} preStage - 上一期
+         * @param {Object} newStage - 最新一期
+         * @returns {Promise<*>}
+         */
+        async copyPreStageAuditors(transaction, preStage, newStage) {
+            const auditors = await this.getAuditGroupByList(preStage.id, preStage.times);
+            const newAuditors = [];
+            for (const a of auditors) {
+                const na = {
+                    tid: preStage.tid,
+                    sid: newStage.id,
+                    aid: a.aid,
+                    times: newStage.times,
+                    order: newAuditors.length + 1,
+                    status: auditConst.status.uncheck
+                };
+                newAuditors.push(na);
+            }
+            const result = await transaction.insert(this.tableName, newAuditors);
+            return result.effectRows = auditors.length;
+        }
     }
 
     return StageAudit;