Browse Source

审批设置bug修复

laiguoran 4 years ago
parent
commit
e8af628fbb
2 changed files with 28 additions and 13 deletions
  1. 23 12
      app/controller/tender_controller.js
  2. 5 1
      app/service/tender_info.js

+ 23 - 12
app/controller/tender_controller.js

@@ -764,21 +764,32 @@ module.exports = app => {
                 }
                 }
             }
             }
             const tenders = await ctx.service.tender.getList('', null, 1);
             const tenders = await ctx.service.tender.getList('', null, 1);
+            const removeTenders = [];
             for (const tender of tenders) {
             for (const tender of tenders) {
-                tender.shenpiInfo = await ctx.service.tenderInfo.getTenderShenpiInfo(tender.id);
-                // 获取所有的固定审批流或固定终审
-                const shenpiauditList = {};
-                for (const shenpi in tender.shenpiInfo) {
-                    if (tender.shenpiInfo[shenpi] === shenpiConst.sp_status.gdspl) {
-                        const shenpiList = await ctx.service.shenpiAudit.getAllDataByCondition({ where: { tid: tender.id, sp_type: shenpiConst.sp_type[shenpi], sp_status: tender.shenpiInfo[shenpi] } });
-                        const shenpiIdList = ctx.helper._.map(shenpiList, 'audit_id');
-                        shenpiauditList[shenpi] = shenpiIdList.length ? shenpiIdList : null;
-                    } else if (tender.shenpiInfo[shenpi] === shenpiConst.sp_status.gdzs) {
-                        const shenpiInfo = await ctx.service.shenpiAudit.getDataByCondition({ tid: tender.id, sp_type: shenpiConst.sp_type[shenpi], sp_status: tender.shenpiInfo[shenpi] });
-                        shenpiauditList[shenpi] = shenpiInfo && shenpiInfo.audit_id ? [shenpiInfo.audit_id] : null;
+                const shenpiInfo = await ctx.service.tenderInfo.getTenderShenpiInfo(tender.id);
+                if (!shenpiInfo) {
+                    removeTenders.push(tender.id);
+                } else {
+                    tender.shenpiInfo = shenpiInfo;
+                    // 获取所有的固定审批流或固定终审
+                    const shenpiauditList = {};
+                    for (const shenpi in tender.shenpiInfo) {
+                        if (tender.shenpiInfo[shenpi] === shenpiConst.sp_status.gdspl) {
+                            const shenpiList = await ctx.service.shenpiAudit.getAllDataByCondition({ where: { tid: tender.id, sp_type: shenpiConst.sp_type[shenpi], sp_status: tender.shenpiInfo[shenpi] } });
+                            const shenpiIdList = ctx.helper._.map(shenpiList, 'audit_id');
+                            shenpiauditList[shenpi] = shenpiIdList.length ? shenpiIdList : null;
+                        } else if (tender.shenpiInfo[shenpi] === shenpiConst.sp_status.gdzs) {
+                            const shenpiInfo = await ctx.service.shenpiAudit.getDataByCondition({ tid: tender.id, sp_type: shenpiConst.sp_type[shenpi], sp_status: tender.shenpiInfo[shenpi] });
+                            shenpiauditList[shenpi] = shenpiInfo && shenpiInfo.audit_id ? [shenpiInfo.audit_id] : null;
+                        }
                     }
                     }
+                    tender.shenpiauditList = shenpiauditList;
                 }
                 }
-                tender.shenpiauditList = shenpiauditList;
+            }
+            if (removeTenders.length > 0) {
+                ctx.helper._.remove(tenders, function(n) {
+                    return removeTenders.indexOf(n.id) !== -1;
+                });
             }
             }
             const categoryData = await ctx.service.category.getAllCategory(ctx.session.sessionProject.id);
             const categoryData = await ctx.service.category.getAllCategory(ctx.session.sessionProject.id);
             const renderData = {
             const renderData = {

+ 5 - 1
app/service/tender_info.js

@@ -342,7 +342,11 @@ module.exports = app => {
          */
          */
         async getTenderShenpiInfo(tenderId) {
         async getTenderShenpiInfo(tenderId) {
             const info = await this.getDataByCondition({ tid: tenderId });
             const info = await this.getDataByCondition({ tid: tenderId });
-            const shenpiInfo = !info.shenpi || info.shenpi === '' ? defaultInfo.shenpi : JSON.parse(info.shenpi);
+            // 还没选择模式的标段不应该可以选择审批流程设置
+            if (!info) {
+                return false;
+            }
+            const shenpiInfo = !info.shenpi || info.shenpi === null || info.shenpi === '' ? defaultInfo.shenpi : JSON.parse(info.shenpi);
             return shenpiInfo;
             return shenpiInfo;
         }
         }
     }
     }