|
@@ -21,8 +21,10 @@ class loadGclBaseTree {
|
|
|
// 常量
|
|
|
this.splitChar = '-';
|
|
|
// 索引
|
|
|
- // 以code为索引
|
|
|
+ // 仅通过addNode或addNodeWithoutParent添加节点
|
|
|
this.items = [];
|
|
|
+ // this.parent下原来的节点
|
|
|
+ this.baseNodes = [];
|
|
|
|
|
|
// 缓存
|
|
|
this.keyNodeId = setting.maxId ? setting.maxId + 1 : 1;
|
|
@@ -70,6 +72,7 @@ class loadGclBaseTree {
|
|
|
b_code: source.b_code,
|
|
|
name: source.name,
|
|
|
unit: source.unit,
|
|
|
+ deal_qty: 0,
|
|
|
sgfh_qty: 0,
|
|
|
qtcl_qty: 0,
|
|
|
sjcl_qyt: 0,
|
|
@@ -84,6 +87,47 @@ class loadGclBaseTree {
|
|
|
return node;
|
|
|
}
|
|
|
|
|
|
+ findLeaf(node, check) {
|
|
|
+ for (const bn of this.baseNodes) {
|
|
|
+ if (bn.b_code === node.b_code && bn.name === node.name && bn.unit === node.unit
|
|
|
+ && bn.is_leaf && !bn.hasPos && (!check || check(bn, node))) return bn;
|
|
|
+ }
|
|
|
+ for (const i of this.items) {
|
|
|
+ if (i.b_code === node.b_code && i.name === node.name && i.unit === node.unit
|
|
|
+ && i.is_leaf && !i.hasPos && (!check || check(i, node))) return i;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ addNodeWithoutParent(source, check) {
|
|
|
+ let node = this.findLeaf(source, check);
|
|
|
+ if (!node) {
|
|
|
+ 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,
|
|
|
+ b_code: source.b_code,
|
|
|
+ name: source.name,
|
|
|
+ unit: source.unit,
|
|
|
+ deal_qty: 0,
|
|
|
+ sgfh_qty: 0,
|
|
|
+ qtcl_qty: 0,
|
|
|
+ sjcl_qty: 0,
|
|
|
+ quantity: 0,
|
|
|
+ is_leaf: source.is_leaf,
|
|
|
+ hasPos: false,
|
|
|
+ }
|
|
|
+ this.keyNodeId += 1;
|
|
|
+ this.parent.children.push(node);
|
|
|
+ this.items.push(node);
|
|
|
+ }
|
|
|
+ return node;
|
|
|
+ }
|
|
|
+
|
|
|
gather(source, parent) {}
|
|
|
getUpdateData() {}
|
|
|
|
|
@@ -149,7 +193,6 @@ class loadLedgerGclTree extends loadGclBaseTree {
|
|
|
class updateReviseGclTree extends loadGclBaseTree {
|
|
|
constructor (ctx, setting) {
|
|
|
super(ctx, setting);
|
|
|
- this.baseNodes = [];
|
|
|
this.errors = [];
|
|
|
}
|
|
|
loadBase(datas, pos) {
|
|
@@ -237,10 +280,6 @@ class updateReviseGclTree extends loadGclBaseTree {
|
|
|
}
|
|
|
|
|
|
class gatherStageGclTree extends loadGclBaseTree {
|
|
|
- constructor (ctx, setting) {
|
|
|
- super(ctx, setting);
|
|
|
- this.baseNodes = [];
|
|
|
- }
|
|
|
loadBase(datas, pos) {
|
|
|
datas.sort((x, y) => { return x.level === y.level ? x.order - y.order : x.level - y.level; });
|
|
|
const Index = {};
|
|
@@ -338,9 +377,10 @@ class sumLoad {
|
|
|
this.ctx = ctx;
|
|
|
}
|
|
|
|
|
|
- recusiveLoadGatherGcl(node, parent) {
|
|
|
- const cur = node.b_code ? this.loadTree.gather(node, parent) : parent;
|
|
|
- if (!node.children || node.children.length === 0) return;
|
|
|
+ recusiveLoadGatherGcl(node, parent, ignoreParent) {
|
|
|
+ const isLeaf = !node.children || node.children.length === 0;
|
|
|
+ const cur = (!ignoreParent || isLeaf) && node.b_code ? this.loadTree.gather(node, parent) : parent;
|
|
|
+ if (isLeaf) return;
|
|
|
for (const child of node.children) {
|
|
|
this.recusiveLoadGatherGcl(child, cur);
|
|
|
}
|
|
@@ -429,8 +469,9 @@ class sumLoad {
|
|
|
}
|
|
|
|
|
|
async stageGatherGcl(select, maxId, tenders, defaultData) {
|
|
|
+ const ignoreParent = this.ctx.tender.info.fun_rela.ignoreParent;
|
|
|
this.loadTree = new gatherStageGclTree(this.ctx, {
|
|
|
- parent: select, maxId, type: 'ledger', defaultData,
|
|
|
+ parent: select, maxId, type: 'ledger', defaultData, ignoreParent,
|
|
|
});
|
|
|
const posterity = await this.ctx.service.ledger.getPosterityByParentId(this.ctx.tender.id, select.ledger_id);
|
|
|
const pos = await this.ctx.service.revisePos.getData(this.ctx.tender.id);
|
|
@@ -456,7 +497,7 @@ class sumLoad {
|
|
|
billsTree.loadDatas(billsData);
|
|
|
for (const top of billsTree.children) {
|
|
|
if ([1].indexOf(top.node_type) < 0) continue;
|
|
|
- this.recusiveLoadGatherGcl(top, null);
|
|
|
+ this.recusiveLoadGatherGcl(top, null, ignoreParent);
|
|
|
}
|
|
|
}
|
|
|
return this.loadTree;
|