|
@@ -1900,6 +1900,68 @@ const gatherMaterialGl = {
|
|
|
data.mem_material_gl_detail = result;
|
|
|
}
|
|
|
};
|
|
|
+const masterCross = {
|
|
|
+ name: '主从交叉(汇总)数据-通用',
|
|
|
+ hint: '此版本,要求表必须是主从关系',
|
|
|
+ defaultSetting: {
|
|
|
+ main: {
|
|
|
+ tableName: 'mem_material_gather_bills',
|
|
|
+ prefix: 'm_',
|
|
|
+ fields: ['b_code', 'name', 'units', 'unit_price', 'quantity', 'total_price', 'gather_qty', 'gather_tp', 'jiacha'],
|
|
|
+ },
|
|
|
+ sub: {
|
|
|
+ tableName: 'mem_material_gather_gl',
|
|
|
+ masterKey: 'id', subKey: 'gather_gcl_id', gatherKey: 'mb_id',
|
|
|
+ prefix: 's_',
|
|
|
+ fields: ['code', 'name', 'units'],
|
|
|
+ gatherFields: ['quantity'],
|
|
|
+ },
|
|
|
+ target: 'master_converse'
|
|
|
+ },
|
|
|
+ _converse: function(ctx, options, mainTable, subTable) {
|
|
|
+ const data = [];
|
|
|
+ const converseData = [];
|
|
|
+ subTable.forEach(x => {
|
|
|
+ let cd = converseData.find(y => { return x[options.sub.gatherKey] === y[options.sub.gatherKey]});
|
|
|
+ if (cd) return;
|
|
|
+
|
|
|
+ cd = {};
|
|
|
+ cd[options.sub.gatherKey] = x[options.sub.gatherKey];
|
|
|
+ for (const f of options.sub.fields) {
|
|
|
+ cd[f] = x[f];
|
|
|
+ }
|
|
|
+ converseData.push(cd);
|
|
|
+ });
|
|
|
+ for (const [i, m] of mainTable.entries()) {
|
|
|
+ const temp = { cross_index: i+1 };
|
|
|
+ for (const f of options.main.fields) {
|
|
|
+ temp[options.main.prefix + f] = m[f];
|
|
|
+ }
|
|
|
+ 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));
|
|
|
+ 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;
|
|
|
+ for (const f of options.sub.gatherFields) {
|
|
|
+ nd[options.sub.prefix + f] = ctx.helper.add(nd[options.sub.prefix + f], x[f]);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ data.push(nd);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return data;
|
|
|
+ },
|
|
|
+ fun(ctx, data, fieldsKey, options, csRela) {
|
|
|
+ if (!options || !options.main || !options.sub || !options.target) return;
|
|
|
+ const mainTable = data[options.main.tableName], subTable = data[options.sub.tableName];
|
|
|
+ if (!mainTable || !subTable) return;
|
|
|
+
|
|
|
+ data[options.target] = this._converse(ctx, options, mainTable, subTable);
|
|
|
+ },
|
|
|
+};
|
|
|
|
|
|
const analysisObj = {
|
|
|
changeSort,
|
|
@@ -1925,6 +1987,7 @@ const analysisObj = {
|
|
|
treeFilter,
|
|
|
gatherGcl2,
|
|
|
gatherMaterialGl,
|
|
|
+ masterCross
|
|
|
};
|
|
|
const analysisDefine = (function(obj) {
|
|
|
const result = [];
|