Browse Source

提交遗漏

MaiXinRong 4 years ago
parent
commit
59810045e8
1 changed files with 14 additions and 11 deletions
  1. 14 11
      app/lib/rptCustomData.js

+ 14 - 11
app/lib/rptCustomData.js

@@ -237,20 +237,15 @@ class jhHelper {
         const curStage = await this.ctx.service.stageBills.getLastestStageData(tender.id, stage.id);
         const preStage = stage.order > 1 ? await this.ctx.service.stageBillsFinal.getFinalData(tender, stage.order - 1) : [];
         const loadData = [
-            { data: curStage, fields: ['qc_qty', 'qc_tp'], prefix: '', relaId: 'lid' },
-            { data: preStage, fields: ['qc_qty', 'qc_tp'], prefix: 'pre_', relaId: 'lid' }
+            { data: curStage, fields: this.billsQueryField, prefix: '', relaId: 'lid' },
+            { data: preStage, fields: this.billsQueryField, prefix: 'pre_', relaId: 'lid' }
         ];
         for (const dc of gsDefine.defaultCompare) {
             const auditor = auditors[dc];
             const auditorStage = await this.ctx.service.stageBills.getAuditorStageData(tender.id, stage.id, auditor.times, auditor.order);
-            loadData.push({ data: auditorStage, fields: ['qc_qty', 'qc_tp'], prefix: `r${dc}_`, relaId: 'lid' });
+            loadData.push({ data: auditorStage, fields: this.billsQueryField, prefix: `r${dc}_`, relaId: 'lid' });
         }
         helper.assignRelaData(billsData, loadData);
-        // 计算截止本期
-        billsData.forEach(x => {
-            x.end_qc_qty = helper.add(x.qc_qty, x.pre_qc_qty);
-            x.end_qc_tp = helper.add(x.qc_tp, x.pre_qc_tp);
-        });
         return billsData;
     }
 
@@ -269,9 +264,6 @@ class jhHelper {
             loadData.push({ data: auditorStage, fields: ['qc_qty'], prefix: `r${dc}_`, relaId: 'pid' });
         }
         helper.assignRelaData(posData, loadData);
-        posData.forEach(x => {
-            x.end_qc_qty = helper.add(x.qc_qty, x.pre_qc_qty);
-        });
         return posData;
     }
 
@@ -288,7 +280,15 @@ class jhHelper {
             times: stage.curTimes, order: 0
         });
         const billsData = await this._loadStageBillsData(tender, stage, gsDefine, auditors);
+        // 计算截止本期
+        billsData.forEach(x => {
+            x.end_qc_qty = helper.add(x.qc_qty, x.pre_qc_qty);
+            x.end_qc_tp = helper.add(x.qc_tp, x.pre_qc_tp);
+        });
         const posData = await this._loadStagePosData(tender, stage, gsDefine, auditors);
+        posData.forEach(x => {
+            x.end_qc_qty = helper.add(x.qc_qty, x.pre_qc_qty);
+        });
         // 创建索引
         const billsIndex = {};
         for (const b of billsData) {
@@ -424,6 +424,7 @@ class jhHelper {
      * @returns {Promise<Array>}
      */
     async gather(memFieldKeys, gsDefine, gsCustom) {
+        this.billsQueryField = ['qc_qty', 'qc_tp'];
         if (!gsDefine || !gsDefine.enable) return [];
         if (!gsCustom || !gsCustom.tenders || gsCustom.tenders.length === 0) return [];
 
@@ -455,6 +456,7 @@ class jhHelper {
     }
 
     async convert(tid, sid, memFieldKeys, option) {
+        this.billsQueryField = ['qc_qty', 'qc_tp'];
         if (!option) return [];
         const setting = JSON.parse(option);
         if (!setting || !setting.defaultCompare) return [];
@@ -473,6 +475,7 @@ class jhHelper {
 
         const gsSetting = JSON.parse(gsDefine.setting);
         if (!gsSetting.defaultCompare) return [];
+        this.billsQueryField = ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp'];
         this.resultTree = new Ledger.gatherTree(this.ctx, {
             id: 'id',
             pid: 'pid',