|
@@ -9,7 +9,7 @@
|
|
|
*/
|
|
|
|
|
|
const stageIm = (function () {
|
|
|
- const imFields = ['uuid', 'doc_code', 'peg', 'bw', 'xm', 'drawing_code', 'calc_memo', 'calc_img', 'position'];
|
|
|
+ const imFields = ['uuid', 'doc_code', 'peg', 'bw', 'xm', 'drawing_code', 'calc_memo', 'calc_img', 'position', 'jldy'];
|
|
|
const splitChar = '-';
|
|
|
const mergeChar = ';';
|
|
|
let stage, imType, decimal, details, changes, ImData, pre;
|
|
@@ -265,8 +265,9 @@ const stageIm = (function () {
|
|
|
(!im.pos_name || im.pos_name === d.pos_name);
|
|
|
});
|
|
|
if (cd) {
|
|
|
+ im.custom_define = cd.custom_define ? cd.custom_define.split(',') : imFields;
|
|
|
_.assignInWith(im, cd, function (oV, sV, key) {
|
|
|
- return (imFields.indexOf(key) > -1 && sV !== undefined && sV !== null) ? sV : oV;
|
|
|
+ return (im.custom_define.indexOf(key) > -1 && sV !== undefined && sV !== null) ? sV : oV;
|
|
|
});
|
|
|
}
|
|
|
}
|
|
@@ -283,6 +284,9 @@ const stageIm = (function () {
|
|
|
}
|
|
|
im.calc_memo = memo.join('\n');
|
|
|
} else if (im.gclBills && im.gclBills.length > 0) {
|
|
|
+ im.gclBills.sort(function (x, y) {
|
|
|
+ return compareCode(x.b_code, y.b_code);
|
|
|
+ });
|
|
|
const memo = [];
|
|
|
for (const [i, b] of im.gclBills.entries()) {
|
|
|
if (b.pos && b.pos.length > 0) {
|
|
@@ -428,6 +432,7 @@ const stageIm = (function () {
|
|
|
peg: peg ? getPegStr(peg.name) : '', drawing_code: getDrawingCode(node),
|
|
|
position: '',
|
|
|
lIndex: nodeIndex,
|
|
|
+ custom_define: [],
|
|
|
};
|
|
|
if (stage.im_gather && node.check) {
|
|
|
im.bw = getZlGatherBw(node, peg);
|
|
@@ -445,6 +450,31 @@ const stageIm = (function () {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ function addBwBillsGclBills(im, bills) {
|
|
|
+ if (!im.gclBills) im.gclBills = [];
|
|
|
+ let gcl = im.gclBills.find(function (x) {
|
|
|
+ return (!bills.b_code || bills.b_code === x.b_code) &&
|
|
|
+ (!bills.name || bills.name === x.name) &&
|
|
|
+ (!bills.unit || bills.unit === x.unit) &&
|
|
|
+ checkZero(ZhCalc.sub(bills.unit_price, x.unit_price));
|
|
|
+ });
|
|
|
+ if (!gcl) {
|
|
|
+ gcl = {b_code: bills.b_code, name: bills.name, unit: bills.unit, unit_price: bills.unit_price};
|
|
|
+ im.gclBills.push(gcl);
|
|
|
+ }
|
|
|
+ gcl.contract_jl = ZhCalc.add(gcl.contract_jl, bills.contract_jl);
|
|
|
+ gcl.qc_jl = ZhCalc.add(gcl.qc_jl, bills.qc_jl);
|
|
|
+ gcl.jl = ZhCalc.add(gcl.jl, bills.jl);
|
|
|
+ }
|
|
|
+ function calculateBwBillsIm(im) {
|
|
|
+ im.contract_jl = 0;
|
|
|
+ im.qc_jl = 0;
|
|
|
+ for (const b of im.gclBills) {
|
|
|
+ im.contract_jl = ZhCalc.add(im.contract_jl, ZhCalc.mul(b.contract_jl, b.unit_price, decimal.tp));
|
|
|
+ im.qc_jl = ZhCalc.add(im.qc_jl, ZhCalc.mul(b.qc_jl, b.unit_price, decimal.tp));
|
|
|
+ }
|
|
|
+ im.jl = ZhCalc.add(im.contract_jl, im.qc_jl);
|
|
|
+ }
|
|
|
function generateBwBillsImData (node) {
|
|
|
if (node.gather_tp) {
|
|
|
const nodeIndex = gsTree.getNodeIndex(node);
|
|
@@ -459,6 +489,7 @@ const stageIm = (function () {
|
|
|
lIndex: nodeIndex,
|
|
|
bw: bw, jldy: node.name,
|
|
|
changes: [], gclBills: [],
|
|
|
+ custom_define: [],
|
|
|
};
|
|
|
checkCustomDetail(imDefault);
|
|
|
for (const p of posterity) {
|
|
@@ -481,6 +512,7 @@ const stageIm = (function () {
|
|
|
lIndex: nodeIndex,
|
|
|
bw: bw, jldy: pp.name,
|
|
|
changes: [], gclBills: [],
|
|
|
+ custom_define: [],
|
|
|
};
|
|
|
nodeImData.push(im);
|
|
|
checkCustomDetail(im);
|
|
@@ -491,18 +523,15 @@ const stageIm = (function () {
|
|
|
im.changes.push(c);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- im.jl = ZhCalc.add(im.jl, ZhCalc.mul(pp.gather_qty, p.unit_price, decimal.tp));
|
|
|
- im.contract_jl = ZhCalc.add(im.contract_jl, ZhCalc.mul(pp.contract_qty, p.unit_price, decimal.tp));
|
|
|
- im.qc_jl = ZhCalc.add(im.qc_jl, ZhCalc.mul(pp.qc_qty, p.unit_price, decimal.tp));
|
|
|
- if (pp.drawing_code) im.drawing_code.push(pp.drawing_code);
|
|
|
- if (pp.position) im.position.push(pp.position);
|
|
|
-
|
|
|
- im.gclBills.push({
|
|
|
- bid: p.id,
|
|
|
- b_code: p.b_code, name: p.name, unit: p.unit,
|
|
|
+ addBwBillsGclBills(im, {
|
|
|
+ b_code: p.b_code, name: p.name, unit: p.unit, unit_price: p.unit_price,
|
|
|
jl: pp.gather_qty, contract_jl: pp.contract_qty, qc_jl: pp.qc_qty
|
|
|
});
|
|
|
+
|
|
|
+ if (pp.drawing_code && im.drawing_code instanceof Array)
|
|
|
+ im.drawing_code.push(pp.drawing_code);
|
|
|
+ if (pp.position && im.position instanceof Array)
|
|
|
+ im.position.push(pp.position);
|
|
|
}
|
|
|
} else {
|
|
|
for (const c of changes) {
|
|
@@ -511,23 +540,23 @@ const stageIm = (function () {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- imDefault.jl = ZhCalc.add(imDefault.jl, p.gather_qty);
|
|
|
imDefault.contract_jl = ZhCalc.add(imDefault.contract_jl, p.contract_qty);
|
|
|
imDefault.qc_jl = ZhCalc.add(imDefault.qc_jl, p.qc_qty);
|
|
|
|
|
|
- imDefault.gclBills.push({
|
|
|
- bid: p.id,
|
|
|
- b_code: p.b_code, name: p.name, unit: p.unit,
|
|
|
- jl: p.gather_qty, contract_jl: p.contract_qty, qc_jl: p.qc_qty
|
|
|
+ addBwBillsGclBills(imDefault, {
|
|
|
+ b_code: p.b_code, name: p.name, unit: p.unit, unit_price: p.unit_price,
|
|
|
+ jl: p.gather_qty, contract_jl: p.contract_qty, qc_jl: p.qc_jl,
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
- if (imDefault.jl) {
|
|
|
+ if (imDefault.contract_jl || imDefault.qc_jl) {
|
|
|
+ imDefault.jl = ZhCalc.add(imDefault.contract_jl, imDefault.qc_jl);
|
|
|
ImData.push(imDefault);
|
|
|
}
|
|
|
for (const im of nodeImData) {
|
|
|
- im.drawing_code = im.drawing_code.join(mergeChar);
|
|
|
- im.position = im.position.join(mergeChar);
|
|
|
+ calculateBwBillsIm(im);
|
|
|
+ im.drawing_code = _.uniq(im.drawing_code).join(mergeChar);
|
|
|
+ im.position = _.uniq(im.position).join(mergeChar);
|
|
|
ImData.push(im);
|
|
|
}
|
|
|
}
|
|
@@ -621,6 +650,7 @@ const stageIm = (function () {
|
|
|
peg: peg ? getPegStr(peg.name) : '',
|
|
|
position: '',
|
|
|
lIndex: nodeIndex,
|
|
|
+ custom_define: [],
|
|
|
};
|
|
|
if (stage.im_gather && node.check) {
|
|
|
im.bw = getZlGatherBw(node, peg);
|
|
@@ -668,6 +698,7 @@ const stageIm = (function () {
|
|
|
changes: [],
|
|
|
position: pp.position,
|
|
|
lIndex: nodeIndex,
|
|
|
+ custom_define: [],
|
|
|
};
|
|
|
im.calc_memo = '本期计量:' + (checkZero(im.jl) ? 0 : im.jl) + ' ' + im.unit;
|
|
|
checkCustomDetail(im);
|
|
@@ -694,6 +725,7 @@ const stageIm = (function () {
|
|
|
changes: [],
|
|
|
position: '',
|
|
|
lIndex: gsTree.getNodeIndex(node),
|
|
|
+ custom_define: [],
|
|
|
};
|
|
|
im.calc_memo = '本期计量:' + (checkZero(im.jl) ? 0 : im.jl) + ' ' + im.unit;
|
|
|
checkCustomDetail(im);
|