Prechádzať zdrojové kódy

数据预处理,调整

MaiXinRong 5 rokov pred
rodič
commit
37c3c60b7e
1 zmenil súbory, kde vykonal 26 pridanie a 2 odobranie
  1. 26 2
      app/lib/rpt_data_analysis.js

+ 26 - 2
app/lib/rpt_data_analysis.js

@@ -370,6 +370,15 @@ const gatherChapter = {
         }
         return [gclChapter, otherChapter, customChapter];
     },
+    _completeGatherInfo: function (chapters, source) {
+        for (const f in source) {
+            if (/^t_[0-9]*_(id|name)$/.test(f)) {
+                for (const chapter of chapters) {
+                    chapter[f] = source[f];
+                }
+            }
+        }
+    },
     _getGclChapter: function (chapter, data, field) {
         for (const c of chapter) {
             if (c.filter) {
@@ -472,14 +481,15 @@ const gatherChapter = {
             if (!chapter) return;
 
             for (const f in data) {
-                if (data[f] && (f.indexOf('tp') >= 0 || f === 'total_price')) {
+                if (!data[f]) continue;
+
+                if ((f.indexOf('tp') >= 0 || f === 'total_price')) {
                     chapter[f] = ctx.helper.add(chapter[f], data[f]);
                     if (calcFields.indexOf(f) === -1) calcFields.push(f);
                 }
             }
         };
 
-        const [gclChapter, otherChapter, customChapter] = this._getCalcChapter(data.tender_info.chapter, options ? options : this.defaultSetting);
         const fields = ctx.helper._.map(fieldsKey, 'field');
         const needFields = ['b_code', 'is_leaf'];
         for (const nf of needFields) {
@@ -487,6 +497,12 @@ const gatherChapter = {
         }
         const sourceData = data[fieldsKey[0].table];
         if (!sourceData) return;
+        const [gclChapter, otherChapter, customChapter] = this._getCalcChapter(data.tender_info.chapter, options ? options : this.defaultSetting);
+        if (fieldsKey[0].table.indexOf('mem_gather') >= 0) {
+            this._completeGatherInfo(gclChapter, sourceData[0]);
+            this._completeGatherInfo(otherChapter, sourceData[0]);
+            this._completeGatherInfo(customChapter, sourceData[0]);
+        }
         const filter = [];
         for (const d of sourceData) {
             for (const c of customChapter) {
@@ -796,6 +812,13 @@ const gatherStagePay = {
             }
         }
     },
+    _completeGatherInfo(d, source) {
+        for (const f in source) {
+            if (/^t_[0-9]*_(id|name)$/.test(f)) {
+                d[f] = source[f];
+            }
+        }
+    },
     fun: function (ctx, data, fields, options) {
         if (!options || !options.table || !options.custom) return;
 
@@ -815,6 +838,7 @@ const gatherStagePay = {
                 if (!cData.order_calc && cData.empty !== 1) {
                     this._gatherFields(ctx, cData, gatherData, calcFields);
                 }
+                if (options.table.indexOf('mem_gather') >= 0) this._completeGatherInfo(cData, gatherData[0]);
                 result.push(cData);
             }
         }