Browse Source

合同管理测试bug修复

ellisran 8 months ago
parent
commit
f95ff5a084
1 changed files with 9 additions and 1 deletions
  1. 9 1
      app/controller/contract_controller.js

+ 9 - 1
app/controller/contract_controller.js

@@ -86,10 +86,15 @@ module.exports = app => {
                 const accountInfo = await this.ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
                 const userPermission = accountInfo !== undefined && accountInfo.permission !== ''
                     ? JSON.parse(accountInfo.permission) : null;
-                const tenderList = await ctx.service.tender.getContractList('', userPermission, ctx.session.sessionUser.is_admin);
+                let tenderList = await ctx.service.tender.getContractList('', userPermission, ctx.session.sessionUser.is_admin);
                 const projectList = await ctx.service.subProject.getSubProjectByTender(ctx.session.sessionProject.id, tenderList);
+                const removeTidList = [];
                 for (const t of tenderList) {
                     const spInfo = ctx.helper._.find(projectList, { id: t.spid });
+                    if (!spInfo) {
+                        removeTidList.push(t.id);
+                        continue;
+                    }
                     spInfo.child_order = spInfo.child_order ? spInfo.child_order : 0;
                     spInfo.is_folder = 1;
                     t.tree_pid = spInfo.id;
@@ -105,6 +110,9 @@ module.exports = app => {
                     t.income_total_price = incomeList.reduce((total, item) => ctx.helper.add(total, item.total_price), 0);
                     t.income_yf_price = incomeList.reduce((total, item) => ctx.helper.add(total, item.yf_price), 0);
                 }
+                if (removeTidList.length > 0) {
+                    tenderList = tenderList.filter(item => !removeTidList.includes(item.id));
+                }
                 const categoryData = await ctx.service.category.getAllCategory(ctx.session.sessionProject.id);
                 const renderData = {
                     // jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.contract.tender),