laiguoran před 2 roky
rodič
revize
5cc81a61c0
1 změnil soubory, kde provedl 18 přidání a 10 odebrání
  1. 18 10
      app/service/payment_detail_audit.js

+ 18 - 10
app/service/payment_detail_audit.js

@@ -51,16 +51,18 @@ module.exports = app => {
             const auditors = await this.getAuditGroupByList(preDetail.id, preDetail.times);
             const newAuditors = [];
             for (const a of auditors) {
-                const na = {
-                    tender_id: preDetail.tender_id,
-                    tr_id: preDetail.tr_id,
-                    td_id: newDetail.id,
-                    aid: a.aid,
-                    times: newDetail.times,
-                    order: newAuditors.length + 1,
-                    status: auditConst.status.uncheck,
-                };
-                newAuditors.push(na);
+                if (a.aid !== newDetail.uid) {
+                    const na = {
+                        tender_id: preDetail.tender_id,
+                        tr_id: preDetail.tr_id,
+                        td_id: newDetail.id,
+                        aid: a.aid,
+                        times: newDetail.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);
@@ -423,6 +425,7 @@ module.exports = app => {
 
         async _checkNo(pid, detailId, checkData, times) {
             const time = new Date();
+            const detailInfo = await ctx.service.paymentDetail.getDataById(detailId);
             // 整理当前流程审核人状态更新
             const audit = await this.getDataByCondition({ td_id: detailId, times, status: auditConst.status.checking });
             if (!audit) {
@@ -438,6 +441,11 @@ module.exports = app => {
                 a.status = auditConst.status.uncheck;
                 order++;
             }
+            // 可能更换了上报人且存在于审批流程中,需要删除
+            const userIndex = this._.findIndex(auditors, { aid: detailInfo.uid });
+            if (userIndex !== -1) {
+                auditors.splice(userIndex, 1);
+            }
             const transaction = await this.db.beginTransaction();
             try {
                 await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time });