|
@@ -38,10 +38,11 @@ const billsFields = (function () {
|
|
|
|
|
|
const stage = cur.concat(pre, end, final);
|
|
|
const stageEnd = pre.concat(end, final);
|
|
|
- const bgl = ['qc_bgl_code'];
|
|
|
+ const bgl = ['qc_bgl_code', 'pre_qc_bgl_code', 'end_qc_bgl_code'];
|
|
|
+ const endBgl = ['pre_qc_bgl_code', 'end_qc_bgl_code'];
|
|
|
const leafXmj = ['leaf_xmj_id'];
|
|
|
|
|
|
- return {cur, pre, end, final, final1, stageDgn, stage, stageEnd, bgl, leafXmj};
|
|
|
+ return {cur, pre, end, final, final1, stageDgn, stage, stageEnd, bgl, leafXmj, endBgl};
|
|
|
})();
|
|
|
const posFields = (function () {
|
|
|
const cur = ['contract_qty', 'qc_qty', 'qc_minus_qty', 'gather_qty', 'postil'];
|
|
@@ -372,6 +373,7 @@ module.exports = app => {
|
|
|
|
|
|
for (const node of billsTree.nodes) {
|
|
|
node.qc_bgl_code = '';
|
|
|
+ node.qc_bgl_arr = [];
|
|
|
if (node.children && node.children.length > 0) continue;
|
|
|
|
|
|
const nodeBgl = helper._.filter(bglData, {lid: node.id});
|
|
@@ -380,7 +382,37 @@ module.exports = app => {
|
|
|
const validBgl = helper._.filter(nodeBgl, function (x) {
|
|
|
return !helper.checkZero(x.qty);
|
|
|
});
|
|
|
- node.qc_bgl_code = helper._.uniq(helper._.map(validBgl, 'c_code')).join(';');
|
|
|
+ node.qc_bgl_arr = helper._.uniq(helper._.map(validBgl, 'c_code'));
|
|
|
+ node.qc_bgl_code = node.qc_bgl_arr.join(';');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ async _calcBillsEndBgl(billsTree) {
|
|
|
+ if (!this.ctx.stage) return;
|
|
|
+
|
|
|
+ const helper = this.ctx.helper;
|
|
|
+ const tender = this.ctx.tender;
|
|
|
+ const stage = this.ctx.stage;
|
|
|
+ const preBglData = stage.order > 1 ? await this.ctx.service.stageChangeFinal.getFinalChangeBills(tender.id, stage.order - 1) : [];
|
|
|
+ for (const node of billsTree.nodes) {
|
|
|
+ node.pre_qc_bgl_code = '';
|
|
|
+ node.pre_qc_bgl_arr = [];
|
|
|
+ if (node.children && node.children.length > 0) continue;
|
|
|
+ if (preBglData.length === 0) continue;
|
|
|
+
|
|
|
+ const nodePreBgl = helper._.filter(preBglData, {lid: node.id});
|
|
|
+ if (nodePreBgl.length === 0) continue;
|
|
|
+
|
|
|
+ helper._.pullAll(preBglData, nodePreBgl);
|
|
|
+ const validBgl = helper._.filter(nodePreBgl, function(x) {
|
|
|
+ return !helper.checkZero(x.qty);
|
|
|
+ });
|
|
|
+ node.pre_qc_bgl_arr = helper._.uniq(helper._.map(validBgl, 'c_code'));
|
|
|
+ node.pre_qc_bgl_code = node.pre_qc_bgl_arr.join(';');
|
|
|
+ }
|
|
|
+ for (const node of billsTree.nodes) {
|
|
|
+ node.end_qc_bgl_arr = helper._.uniq(node.pre_qc_bgl_arr.concat(node.qc_bgl_arr));
|
|
|
+ node.end_qc_bgl_code = node.end_qc_bgl_arr.join(';');
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -538,6 +570,7 @@ module.exports = app => {
|
|
|
|
|
|
if (this._checkFieldsExist(fields, billsFields.bgl)) {
|
|
|
await this._calcBillsBgl(billsTree);
|
|
|
+ if (this._checkFieldsExist(fields, billsFields.endBgl)) await this._calcBillsEndBgl(billsTree)
|
|
|
}
|
|
|
|
|
|
if (this._checkFieldsExist(fields, billsFields.leafXmj)) {
|