Browse Source

决策大屏统一获取数据

laiguoran 3 years ago
parent
commit
99ba6c8f78
2 changed files with 6 additions and 10 deletions
  1. 2 6
      app/controller/datacollect_controller.js
  2. 4 4
      app/service/stage.js

+ 2 - 6
app/controller/datacollect_controller.js

@@ -114,12 +114,8 @@ module.exports = app => {
                     t.advance_tp = await ctx.service.advance.getSumAdvance(t.id);
 
                     if (t.ledger_status === auditConst.ledger.status.checked) {
-                        t.lastStage = await ctx.service.stage.getLastestStage(t.id, true);
-                        if (t.lastStage && t.lastStage.status === auditConst.stage.status.uncheck &&
-                            t.lastStage.user_id !== ctx.session.sessionUser.accountId) {
-                            t.lastStage = await ctx.service.stage.getLastestStage(t.id);
-                        }
-                        if (t.lastStage) await ctx.service.stage.checkStageGatherData(t.lastStage);
+                        t.lastStage = await ctx.service.stage.getLastestStage(t.id);
+                        if (t.lastStage) await ctx.service.stage.checkStageGatherData(t.lastStage, true);
                         t.completeStage = await ctx.service.stage.getLastestCompleteStage(t.id);
                         if ((!bCalcTp) && t.measure_type === measureType.gcl.value) {
                             bCalcTp = t.lastStage && t.lastStage.status !== auditConst.stage.status.checked && !t.lastStage.readOnly;

+ 4 - 4
app/service/stage.js

@@ -68,7 +68,7 @@ module.exports = app => {
             return result;
         }
 
-        async doCheckStage(stage) {
+        async doCheckStage(stage, formDataCollect = false) {
             const status = auditConst.status;
             stage.auditors = await this.ctx.service.stageAudit.getAuditors(stage.id, stage.times);
             stage.curAuditor = await this.ctx.service.stageAudit.getCurAuditor(stage.id, stage.times);
@@ -91,7 +91,7 @@ module.exports = app => {
                 } else {
                     stage.curOrder = stage.curAuditor.aid === accountId ? stage.curAuditor.order : stage.curAuditor.order - 1;
                 }
-            } else if (this.ctx.tender && this.ctx.tender.isTourist) { // 游客
+            } else if ((this.ctx.tender && this.ctx.tender.isTourist) || formDataCollect) { // 游客
                 stage.readOnly = true;
                 stage.curTimes = stage.times;
                 if (stage.status === status.uncheck || stage.status === status.checkNo) {
@@ -218,10 +218,10 @@ module.exports = app => {
             return await this.db.query(sql, sqlParam);
         }
 
-        async checkStageGatherData(stage) {
+        async checkStageGatherData(stage, formDataCollect = false) {
             // 最新一期计量(未审批完成),当前操作人的期详细数据,应实时计算
             if (stage.status !== auditConst.status.checked) {
-                await this.doCheckStage(stage);
+                await this.doCheckStage(stage, formDataCollect);
                 if (!stage.readOnly && stage.check_calc) {
                     const tpData = await this.ctx.service.stageBills.getSumTotalPrice(stage);
                     stage.contract_tp = tpData.contract_tp;