Forráskód Böngészése

修复协同审批待办页bug

ellisran 1 éve
szülő
commit
c738ee39cd
1 módosított fájl, 14 hozzáadás és 5 törlés
  1. 14 5
      app/service/stage_audit_ass.js

+ 14 - 5
app/service/stage_audit_ass.js

@@ -43,12 +43,21 @@ module.exports = app => {
         async getAuditStageAss(ass_user_id) {
             // 找出待上报或待审批的协同字段
             const accountStageAssData = await this.getAllDataByCondition({ where: { ass_user_id } });
+            const lastStageList = [];
+            const tidList = this._.map(accountStageAssData, 'tid');
+            for (const t of tidList) {
+                const s = await this.ctx.service.stage.getLastestStage(t);
+                lastStageList.push(s);
+            }
             const accountStageAssDatas = [];
             for (const as of accountStageAssData) {
-                const asaIndex = accountStageAssDatas.findIndex(x => { return x.sid === as.sid; });
-                if (asaIndex === -1 || (asaIndex >= 0 && as.times > accountStageAssDatas[asaIndex].times)) {
-                    if (asaIndex >= 0 && as.times > accountStageAssDatas[asaIndex].times) accountStageAssDatas.splice(asaIndex, 1);
-                    accountStageAssDatas.push(as);
+                const s = this._.find(lastStageList, { tid: as.tid });
+                if (s.id === as.sid) {
+                    const asaIndex = accountStageAssDatas.findIndex(x => { return x.sid === as.sid; });
+                    if (asaIndex === -1 || (asaIndex >= 0 && as.times > accountStageAssDatas[asaIndex].times)) {
+                        if (asaIndex >= 0 && as.times > accountStageAssDatas[asaIndex].times) accountStageAssDatas.splice(asaIndex, 1);
+                        accountStageAssDatas.push(as);
+                    }
                 }
             }
             const result = [];
@@ -66,7 +75,7 @@ module.exports = app => {
             if (result.length > 0) {
                 for (const r of result) {
                     const t = await this.ctx.service.tender.getDataById(r.tid);
-                    const s = await this.ctx.service.stage.getLastestStage(r.tid);
+                    const s = this._.find(lastStageList, { tid: r.tid }) || await this.ctx.service.stage.getLastestStage(r.tid);
                     // const s = r.sid && r.sid === lasts.id ? lasts : await this.ctx.service.stage.getDataById(r.sid);
                     if (s) {
                         r.tender_name = t.name;