|  | @@ -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,7 +98,7 @@ 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;
 | 
	
	
		
			
				|  | @@ -106,6 +107,18 @@ const ledgerCheckUtil = {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          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) {
 | 
	
	
		
			
				|  | @@ -129,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) {
 |