Ver código fonte

数据预处理,调整

MaiXinRong 5 anos atrás
pai
commit
73ba546c95
2 arquivos alterados com 23 adições e 8 exclusões
  1. 1 4
      app/controller/report_controller.js
  2. 22 4
      app/lib/rpt_data_analysis.js

+ 1 - 4
app/controller/report_controller.js

@@ -653,11 +653,8 @@ async function getMultiRptsCommon(ctx, params, outputType, baseDir) {
             const dftOption = params.option || JV.PAGING_OPTION_NORMAL;
 
             printCom.initialize(rptTpl);
-            const cdDefine = await ctx.service.rptCustomDefine.getDataByCondition({
-                tid: params.tender_id, sid: params.stage_id, rid: params.rpt_tpl_id
-            });
             // console.log(rptTpl);
-            printCom.analyzeData(ctx.helper, rptTpl, tplData, defProperties, dftOption, outputType, cdDefine);
+            printCom.analyzeData(ctx.helper, rptTpl, tplData, defProperties, dftOption, outputType, customSelect);
             const maxPages = printCom.totalPages;
             let pageRst = null;
             // console.log(maxPages);

+ 22 - 4
app/lib/rpt_data_analysis.js

@@ -641,6 +641,7 @@ const gatherStagePay = {
             {name: '本期完成计量', ptype: 4, order: 1, visible: false},
             {name: '业主违约罚金', match: '业主违约罚金', order: 2},
             {name: '迟付款利息', match: '迟付款利息', order: 3},
+            {flow: true, minus: 0, rid: ['业主违约罚金', '迟付款利息'], order: 4},
             {name: '其他付款', minus: 0, rid: ['业主违约罚金', '迟付款利息'], order: 4},
             {name: '合计', order: 5, order_calc: 'o1+o2+o3+o4', },
             {name: '动员预付款', order: 6},
@@ -655,7 +656,7 @@ const gatherStagePay = {
             {name: '支付', ptype: 2, order: 15},
         ]
     },
-    _gatherFields: function (ctx, d, source, calcFields) {
+    _filterFields: function (ctx, d, source) {
         let filterData = source;
         if (d.ptype) {
             filterData = filterData.filter(function (x) {
@@ -686,6 +687,10 @@ const gatherStagePay = {
                 return true;
             });
         }
+        return filterData;
+    },
+    _gatherFields: function (ctx, d, source, calcFields) {
+        const filterData = this._filterFields(ctx, d, source);
         for (const fd of filterData) {
             for (const prop in fd) {
                 if (prop.indexOf('tp') >= 0) {
@@ -702,15 +707,28 @@ const gatherStagePay = {
         const result = [], calcFields = [];
         for (const c of options.custom) {
             const cData = JSON.parse(JSON.stringify(c));
-            if (!cData.order_calc && cData.empty !== 1) {
-                this._gatherFields(ctx, cData, gatherData, calcFields);
+            cData.subOrder = 0;
+            if (cData.flow) {
+                const fData = this._filterFields(ctx, cData, gatherData);
+                for (const [i, f] of fData.entries()) {
+                    f.order = cData.order;
+                    f.subOrder = i;
+                    result.push(fData);
+                }
+            } else {
+                if (!cData.order_calc && cData.empty !== 1) {
+                    this._gatherFields(ctx, cData, gatherData, calcFields);
+                }
+                result.push(cData);
             }
-            result.push(cData);
         }
         rdaUtils.orderCalc(ctx, result, calcFields);
         data[options.table] = result.filter(function (x) {
             return x.visible === undefined || x.visible;
         });
+        data[options.table].sort(function (a, b) {
+            return a.order === b.order ? a.subOrder - b.subOrder : a.order - b.order;
+        })
     },
 };
 const union = {