Explorar el Código

多人协同审批流程相关

MaiXinRong hace 2 años
padre
commit
82a39f4990
Se han modificado 2 ficheros con 9 adiciones y 1 borrados
  1. 7 1
      app/service/cooperation_confirm.js
  2. 2 0
      app/service/stage_audit.js

+ 7 - 1
app/service/cooperation_confirm.js

@@ -89,6 +89,8 @@ module.exports = app => {
             if (!transaction) throw '缺少参数';
             // 审批人数据锁定
             const lockConfirm = await this.getAllDataByCondition({ where: { sid: stage.id, times: stage.curTimes, uid: uid } });
+            if (lockConfirm.length === 0) return;
+
             const insertData = [];
             lockConfirm.forEach(x => {
                 delete x.id;
@@ -112,7 +114,11 @@ module.exports = app => {
                     insertData.push(kc);
                 }
             }
-            await transaction.insert(this.tableName, insertData);
+            if (insertData.length > 0) await transaction.insert(this.tableName, insertData);
+        }
+
+        async cancelLock(stage, uid, transaction) {
+            await transaction.update(this.tableName, { lock: 0 }, { sid: stage.id, times: stage.curTimes, uid });
         }
 
         async getLockedId(tender, stage) {

+ 2 - 0
app/service/stage_audit.js

@@ -444,6 +444,8 @@ module.exports = app => {
                         tp_history: JSON.stringify(this.ctx.stage.tp_history),
                         cache_time_r: this.ctx.stage.cache_time_l,
                     });
+                    // 多人协同,取消下一审批人存在的锁定
+                    await this.ctx.service.cooperationConfirm.cancelLock(this.ctx.stage, nextAudit.id, transaction);
 
                     // 添加短信通知-需要审批提醒功能
                     // const smsUser = await this.ctx.service.projectAccount.getDataById(nextAudit.aid);