|
@@ -55,6 +55,24 @@ class loadGclBaseTree {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ findBCodeNode(b_code, mustParent) {
|
|
|
+ for (const bn of this.baseNodes) {
|
|
|
+ if (bn.b_code === b_code && (!mustParent || !bn.is_leaf)) return bn;
|
|
|
+ }
|
|
|
+ for (const i of this.items) {
|
|
|
+ if (i.b_code === b_code && (!mustParent || !i.is_leaf)) return i;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ findBCodeParent(b_code) {
|
|
|
+ const codeArr = b_code.split('-');
|
|
|
+ if (codeArr.length === 1) return null;
|
|
|
+ codeArr.length = codeArr.length - 1;
|
|
|
+ const parentCode = codeArr.join('-');
|
|
|
+ const result = this.findBCodeNode(parentCode, true);
|
|
|
+ return result || this.findBCodeParent(parentCode);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 添加 树节点 并完善该节点的树结构
|
|
|
* @param {Object} node - 添加节点
|
|
@@ -108,14 +126,15 @@ class loadGclBaseTree {
|
|
|
addNodeWithoutParent(source, check) {
|
|
|
let node = this.findLeaf(source, check);
|
|
|
if (!node) {
|
|
|
+ const parent = this.findBCodeParent(source.b_code) || this.parent;
|
|
|
node = {
|
|
|
id: this.ctx.app.uuid.v4(),
|
|
|
tender_id: this.ctx.tender.id,
|
|
|
ledger_id: this.keyNodeId,
|
|
|
- ledger_pid: this.parent.ledger_id,
|
|
|
- level: this.parent.level + 1,
|
|
|
- full_path: this.parent.full_path + '-' + this.keyNodeId,
|
|
|
- order: this.parent.children.length + 1,
|
|
|
+ ledger_pid: parent.ledger_id,
|
|
|
+ level: parent.level + 1,
|
|
|
+ full_path: parent.full_path + '-' + this.keyNodeId,
|
|
|
+ order: parent.children.length + 1,
|
|
|
b_code: source.b_code,
|
|
|
name: source.name,
|
|
|
unit: source.unit,
|
|
@@ -128,7 +147,7 @@ class loadGclBaseTree {
|
|
|
hasPos: false,
|
|
|
};
|
|
|
this.keyNodeId += 1;
|
|
|
- this.parent.children.push(node);
|
|
|
+ parent.children.push(node);
|
|
|
this.items.push(node);
|
|
|
}
|
|
|
return node;
|
|
@@ -254,7 +273,7 @@ class updateReviseGclTree extends loadGclBaseTree {
|
|
|
}
|
|
|
}
|
|
|
gather(source, parent) {
|
|
|
- const node = this.addNode(source, parent);
|
|
|
+ const node = this.ignoreParent ? this.addNodeWithoutParent(source) : this.addNode(source, parent);
|
|
|
node.deal_qty = this.ctx.helper.add(node.deal_qty, source.deal_qty);
|
|
|
node.sgfh_qty = this.ctx.helper.add(node.sgfh_qty, source.sgfh_qty);
|
|
|
node.qtcl_qty = this.ctx.helper.add(node.qtcl_qty, source.qtcl_qty);
|
|
@@ -494,8 +513,9 @@ class sumLoad {
|
|
|
}
|
|
|
|
|
|
async updateGatherGcl(select, maxId, tenders, defaultData) {
|
|
|
+ const ignoreParent = this.ctx.tender.info.fun_rela.sum_load.ignoreParent;
|
|
|
this.loadTree = new updateReviseGclTree(this.ctx, {
|
|
|
- parent: select, maxId, type: 'ledger', defaultData,
|
|
|
+ parent: select, maxId, type: 'ledger', defaultData, ignoreParent,
|
|
|
});
|
|
|
const posterity = await this.ctx.service.reviseBills.getPosterityByParentId(this.ctx.tender.id, select.ledger_id);
|
|
|
const pos = await this.ctx.service.revisePos.getData(this.ctx.tender.id);
|
|
@@ -518,7 +538,7 @@ class sumLoad {
|
|
|
});
|
|
|
for (const top of billsTree.children) {
|
|
|
if ([1].indexOf(top.node_type) < 0) continue;
|
|
|
- this.recusiveLoadGatherGcl(top, null);
|
|
|
+ this.recusiveLoadGatherGcl(top, null, ignoreParent);
|
|
|
}
|
|
|
}
|
|
|
this.loadTree.resortByCode();
|