Browse Source

feat: 仪表盘-变更数据查询优化

lanjianrong 4 days ago
parent
commit
685d4d4b4b

+ 96 - 19
app/controller/weapp_dashboard_controller.js

@@ -7,15 +7,15 @@ module.exports = app => {
     class WeappDashboardController extends app.BaseController {
     class WeappDashboardController extends app.BaseController {
         async workspace(ctx) {
         async workspace(ctx) {
             try {
             try {
-                // const allAuditTenders = await ctx.service.ledgerAudit.getAuditTender(ctx.session.sessionUser.id);
+                const allAuditTenders = await ctx.service.ledgerAudit.getAuditTender(ctx.session.sessionUser.id);
                 const allAuditStages = await ctx.service.stageAudit.getAuditStage(ctx.session.sessionUser.id);
                 const allAuditStages = await ctx.service.stageAudit.getAuditStage(ctx.session.sessionUser.id);
-                const allAuditChanges = await ctx.service.changeAudit.getAuditChange(ctx.session.sessionUser.id);
-                // const allAuditRevise = await ctx.service.reviseAudit.getAuditRevise(ctx.session.sessionUser.id);
+                const allAuditRevise = await ctx.service.reviseAudit.getAuditRevise(ctx.session.sessionUser.id);
                 const allAuditMaterial = await ctx.service.materialAudit.getAuditMaterial(ctx.session.sessionUser.id);
                 const allAuditMaterial = await ctx.service.materialAudit.getAuditMaterial(ctx.session.sessionUser.id);
                 const allAuditAdvance = await ctx.service.advanceAudit.getAuditAdvance(ctx.session.sessionUser.id);
                 const allAuditAdvance = await ctx.service.advanceAudit.getAuditAdvance(ctx.session.sessionUser.id);
-                const allAuditChangeProject = await ctx.service.changeProjectAudit.getAuditChangeProject(ctx.session.sessionUser.id);
-                const allAuditChangeApply = await ctx.service.changeApplyAudit.getAuditChangeApply(ctx.session.sessionUser.id);
-                const allAuditChangePlan = await ctx.service.changePlanAudit.getAuditChangePlan(ctx.session.sessionUser.id);
+                const allAuditChanges = await ctx.service.changeAudit.getAuditChangeByWeapp(ctx.session.sessionUser.id, '', true);
+                const allAuditChangeProject = await ctx.service.changeProjectAudit.getAuditChangeProject(ctx.session.sessionUser.id, '', true);
+                const allAuditChangeApply = await ctx.service.changeApplyAudit.getAuditChangeApply(ctx.session.sessionUser.id, '', true);
+                const allAuditChangePlan = await ctx.service.changePlanAudit.getAuditChangePlan(ctx.session.sessionUser.id, '', true);
                 // const allAuditPayments = await ctx.service.paymentDetailAudit.getAuditPayment(ctx.session.sessionUser.id);
                 // const allAuditPayments = await ctx.service.paymentDetailAudit.getAuditPayment(ctx.session.sessionUser.id);
                 // const allAuditStageAss = await ctx.service.stageAuditAss.getAuditStageAss(ctx.session.sessionUser.id);
                 // const allAuditStageAss = await ctx.service.stageAuditAss.getAuditStageAss(ctx.session.sessionUser.id);
                 // const allAuditFinancials = await ctx.service.financialPayAudit.getAuditFinancial(ctx.session.sessionUser.id);
                 // const allAuditFinancials = await ctx.service.financialPayAudit.getAuditFinancial(ctx.session.sessionUser.id);
@@ -53,24 +53,101 @@ module.exports = app => {
                 }
                 }
 
 
                 const dashboardShenpis = [];
                 const dashboardShenpis = [];
-                // const auditTenders = await DashboardStats.auditSet(ctx, allAuditTenders, subProjects, dashboardStatus, 'ledger');
-                // dashboardShenpis.push(...auditTenders);
+                const auditTenders = await DashboardStats.auditSet(ctx, allAuditTenders, subProjects, dashboardStatus, 'ledger');
+                dashboardShenpis.push(...(auditTenders.map(item => ({ ...item, type: 'ledger', subType: 'ledger' }))));
                 const auditStages = await DashboardStats.auditSet(ctx, allAuditStages, subProjects, dashboardStatus, 'stage');
                 const auditStages = await DashboardStats.auditSet(ctx, allAuditStages, subProjects, dashboardStatus, 'stage');
                 dashboardShenpis.push(...(auditStages.map(item => ({ ...item, type: 'stage', subType: 'stage' }))));
                 dashboardShenpis.push(...(auditStages.map(item => ({ ...item, type: 'stage', subType: 'stage' }))));
                 const auditChanges = await DashboardStats.auditSet(ctx, allAuditChanges, subProjects, dashboardStatus, 'change');
                 const auditChanges = await DashboardStats.auditSet(ctx, allAuditChanges, subProjects, dashboardStatus, 'change');
-                dashboardShenpis.push(...(auditChanges.map(item => ({ ...item, type: 'change', subType: 'change' }))));
-                // const auditRevise = await DashboardStats.auditSet(ctx, allAuditRevise, subProjects, dashboardStatus, 'revise');
-                // dashboardShenpis.push(...auditRevise);
+                for (const item of auditChanges) {
+                  let sp = null;
+                  if (item.spid) {
+                      if (ctx.helper._.findIndex(subProjects, { id: item.spid }) !== -1) {
+                          sp = ctx.helper._.find(subProjects, { id: item.spid });
+                      } else {
+                          sp = await ctx.service.subProject.getDataById(item.spid);
+                          subProjects.push(sp);
+                      }
+                  }
+
+                  if (sp && sp.page_show) {
+                      if (sp.page_show.openChangeProject) {
+                        dashboardShenpis.push({ ...item, type: 'change', subType: 'change' });
+                      }
+                  }
+                }
+
+                const auditRevise = await DashboardStats.auditSet(ctx, allAuditRevise, subProjects, dashboardStatus, 'revise');
+                dashboardShenpis.push(...(auditRevise.map(item => ({ ...item, type: 'revise', subType: 'revise' }))));
                 const auditMaterial = await DashboardStats.auditSet(ctx, allAuditMaterial, subProjects, dashboardStatus, 'material');
                 const auditMaterial = await DashboardStats.auditSet(ctx, allAuditMaterial, subProjects, dashboardStatus, 'material');
-                dashboardShenpis.push(...(auditMaterial.map(item => ({ ...item, type: 'material', subType: 'material' }))));
+                for (const item of auditMaterial) {
+                  let sp = null;
+                  if (item.spid) {
+                      if (ctx.helper._.findIndex(subProjects, { id: item.spid }) !== -1) {
+                          sp = ctx.helper._.find(subProjects, { id: item.spid });
+                      } else {
+                          sp = await ctx.service.subProject.getDataById(item.spid);
+                          subProjects.push(sp);
+                      }
+                  }
+                  if (sp && sp.page_show) {
+                      if (sp.page_show.openMaterial) {
+                        dashboardShenpis.push({ ...item, type: 'material', subType: 'material' });
+                      }
+                  }
+                }
                 const auditAdvance = await DashboardStats.auditSet(ctx, allAuditAdvance, subProjects, dashboardStatus, 'advance');
                 const auditAdvance = await DashboardStats.auditSet(ctx, allAuditAdvance, subProjects, dashboardStatus, 'advance');
                 dashboardShenpis.push(...(auditAdvance.map(item => ({ ...item, type: 'advance', subType: 'advance' }))));
                 dashboardShenpis.push(...(auditAdvance.map(item => ({ ...item, type: 'advance', subType: 'advance' }))));
                 const auditChangeProject = await DashboardStats.auditSet(ctx, allAuditChangeProject, subProjects, dashboardStatus, 'changeProject');
                 const auditChangeProject = await DashboardStats.auditSet(ctx, allAuditChangeProject, subProjects, dashboardStatus, 'changeProject');
-                dashboardShenpis.push(...(auditChangeProject.map(item => ({ ...item, type: 'change', subType: 'changeProject' }))));
+                for (const item of auditChangeProject) {
+                  let sp = null;
+                  if (item.spid) {
+                      if (ctx.helper._.findIndex(subProjects, { id: item.spid }) !== -1) {
+                          sp = ctx.helper._.find(subProjects, { id: item.spid });
+                      } else {
+                          sp = await ctx.service.subProject.getDataById(item.spid);
+                          subProjects.push(sp);
+                      }
+                  }
+                  if (sp && sp.page_show) {
+                      if (sp.page_show.openChangeProject) {
+                        dashboardShenpis.push({ ...item, type: 'change', subType: 'changeProject' });
+                      }
+                  }
+                }
                 const auditChangeApply = await DashboardStats.auditSet(ctx, allAuditChangeApply, subProjects, dashboardStatus, 'changeApply');
                 const auditChangeApply = await DashboardStats.auditSet(ctx, allAuditChangeApply, subProjects, dashboardStatus, 'changeApply');
-                dashboardShenpis.push(...(auditChangeApply.map(item => ({ ...item, type: 'change', subType: 'changeApply' }))));
+                for (const item of auditChangeApply) {
+                  let sp = null;
+                  if (item.spid) {
+                      if (ctx.helper._.findIndex(subProjects, { id: item.spid }) !== -1) {
+                          sp = ctx.helper._.find(subProjects, { id: item.spid });
+                      } else {
+                          sp = await ctx.service.subProject.getDataById(item.spid);
+                          subProjects.push(sp);
+                      }
+                  }
+                  if (sp && sp.page_show) {
+                      if (sp.page_show.openChangeApply) {
+                        dashboardShenpis.push({ ...item, type: 'change', subType: 'changeApply' });
+                      }
+                  }
+                }
                 const auditChangePlan = await DashboardStats.auditSet(ctx, allAuditChangePlan, subProjects, dashboardStatus, 'changePlan');
                 const auditChangePlan = await DashboardStats.auditSet(ctx, allAuditChangePlan, subProjects, dashboardStatus, 'changePlan');
-                dashboardShenpis.push(...(auditChangePlan.map(item => ({ ...item, type: 'change', subType: 'changePlan' }))));
+                for (const item of auditChangePlan) {
+                    let sp = null;
+                  if (item.spid) {
+                      if (ctx.helper._.findIndex(subProjects, { id: item.spid }) !== -1) {
+                          sp = ctx.helper._.find(subProjects, { id: item.spid });
+                      } else {
+                          sp = await ctx.service.subProject.getDataById(item.spid);
+                          subProjects.push(sp);
+                      }
+                  }
+                  if (sp && sp.page_show) {
+                      if (sp.page_show.openChangePlan) {
+                        dashboardShenpis.push({ ...item, type: 'change', subType: 'changePlan' });
+                      }
+                  }
+                }
                 // const auditPayments = await DashboardStats.auditSet(ctx, allAuditPayments, subProjects, dashboardStatus, 'payment');
                 // const auditPayments = await DashboardStats.auditSet(ctx, allAuditPayments, subProjects, dashboardStatus, 'payment');
                 // dashboardShenpis.push(...auditPayments);
                 // dashboardShenpis.push(...auditPayments);
                 // const auditStageAss = await DashboardStats.auditSet(ctx, allAuditStageAss, subProjects, dashboardStatus, 'stageAss');
                 // const auditStageAss = await DashboardStats.auditSet(ctx, allAuditStageAss, subProjects, dashboardStatus, 'stageAss');
@@ -79,10 +156,10 @@ module.exports = app => {
                 // dashboardShenpis.push(...auditFinancials);
                 // dashboardShenpis.push(...auditFinancials);
                 // const auditInspections = await DashboardStats.auditSet(ctx, allAuditInspections, subProjects, dashboardStatus, 'inspection');
                 // const auditInspections = await DashboardStats.auditSet(ctx, allAuditInspections, subProjects, dashboardStatus, 'inspection');
                 // dashboardShenpis.push(...auditInspections);
                 // dashboardShenpis.push(...auditInspections);
-                const auditQualityInspections = await DashboardStats.auditSet(ctx, allAuditQualityInspections, subProjects, dashboardStatus, 'inspection');
-                dashboardShenpis.push(...(auditQualityInspections.map(item => ({ ...item, type: 'qualityInspection', subType: 'qualityInspection' }))));
-                const auditSafeInspections = await DashboardStats.auditSet(ctx, allAuditSafeInspections, subProjects, dashboardStatus, 'safeInspection');
-                dashboardShenpis.push(...(auditSafeInspections.map(item => ({ ...item, type: 'safeInspection', subType: 'safeInspection' }))));
+                // const auditQualityInspections = await DashboardStats.auditSet(ctx, allAuditQualityInspections, subProjects, dashboardStatus, 'inspection');
+                // dashboardShenpis.push(...(auditQualityInspections.map(item => ({ ...item, type: 'qualityInspection', subType: 'qualityInspection' }))));
+                // const auditSafeInspections = await DashboardStats.auditSet(ctx, allAuditSafeInspections, subProjects, dashboardStatus, 'safeInspection');
+                // dashboardShenpis.push(...(auditSafeInspections.map(item => ({ ...item, type: 'safeInspection', subType: 'safeInspection' }))));
 
 
                 // const auditPhasePay = await DashboardStats.auditSet(ctx, allAuditPhasePay, subProjects, dashboardStatus, 'phasePay');
                 // const auditPhasePay = await DashboardStats.auditSet(ctx, allAuditPhasePay, subProjects, dashboardStatus, 'phasePay');
                 // dashboardShenpis.push(...auditPhasePay);
                 // dashboardShenpis.push(...auditPhasePay);

+ 7 - 7
app/controller/weapp_tender_controller.js

@@ -517,19 +517,19 @@ module.exports = app => {
 
 
         async changeCheck(ctx) {
         async changeCheck(ctx) {
             try {
             try {
-                const { type } = ctx.request.query || ctx.request.body;
+                const type = ctx.request.query.type || ctx.request.body.type;
                 const curChangeMap = changeMap[type];
                 const curChangeMap = changeMap[type];
+
                 const subProject = await ctx.service.subProject.getDataById(ctx.tender.data.spid);
                 const subProject = await ctx.service.subProject.getDataById(ctx.tender.data.spid);
                 if (curChangeMap && curChangeMap.pageShowKey && !subProject.page_show[curChangeMap.pageShowKey]) {
                 if (curChangeMap && curChangeMap.pageShowKey && !subProject.page_show[curChangeMap.pageShowKey]) {
                     throw '该功能已关闭';
                     throw '该功能已关闭';
                 }
                 }
-                const id = ctx.request.query.id || this.request.body.id;
+                const id = ctx.request.query.id || ctx.request.body.id;
                 if (!id) {
                 if (!id) {
                     throw '您访问的变更数据不存在';
                     throw '您访问的变更数据不存在';
                 }
                 }
                 const condition = { [type === 'change' ? 'cid' : 'id']: id };
                 const condition = { [type === 'change' ? 'cid' : 'id']: id };
                 const change = await ctx.service[curChangeMap.service].getDataByCondition(condition);
                 const change = await ctx.service[curChangeMap.service].getDataByCondition(condition);
-                console.log(change);
 
 
                 if (!change) throw '变更方案数据有误';
                 if (!change) throw '变更方案数据有误';
                 // 读取原报、审核人数据
                 // 读取原报、审核人数据
@@ -588,7 +588,7 @@ module.exports = app => {
         async changeDetail(ctx) {
         async changeDetail(ctx) {
             try {
             try {
                 await this.changeCheck(ctx);
                 await this.changeCheck(ctx);
-                const { type } = ctx.request.query || ctx.request.body;
+                const type = ctx.request.query.type;
                 const curChangeMap = changeMap[type];
                 const curChangeMap = changeMap[type];
                 await ctx.service[curChangeMap.service].loadChangeUser(this.change);
                 await ctx.service[curChangeMap.service].loadChangeUser(this.change);
                 await ctx.service[curChangeMap.service].loadChangeAuditViewData(this.change);
                 await ctx.service[curChangeMap.service].loadChangeAuditViewData(this.change);
@@ -610,6 +610,7 @@ module.exports = app => {
 
 
                 const change = {
                 const change = {
                     id: this.change.id || this.change.cid,
                     id: this.change.id || this.change.cid,
+                    tid: ctx.tender.id,
                     name: this.change.name,
                     name: this.change.name,
                     status: this.change.status,
                     status: this.change.status,
                     code: this.change.code,
                     code: this.change.code,
@@ -711,8 +712,7 @@ module.exports = app => {
                 await this.changeCheck(ctx);
                 await this.changeCheck(ctx);
                 await this.changeAuditCheck(ctx);
                 await this.changeAuditCheck(ctx);
                 const curChangeMap = changeMap[type];
                 const curChangeMap = changeMap[type];
-                const auditConst = auditConsts[type];
-                if (!ctx.change || ctx.change.status !== auditConst.status.checking) {
+                if (!ctx.change || ctx.change.status !== auditConst[type].status.checking) {
                     throw '当前变更申请数据有误';
                     throw '当前变更申请数据有误';
                 }
                 }
                 if (ctx.change.curAuditorIds.length === 0 || ctx.change.curAuditorIds.indexOf(ctx.session.sessionUser.accountId) === -1) {
                 if (ctx.change.curAuditorIds.length === 0 || ctx.change.curAuditorIds.indexOf(ctx.session.sessionUser.accountId) === -1) {
@@ -725,7 +725,7 @@ module.exports = app => {
                 if (!data.checkType || isNaN(data.checkType)) {
                 if (!data.checkType || isNaN(data.checkType)) {
                     throw '提交数据错误';
                     throw '提交数据错误';
                 }
                 }
-                await ctx.service[auditConst.auditService].check(ctx.change.id, data, ctx.change.times);
+                await ctx.service[curChangeMap.auditService].check(ctx.change.id, data, ctx.change.times);
                 ctx.body = { code: 0, msg: '操作成功', data: null };
                 ctx.body = { code: 0, msg: '操作成功', data: null };
             } catch (error) {
             } catch (error) {
                 this.log(error);
                 this.log(error);

+ 5 - 2
app/service/change_apply_audit.js

@@ -390,9 +390,9 @@ module.exports = app => {
          * @param auditorId
          * @param auditorId
          * @return {Promise<*>}
          * @return {Promise<*>}
          */
          */
-        async getAuditChangeApply(auditorId, spid = '') {
+        async getAuditChangeApply(auditorId, spid = '', filterReport = false) {
             const spSql = spid ? ' and t.`spid` = "' + spid + '"' : '';
             const spSql = spid ? ' and t.`spid` = "' + spid + '"' : '';
-            const sql = 'SELECT ma.`aid`, ma.`times`, ma.`order`, ma.`begin_time`, ma.`end_time`, ma.`tid`, ma.`caid`,' +
+            const sql = 'SELECT ma.`aid`, ma.`times`, ma.`order`, ma.`audit_order`, ma.`begin_time`, ma.`end_time`, ma.`tid`, ma.`caid`,' +
                 '    m.`status` As `mstatus`, m.`code` As `mcode`,' +
                 '    m.`status` As `mstatus`, m.`code` As `mcode`,' +
                 '    t.`name`, t.`project_id`, t.`type`, t.`user_id`, t.`spid` ' +
                 '    t.`name`, t.`project_id`, t.`type`, t.`user_id`, t.`spid` ' +
                 '  FROM ?? AS ma LEFT JOIN ?? AS m ON  ma.`caid` = m.`id` LEFT JOIN ?? As t ON ma.`tid` = t.`id`' +
                 '  FROM ?? AS ma LEFT JOIN ?? AS m ON  ma.`caid` = m.`id` LEFT JOIN ?? As t ON ma.`tid` = t.`id`' +
@@ -405,6 +405,9 @@ module.exports = app => {
             const caidArr = [];
             const caidArr = [];
             for (const r of result) {
             for (const r of result) {
                 if (caidArr.indexOf(r.caid) === -1) {
                 if (caidArr.indexOf(r.caid) === -1) {
+                    if (filterReport && r.mstatus === auditConst.status.checkNo && r.audit_order === 0) {
+                        continue;
+                    }
                     filterResult.push(r);
                     filterResult.push(r);
                     caidArr.push(r.caid);
                     caidArr.push(r.caid);
                 }
                 }

+ 18 - 1
app/service/change_audit.js

@@ -217,7 +217,7 @@ module.exports = app => {
          * @param uid
          * @param uid
          * @return {Promise<void>}
          * @return {Promise<void>}
          */
          */
-        async getAuditChange(uid, spid = '') {
+        async getAuditChange(uid, spid = '', ) {
             // const sql = 'SELECT ca.`uid`, ca.`times`, ca.`usite`, ca.`usort`, ca.`tid`, ca.`cid`, ca.`begin_time`, ca.`end_time`, ca.`sin_time`, ca.`name` As `caname`, ' +
             // const sql = 'SELECT ca.`uid`, ca.`times`, ca.`usite`, ca.`usort`, ca.`tid`, ca.`cid`, ca.`begin_time`, ca.`end_time`, ca.`sin_time`, ca.`name` As `caname`, ' +
             //     '    c.`code` As `ccode`, c.`name` As `cname`, c.`status` As `cstatus`, c.`cin_time`, ' +
             //     '    c.`code` As `ccode`, c.`name` As `cname`, c.`status` As `cstatus`, c.`cin_time`, ' +
             //     '    t.`name`, t.`type`, t.`user_id` ' +
             //     '    t.`name`, t.`type`, t.`user_id` ' +
@@ -251,6 +251,23 @@ module.exports = app => {
         }
         }
 
 
         /**
         /**
+         * weapp获取 审核人 待审批的() 变更令列表
+         */
+          async getAuditChangeByWeapp(uid, spid = '') {
+            const spSql = spid ? ' and t.`spid` = "' + spid + '"' : '';
+            const sql = 'SELECT ca.`uid`, ca.`times`, ca.`usite`, ca.`usort`, ca.`tid`, ca.`cid`, ca.`begin_time`, ca.`end_time`, ca.`sin_time`, ca.`name` As `caname`, ' +
+                '    c.`code` As `ccode`, c.`name` As `cname`, c.`status` As `cstatus`, c.`cin_time`, ' +
+                '    t.`name`, t.`type`, t.`user_id`, t.`spid` ' +
+                '  FROM ?? AS ca LEFT JOIN ?? AS c ON ca.`cid` = c.`cid` ' +
+                '    LEFT JOIN ?? As t ON ca.`tid` = t.`id` ' +
+                '  WHERE ca.`uid` = ? and ca.`status` = ? and c.`status` != ? and ca.`usite` != ?' + spSql +
+                '  ORDER BY ca.`begin_time` DESC';
+            const sqlParam = [this.tableName, this.ctx.service.change.tableName, this.ctx.service.tender.tableName, uid, auditConst.status.checking, auditConst.status.uncheck, 0];
+            const changes = await this.db.query(sql, sqlParam);
+            return changes;
+          }
+
+        /**
          * 获取审核人审核的次数
          * 获取审核人审核的次数
          *
          *
          * @param auditorId
          * @param auditorId

+ 5 - 2
app/service/change_plan_audit.js

@@ -388,9 +388,9 @@ module.exports = app => {
          * @param auditorId
          * @param auditorId
          * @return {Promise<*>}
          * @return {Promise<*>}
          */
          */
-        async getAuditChangePlan(auditorId, spid = '') {
+        async getAuditChangePlan(auditorId, spid = '', filterReport = false) {
             const spSql = spid ? ' and t.`spid` = "' + spid + '"' : '';
             const spSql = spid ? ' and t.`spid` = "' + spid + '"' : '';
-            const sql = 'SELECT ma.`aid`, ma.`times`, ma.`order`, ma.`begin_time`, ma.`end_time`, ma.`tid`, ma.`cpid`,' +
+            const sql = 'SELECT ma.`aid`, ma.`times`, ma.`audit_order`, ma.`order`, ma.`begin_time`, ma.`end_time`, ma.`tid`, ma.`cpid`,' +
                 '    m.`status` As `mstatus`, m.`code` As `mcode`,' +
                 '    m.`status` As `mstatus`, m.`code` As `mcode`,' +
                 '    t.`name`, t.`project_id`, t.`type`, t.`user_id`, t.`spid` ' +
                 '    t.`name`, t.`project_id`, t.`type`, t.`user_id`, t.`spid` ' +
                 '  FROM ?? AS ma LEFT JOIN ?? AS m ON  ma.`cpid` = m.`id` LEFT JOIN ?? As t ON ma.`tid` = t.`id`' +
                 '  FROM ?? AS ma LEFT JOIN ?? AS m ON  ma.`cpid` = m.`id` LEFT JOIN ?? As t ON ma.`tid` = t.`id`' +
@@ -403,6 +403,9 @@ module.exports = app => {
             const cpidArr = [];
             const cpidArr = [];
             for (const r of result) {
             for (const r of result) {
                 if (cpidArr.indexOf(r.cpid) === -1) {
                 if (cpidArr.indexOf(r.cpid) === -1) {
+                    if (filterReport && r.mstatus === auditConst.status.checkNo && r.audit_order === 0) {
+                        continue;
+                    }
                     filterResult.push(r);
                     filterResult.push(r);
                     cpidArr.push(r.cpid);
                     cpidArr.push(r.cpid);
                 }
                 }

+ 6 - 3
app/service/change_project_audit.js

@@ -397,9 +397,9 @@ module.exports = app => {
          * @param auditorId
          * @param auditorId
          * @return {Promise<*>}
          * @return {Promise<*>}
          */
          */
-        async getAuditChangeProject(auditorId, spid = '') {
+        async getAuditChangeProject(auditorId, spid = '', filterReport = false) {
             const spSql = spid ? ' and t.`spid` = "' + spid + '"' : '';
             const spSql = spid ? ' and t.`spid` = "' + spid + '"' : '';
-            const sql = 'SELECT ma.`aid`, ma.`times`, ma.`order`, ma.`begin_time`, ma.`end_time`, ma.`tid`, ma.`cpid`,' +
+            const sql = 'SELECT ma.`aid`, ma.`times`, ma.`audit_order`, ma.`order`, ma.`begin_time`, ma.`end_time`, ma.`tid`, ma.`cpid`,' +
                 '    m.`status` As `mstatus`, m.`code` As `mcode`,' +
                 '    m.`status` As `mstatus`, m.`code` As `mcode`,' +
                 '    t.`name`, t.`project_id`, t.`type`, t.`user_id`, t.`spid` ' +
                 '    t.`name`, t.`project_id`, t.`type`, t.`user_id`, t.`spid` ' +
                 '  FROM ?? AS ma LEFT JOIN ?? AS m ON  ma.`cpid` = m.`id` LEFT JOIN ?? As t ON ma.`tid` = t.`id`' +
                 '  FROM ?? AS ma LEFT JOIN ?? AS m ON  ma.`cpid` = m.`id` LEFT JOIN ?? As t ON ma.`tid` = t.`id`' +
@@ -412,8 +412,11 @@ module.exports = app => {
             const cpidArr = [];
             const cpidArr = [];
             for (const r of result) {
             for (const r of result) {
                 if (cpidArr.indexOf(r.cpid) === -1) {
                 if (cpidArr.indexOf(r.cpid) === -1) {
-                    filterResult.push(r);
+                    if (filterReport && r.mstatus === auditConst.status.back && r.audit_order === 0) {
+                        continue;
+                    }
                     cpidArr.push(r.cpid);
                     cpidArr.push(r.cpid);
+                    filterResult.push(r);
                 }
                 }
             }
             }
             return filterResult;
             return filterResult;