|
@@ -69,7 +69,7 @@ const gatherGcl = {
|
|
|
const gatherOther = fields.indexOf('chapter') >= 0;
|
|
|
|
|
|
ctx.helper._.pull(data.mem_stage_bills, 'is_leaf');
|
|
|
- const gclBills = [], other = {name: '未计入清单章节项', chapter: '100'};
|
|
|
+ const gclBills = [], other = {name: '未计入清单章节项', chapter: '10000'};
|
|
|
|
|
|
for (const b of data.mem_stage_bills) {
|
|
|
if (b.b_code && b.b_code !== '') {
|
|
@@ -81,7 +81,8 @@ const gatherGcl = {
|
|
|
gcl = {
|
|
|
b_code: b.b_code, name: b.name, unit: b.unit,
|
|
|
unit_price: b.unit_price,
|
|
|
- qc_bgl_code: [],
|
|
|
+ qc_bgl_code: [], chapter: b.chapter,
|
|
|
+ deal_bills_qty: b.deal_bills_qty, deal_bills_tp: b.deal_bills_tp,
|
|
|
};
|
|
|
gclBills.push(gcl);
|
|
|
}
|
|
@@ -147,11 +148,92 @@ const sortGcl = {
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
+const gatherChapter = {
|
|
|
+ name: '汇总章级数据',
|
|
|
+ hint: '请使用mem_stage_bills/mem_stage_bills_compare/ledger,仅对一张表进行汇总,并生成数据:\n'+
|
|
|
+ '1. 因为是汇总章级数据,必须在离散数据中添加"章节代码"&"章节名称"\n' +
|
|
|
+ '2. 需勾选"清单编号(b_code)", "树结构-是否子项(is_leaf)"字段,可以对任何含有这些字段的表汇总\n' +
|
|
|
+ '注意事项:\n' +
|
|
|
+ '1. 算法对数据表没有要求,保证有上述字段,且按顺序勾选即可, 仅汇总金额\n' +
|
|
|
+ '2. 算法计算后,原数据表中非数字类型的字段全部失效(除清单编号、名称外),请勿在指标映射中添加\n' +
|
|
|
+ '示例:\n' +
|
|
|
+ 'e.g.1 要对mem_stage_bills汇总,须勾选mem_stage_bills下的"清单编号(b_code)", "树结构-是否子项((is_leaf)"字段\n' +
|
|
|
+ 'e.g.2 要对mem_stage_bills_compare汇总,须勾选mem_stage_bills_compare下的"清单编号(b_code)", "树结构-是否子项((is_leaf)"字段\n' +
|
|
|
+ '结果:\n' +
|
|
|
+ '汇总结果可参照 清单汇总--章节合计,但是不过滤1000-1300章数据',
|
|
|
+ fun: function (ctx, data, fieldsKey) {
|
|
|
+ if (!data.tender_info || !data.tender_info.chapter) return;
|
|
|
+ if (!fieldsKey && fieldsKey.length < 0) return;
|
|
|
+
|
|
|
+ const getCalcChapter = function (chapter) {
|
|
|
+ const gclChapter = [], otherChapter = [];
|
|
|
+ let serialNo = 1;
|
|
|
+ for (const c of chapter) {
|
|
|
+ const cc = { code: c.code, name: c.name, cType: 1 };
|
|
|
+ cc.serialNo = serialNo++;
|
|
|
+ cc.filter = '^' + c.code.substr(0, c.code.length - 2) + '[0-9]{2}-';
|
|
|
+ gclChapter.push(cc);
|
|
|
+ }
|
|
|
+ gclChapter.push({ name: '未计入章节清单合计', cType: 21, serialNo: serialNo++, });
|
|
|
+ otherChapter.push({ name: '清单小计(A)', cType: 11, serialNo: serialNo++ });
|
|
|
+ otherChapter.push({ name: '非清单项费用(B)', cType: 31, serialNo: serialNo++ });
|
|
|
+ otherChapter.push({ name: '合计(C=A+B)', cType: 41, serialNo: serialNo });
|
|
|
+ return [gclChapter, otherChapter];
|
|
|
+ };
|
|
|
+ const getGclChapter = function (chapter, data) {
|
|
|
+ for (const c of chapter) {
|
|
|
+ if (c.filter) {
|
|
|
+ const reg = new RegExp(c.filter);
|
|
|
+ if (reg.test(data.b_code)) {
|
|
|
+ return c;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return c;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ const gatherData = function(chapter, data) {
|
|
|
+ for (const f in data) {
|
|
|
+ if (data[f] && (f.indexOf('tp') >= 0 || f === 'total_price')) {
|
|
|
+ chapter[f] = ctx.helper.add(chapter[f], data[f]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ const [gclChapter, otherChapter] = getCalcChapter(data.tender_info.chapter);
|
|
|
+ const fields = ctx.helper._.map(fieldsKey, 'field');
|
|
|
+ const needFields = ['b_code', 'is_leaf'];
|
|
|
+ for (const nf of needFields) {
|
|
|
+ if (fields.indexOf(nf) === -1) return;
|
|
|
+ }
|
|
|
+ const sourceData = data[fieldsKey[0].table];
|
|
|
+ if (!sourceData) return;
|
|
|
+ for (const d of sourceData) {
|
|
|
+ if (!d.is_leaf) continue;
|
|
|
+
|
|
|
+ for (const c of otherChapter) {
|
|
|
+ if (c.cType === 41) {
|
|
|
+ gatherData(c, d);
|
|
|
+ } else if (c.cType === 31 && (!d.b_code || d.b_code === '')) {
|
|
|
+ gatherData(c, d, fields);
|
|
|
+ } else if (c.cType === 11 && (d.b_code)) {
|
|
|
+ gatherData(c, d, fields);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (d.b_code) {
|
|
|
+ const c = getGclChapter(gclChapter, d);
|
|
|
+ gatherData(c, d, fields);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ data[fieldsKey[0].table] = gclChapter.concat(otherChapter);
|
|
|
+ },
|
|
|
+};
|
|
|
|
|
|
const analysisObj = {
|
|
|
changeSort,
|
|
|
gatherGcl,
|
|
|
- sortGcl
|
|
|
+ sortGcl,
|
|
|
+ gatherChapter,
|
|
|
};
|
|
|
const analysisDefine = (function (obj) {
|
|
|
const result = [];
|