MaiXinRong 5 лет назад
Родитель
Сommit
3ab060e255
3 измененных файлов с 20 добавлено и 17 удалено
  1. 1 1
      app/service/report.js
  2. 18 15
      app/service/rpt_gather_memory.js
  3. 1 1
      builder_report_index_define.js

+ 1 - 1
app/service/report.js

@@ -122,7 +122,7 @@ module.exports = app => {
                             break;
                         case 'mem_gather_stage_bills':
                             runnableRst.push(service.rptGatherMemory.getGatherStageBills(memFieldKeys[filter],
-                                customDefine.gather_select.setting, customSelect ? customSelect.gather_select : null));
+                                customDefine.gather_select, customSelect ? customSelect.gather_select : null));
                             runnableKey.push(filter);
                             break;
                         default:

+ 18 - 15
app/service/rpt_gather_memory.js

@@ -117,8 +117,10 @@ module.exports = app => {
         }
 
         _checkSpecialTender(tender, special) {
-            for (const spec of special) {
-                if (tender[spec.key] === true) return spec.key;
+            if (special) {
+                for (const spec of special) {
+                    if (tender[spec.key] === true) return spec.key;
+                }
             }
             return '';
         }
@@ -166,8 +168,8 @@ module.exports = app => {
                 }
                 if (hasPre) {
                     const preStage = stage.order > 1 ? await this.ctx.service.stageBillsFinal.getFinalData(tender, stage.order - 1) : [];
-                    this.ctx.helper.assignRelaData(posData, [
-                        {data: preStage, fields: ['contract_qty', 'qc_qty'], prefix: 'pre_', relaId: 'pid'}
+                    this.ctx.helper.assignRelaData(billsData, [
+                        {data: preStage, fields: ['contract_qty', 'qc_qty'], prefix: 'pre_', relaId: 'lid'}
                     ]);
                 }
             }
@@ -268,14 +270,14 @@ module.exports = app => {
 
         async _gatherFinalData(sTender, index, hasPre) {
             const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
-            const stages = await this.db.select(this.tableName, {
+            const stages = await this.db.select(this.ctx.service.stage.tableName, {
                 where: { tid: tender.id },
                 orders: [['order', 'desc']],
             });
             if (stages.length !== 0) {
-                const lastStage = stages[stages.length - 1];
+                const lastStage = stages[0];
                 if (lastStage.status === auditConst.stage.status.uncheck && lastStage.user_id !== this.ctx.session.sessionUser.accountId) {
-                    stages.splice(stages.length - 1, 1);
+                    stages.splice(0, 1);
                 }
             }
             await this._gatherStageData(index, tender, stages[0], hasPre);
@@ -283,14 +285,14 @@ module.exports = app => {
 
         async _gatherCheckedFinalData(sTender, index, hasPre) {
             const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
-            const stages = await this.db.select(this.tableName, {
+            const stages = await this.db.select(this.ctx.service.stage.tableName, {
                 where: { tid: tender.id },
                 orders: [['order', 'desc']],
             });
             if (stages.length !== 0) {
-                const lastStage = stages[stages.length - 1];
+                const lastStage = stages[0];
                 if (lastStage.status !== auditConst.stage.status.checked) {
-                    stages.splice(stages.length - 1, 1);
+                    stages.splice(0, 1);
                 }
             }
             await this._gatherStageData(index, tender, stages[0], hasPre);
@@ -321,22 +323,23 @@ module.exports = app => {
             if (!gsDefine || !gsDefine.enable) return [];
             if (!gsCustom || !gsCustom.tenders || gsCustom.tenders.length === 0) return [];
 
+            const gsSetting = JSON.parse(gsDefine.setting);
             let commonIndex = 0;
             for (const tender of gsCustom.tenders) {
-                const specialKey = this._checkSpecialTender(tender, gsDefine.setting.special);
+                const specialKey = this._checkSpecialTender(tender, gsSetting.special);
                 if (specialKey === '') {
-                    switch (gsDefine.setting.type) {
+                    switch (gsSetting.type) {
                         case 'month':
-                            await this._gatherMonthData(tender, commonIndex, gsCustom.month, gsDefine.hasPre);
+                            await this._gatherMonthData(tender, commonIndex, gsCustom.month, gsSetting.hasPre);
                             break;
                         case 'zone':
                             await this._gatherZoneData(tender, commonIndex, gsCustom.zone);
                             break;
                         case 'final':
-                            await this._gatherFinalData(tender, commonIndex, gsDefine.hasPre);
+                            await this._gatherFinalData(tender, commonIndex, gsSetting.hasPre);
                             break;
                         case 'checked-final':
-                            await this._gatherCheckedFinalData(tender, commonIndex, gsDefine.hasPre);
+                            await this._gatherCheckedFinalData(tender, commonIndex, gsSetting.hasPre);
                             break;
                     }
                     commonIndex++;

+ 1 - 1
builder_report_index_define.js

@@ -466,7 +466,7 @@ const gather_stage_bills = {
         { name: '(标段)截止本期-完成-数量', field: 't_end_gather_qty', type: dataType.currency },
         { name: '(标段)截止本期-完成-金额', field: 't_end_gather_tp', type: dataType.currency },
 
-        { name: '(合计)台账-数量', field: 's_ty', type: dataType.currency },
+        { name: '(合计)台账-数量', field: 's_qty', type: dataType.currency },
         { name: '(合计)台账-金额', field: 's_tp', type: dataType.currency },
 
         { name: '(合计)本期-合同-数量', field: 's_contract_qty', type: dataType.currency },