|
@@ -10,15 +10,16 @@
|
|
|
|
|
|
|
|
|
const ledgerCheckType = {
|
|
|
- sibling: {value: 1, text: '项目节、清单同层'},
|
|
|
- empty_code: {value: 2, text: '项目节、清单编号同时为空'},
|
|
|
- calc: {value: 3, text: '清单数量不等于计量单元之和'},
|
|
|
- zero: {value: 4, text: '清单数量或单价为0'},
|
|
|
- tp: {value: 5, text: '清单金额≠数量×单价'},
|
|
|
- over: {value: 6, text: '超计'},
|
|
|
+ sibling: {value: 1, text: '项目节、清单同层', fun: 'checkSibling', },
|
|
|
+ empty_code: {value: 2, text: '项目节、清单编号同时为空', fun: 'checkCodeEmpty', },
|
|
|
+ calc: {value: 3, text: '清单数量不等于计量单元之和', fun: 'checkCalc', },
|
|
|
+ zero: {value: 4, text: '清单数量或单价为0', fun: 'checkZero', },
|
|
|
+ tp: {value: 5, text: '清单金额≠数量×单价', fun: 'checkTp', },
|
|
|
+ over: {value: 6, text: '超计', fun: 'checkOver', },
|
|
|
+ same_code: {value: 7, text: '重复项目节', fun: 'checkSameCode', },
|
|
|
};
|
|
|
const ledgerCheckUtil = {
|
|
|
- checkSibling: function (ledgerTree) {
|
|
|
+ checkSibling: function (ledgerTree, ledgerPos, decimal, option) {
|
|
|
const error = [];
|
|
|
for (const node of ledgerTree.nodes) {
|
|
|
if (!node.children || node.children.length === 0) continue;
|
|
@@ -31,7 +32,7 @@ const ledgerCheckUtil = {
|
|
|
}
|
|
|
return error;
|
|
|
},
|
|
|
- checkCodeEmpty: function (ledgerTree) {
|
|
|
+ checkCodeEmpty: function (ledgerTree, ledgerPos, decimal, option) {
|
|
|
const error = [];
|
|
|
const checkNodeCode = function (node) {
|
|
|
if ((!node.code || node.code === '') && (!node.b_code || node.b_code === '')) error.push(node);
|
|
@@ -40,15 +41,15 @@ const ledgerCheckUtil = {
|
|
|
checkNodeCode(child);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ };
|
|
|
for (const topLevel of ledgerTree.children) {
|
|
|
- if (topLevel.node_type !== 1) continue;
|
|
|
+ if ([1, 3, 4].indexOf(topLevel.node_type) < 0) continue;
|
|
|
|
|
|
checkNodeCode(topLevel);
|
|
|
}
|
|
|
return error;
|
|
|
},
|
|
|
- checkCalc: function (ledgerTree, ledgerPos, option) {
|
|
|
+ checkCalc: function (ledgerTree, ledgerPos, decimal, option) {
|
|
|
const error = [];
|
|
|
for (const node of ledgerTree.nodes) {
|
|
|
if (node.children && node.children.length > 0) continue;
|
|
@@ -70,7 +71,7 @@ const ledgerCheckUtil = {
|
|
|
}
|
|
|
return error;
|
|
|
},
|
|
|
- checkZero: function (ledgerTree) {
|
|
|
+ checkZero: function (ledgerTree, ledgerPos, decimal, option) {
|
|
|
const error = [];
|
|
|
for (const node of ledgerTree.nodes) {
|
|
|
if ((!node.b_code || node.b_code === '')) continue;
|
|
@@ -82,7 +83,7 @@ const ledgerCheckUtil = {
|
|
|
}
|
|
|
return error;
|
|
|
},
|
|
|
- checkTp: function (ledgerTree, decimal, option) {
|
|
|
+ checkTp: function (ledgerTree, ledgerPos, decimal, option) {
|
|
|
const error = [];
|
|
|
for (const node of ledgerTree.nodes) {
|
|
|
if (node.children && node.children.length > 0) continue;
|
|
@@ -97,38 +98,27 @@ const ledgerCheckUtil = {
|
|
|
}
|
|
|
return error;
|
|
|
},
|
|
|
- checkOver: function(ledgerTree, ledgerPos, option) {
|
|
|
+ checkOver: function(ledgerTree, ledgerPos, decimal, option) {
|
|
|
const error = [];
|
|
|
for (const node of ledgerTree.nodes) {
|
|
|
if (node.children && node.children.length > 0) continue;
|
|
|
|
|
|
- if (option.isTz) {
|
|
|
- const posRange = ledgerPos.getLedgerPos(node.id) || [];
|
|
|
- if (posRange.length > 0) {
|
|
|
- for (const p of posRange) {
|
|
|
- if (p.end_contract_qty > p.quantity) {
|
|
|
- error.push(node);
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (node.is_tp) {
|
|
|
- if (option.isTz) {
|
|
|
- if (node.end_contract_tp > node.total_price) error.push(node);
|
|
|
- } else {
|
|
|
- if (node.end_contract_tp > node.deal_tp) error.push(node);
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (option.isTz) {
|
|
|
- if (node.end_contract_qty > node.quantity) error.push(node);
|
|
|
- } else {
|
|
|
- if (node.end_contract_qty > node.deal_qty) error.push(node);
|
|
|
- }
|
|
|
- }
|
|
|
+ if (checkUtils.billsOver(node, option.isTz, ledgerPos)) error.push(node);
|
|
|
}
|
|
|
return error;
|
|
|
},
|
|
|
+ checkSameCode: function (ledgerTree, ledgerPos, decimal, option) {
|
|
|
+ const error = [];
|
|
|
+ let xmj = ledgerTree.nodes.filter(x => { return /^((GD*)|G)?[0-9]+/.test(x.code); });
|
|
|
+ let check = null;
|
|
|
+ while (xmj.length > 0) {
|
|
|
+ [check, xmj] = _.partition(xmj, x => { return x.code === xmj[0].code; });
|
|
|
+ if (check.length > 1) {
|
|
|
+ error.push(...check);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return error;
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
const ledgerCheck2 = function (setting) {
|
|
@@ -152,35 +142,12 @@ const ledgerCheck2 = function (setting) {
|
|
|
warning_data: [],
|
|
|
};
|
|
|
const progressData = [];
|
|
|
- if (checkOption.sibling.enable) {
|
|
|
- const sibling = ledgerCheckUtil.checkSibling(ledger, checkOption.sibling) || [];
|
|
|
- assignWarningData(sibling, ledgerCheckType.sibling.value, checkData.warning_data);
|
|
|
- progressData.push({key: 'sibling', caption: ledgerCheckType.sibling.text, error: sibling.length});
|
|
|
- }
|
|
|
- if (checkOption.empty_code.enable) {
|
|
|
- const empty_code = ledgerCheckUtil.checkCodeEmpty(ledger, checkOption.empty_code) || [];
|
|
|
- assignWarningData(empty_code, ledgerCheckType.empty_code.value, checkData.warning_data);
|
|
|
- progressData.push({key: 'empty_code', caption: ledgerCheckType.empty_code.text, error: empty_code.length});
|
|
|
- }
|
|
|
- if (checkOption.calc.enable) {
|
|
|
- const calc = ledgerCheckUtil.checkCalc(ledger, ledgerPos, checkOption.calc) || [];
|
|
|
- assignWarningData(calc, ledgerCheckType.calc.value, checkData.warning_data);
|
|
|
- progressData.push({key: 'calc', caption: ledgerCheckType.calc.text, error: calc.length});
|
|
|
- }
|
|
|
- if (checkOption.zero.enable) {
|
|
|
- const zero = ledgerCheckUtil.checkZero(ledger, checkOption.zero) || [];
|
|
|
- assignWarningData(zero, ledgerCheckType.zero.value, checkData.warning_data);
|
|
|
- progressData.push({key: 'zero', caption: ledgerCheckType.zero.text, error: zero.length});
|
|
|
- }
|
|
|
- if (checkOption.tp.enable) {
|
|
|
- const tp = ledgerCheckUtil.checkTp(ledger, decimal, checkOption.tp) || [];
|
|
|
- assignWarningData(tp, ledgerCheckType.tp.value, checkData.warning_data);
|
|
|
- progressData.push({key: 'tp', caption: ledgerCheckType.tp.text, error: tp.length});
|
|
|
- }
|
|
|
- if (checkOption.over && checkOption.over.enable) {
|
|
|
- const over = ledgerCheckUtil.checkOver(ledger, ledgerPos, checkOption.over) || [];
|
|
|
- assignWarningData(over, ledgerCheckType.over.value, checkData.warning_data);
|
|
|
- progressData.push({key: 'over', caption: ledgerCheckType.over.text, error: over.length});
|
|
|
+ for (const prop in ledgerCheckType) {
|
|
|
+ if (!checkOption[prop] || !checkOption[prop].enable) continue;
|
|
|
+
|
|
|
+ const errors = ledgerCheckUtil[ledgerCheckType[prop].fun](ledger, ledgerPos, decimal, checkOption[prop]) || [];
|
|
|
+ assignWarningData(errors, ledgerCheckType[prop].value, checkData.warning_data);
|
|
|
+ progressData.push({key: prop, caption: ledgerCheckType[prop].text, error: errors.length});
|
|
|
}
|
|
|
setting.checkList.clearCheckData();
|
|
|
if (checkData.warning_data.length > 0) {
|