浏览代码

主从交叉,引用字段

MaiXinRong 2 年之前
父节点
当前提交
d0d7a81f0a
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      app/lib/rpt_data_analysis.js

+ 8 - 0
app/lib/rpt_data_analysis.js

@@ -1914,6 +1914,7 @@ const masterCross = {
             masterKey: 'id', subKey: 'gather_gcl_id', gatherKey: 'mb_id',
             prefix: 's_',
             fields: ['code', 'name', 'units'],
+            quoteFields: ['quantity'],
             gatherFields: ['quantity'],
         },
         target: 'master_converse'
@@ -1940,11 +1941,18 @@ const masterCross = {
             const rela = subTable.filter(x => { return x[options.sub.subKey] === m[options.masterKey]; });
             for (const cd of converseData) {
                 const nd = JSON.parse(JSON.stringify(temp));
+                nd.quote = false;
                 for (const prop in cd) {
                     nd[options.sub.prefix + prop] = cd[prop];
                 }
                 rela.forEach(x => {
                     if (x[options.sub.gatherKey] !== cd[options.sub.gatherKey]) return;
+                    if (!nd.quote) {
+                        for (const f of options.sub.quoteFields) {
+                            nd[options.sub.prefix + f] = x[f];
+                        }
+                        nd.quote = true;
+                    }
                     for (const f of options.sub.gatherFields) {
                         nd[options.sub.prefix + f] = ctx.helper.add(nd[options.sub.prefix + f], x[f]);
                     }