|
@@ -12,7 +12,7 @@ const stageIm = (function () {
|
|
|
const imFields = ['uuid', 'doc_code', 'peg', 'bw', 'xm', 'drawing_code', 'calc_memo', 'calc_img', 'position'];
|
|
|
const splitChar = '-';
|
|
|
const mergeChar = ';';
|
|
|
- let stage, imType, details, changes, ImData, pre;
|
|
|
+ let stage, imType, decimal, details, changes, ImData, pre;
|
|
|
const gsTreeSetting = {
|
|
|
id: 'ledger_id',
|
|
|
pid: 'ledger_pid',
|
|
@@ -52,9 +52,10 @@ const stageIm = (function () {
|
|
|
};
|
|
|
const gsPos = new StagePosData(gsPosSetting);
|
|
|
|
|
|
- function init (s, i) {
|
|
|
+ function init (s, i, d) {
|
|
|
stage = s;
|
|
|
imType = i;
|
|
|
+ decimal = d;
|
|
|
}
|
|
|
|
|
|
function initCheck () {
|
|
@@ -62,7 +63,6 @@ const stageIm = (function () {
|
|
|
for (const node of gsTree.datas) {
|
|
|
node.check = gatherNodes.indexOf(node.id) !== -1;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
function loadData (ledger, pos, stageDetail, stageChange) {
|
|
@@ -241,6 +241,19 @@ const stageIm = (function () {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ function getBwBillsBw(node) {
|
|
|
+ if (node.level < 3) {
|
|
|
+ return '';
|
|
|
+ } else {
|
|
|
+ let parent = node, result = parent.name;
|
|
|
+ while (parent.level > 3 && parent) {
|
|
|
+ parent = getNodeByLevel(node, parent.level - 1);
|
|
|
+ result = parent.name + '-' + result;
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
function checkCustomDetail(im) {
|
|
|
const cd = _.find(details, function (d) {
|
|
|
return im.lid === d.lid &&
|
|
@@ -248,7 +261,8 @@ const stageIm = (function () {
|
|
|
(!im.name || im.name === d.name) &&
|
|
|
(!im.unit || im.unit === d.unit) &&
|
|
|
checkZero(ZhCalc.sub(im.unit_price, d.unit_price)) &&
|
|
|
- (!im.pid || im.pid === d.pid);
|
|
|
+ (!im.pid || im.pid === d.pid) &&
|
|
|
+ (!im.pos_name || im.pos_name === d.pos_name);
|
|
|
});
|
|
|
if (cd) {
|
|
|
_.assignInWith(im, cd, function (oV, sV, key) {
|
|
@@ -431,6 +445,94 @@ const stageIm = (function () {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ function generateBwBillsImData (node) {
|
|
|
+ if (node.gather_tp) {
|
|
|
+ const nodeIndex = gsTree.getNodeIndex(node);
|
|
|
+ const peg = getPegNode(node);
|
|
|
+ const nodeImData = [], posterity = gsTree.getPosterity(node);
|
|
|
+ const bw = getBwBillsBw(node);
|
|
|
+ const imDefault = {
|
|
|
+ lid: node.id, pid: '', code: node.code, name: node.name, pos_name: '',
|
|
|
+ peg: peg ? getPegStr(peg.name) : '',
|
|
|
+ drawing_code: getDrawingCode(node),
|
|
|
+ position: '',
|
|
|
+ lIndex: nodeIndex,
|
|
|
+ bw: bw, jldy: node.name,
|
|
|
+ changes: [], gclBills: [],
|
|
|
+ };
|
|
|
+ checkCustomDetail(imDefault);
|
|
|
+ for (const p of posterity) {
|
|
|
+ if (p.children && p.children.length > 0) continue;
|
|
|
+ if (!p.b_code || p.b_code === '') continue;
|
|
|
+ if (!p.gather_tp || p.gather_tp === 0) continue;
|
|
|
+ const pPos = gsPos.getLedgerPos(p.id);
|
|
|
+ if (pPos && pPos.length > 0) {
|
|
|
+ for (const pp of pPos) {
|
|
|
+ if (!pp.gather_qty || !pp.contract_qty || !pp.qc_qty) continue;
|
|
|
+ let im = nodeImData.find(function (d) {
|
|
|
+ return d.lid === node.id && d.pos_name === pp.name;
|
|
|
+ });
|
|
|
+ if (!im) {
|
|
|
+ im = {
|
|
|
+ lid: node.id, pid: '',
|
|
|
+ code: node.code + '-' + (nodeImData.length + 1), name: node.name, pos_name: pp.name,
|
|
|
+ peg: CheckPeg(pp.name) ? pp.name : (peg ? getPegStr(peg.name) : ''),
|
|
|
+ drawing_code: [], position: [],
|
|
|
+ lIndex: nodeIndex,
|
|
|
+ bw: bw, jldy: pp.name,
|
|
|
+ changes: [], gclBills: [],
|
|
|
+ };
|
|
|
+ nodeImData.push(im);
|
|
|
+ checkCustomDetail(im);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (const c of changes) {
|
|
|
+ if (c.lid === p.id && c.pid == pp.id && c.qty && c.qty !== 0) {
|
|
|
+ imDefault.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,
|
|
|
+ jl: pp.gather_qty, contract_jl: pp.contract_qty, qc_jl: pp.qc_qty
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (const c of changes) {
|
|
|
+ if (c.lid === p.id && c.pid == -1 && c.qty && c.qty !== 0) {
|
|
|
+ imDefault.changes.push(c);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (imDefault.jl) {
|
|
|
+ ImData.push(imDefault);
|
|
|
+ }
|
|
|
+ for (const im of nodeImData) {
|
|
|
+ im.drawing_code = im.drawing_code.join('');
|
|
|
+ im.position = im.position.join('');
|
|
|
+ ImData.push(im);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
function generateZlPosData(node, lx) {
|
|
|
if (!lx.pos) {
|
|
|
lx.pos = [];
|
|
@@ -614,13 +716,15 @@ const stageIm = (function () {
|
|
|
function recursiveBuildImData (nodes) {
|
|
|
if (!nodes || nodes.length === 0) { return; }
|
|
|
for (const node of nodes) {
|
|
|
- if (gsTree.isLeafXmj(node) || (stage.im_type !== imType.bw.value && stage.im_gather && node.check)) {
|
|
|
+ if (gsTree.isLeafXmj(node) || ((stage.im_type !== imType.bw.value && stage.im_type !== imType.bb.value) && stage.im_gather && node.check)) {
|
|
|
if (stage.im_type === imType.tz.value) {
|
|
|
generateTzImData(node);
|
|
|
} else if (stage.im_type === imType.zl.value) {
|
|
|
generateZlImData(node);
|
|
|
} else if (stage.im_type === imType.bw.value) {
|
|
|
generateBwImData(node);
|
|
|
+ } else if (stage.im_type === imType.bb.value) {
|
|
|
+ generateBwBillsImData(node);
|
|
|
}
|
|
|
} else {
|
|
|
recursiveBuildImData(node.children);
|