Selaa lähdekoodia

重复项目节,检查范围调整

MaiXinRong 4 vuotta sitten
vanhempi
commit
60d9e4fd1d
2 muutettua tiedostoa jossa 26 lisäystä ja 2 poistoa
  1. 13 1
      app/lib/ledger.js
  2. 13 1
      app/public/js/ledger_check.js

+ 13 - 1
app/lib/ledger.js

@@ -734,7 +734,19 @@ class checkData {
     }
 
     checkSameCode() {
-        let xmj = this.checkBills.nodes.filter(x => { return /^((GD*)|G)?[0-9]+/.test(x.code); });
+        //let xmj = this.checkBills.nodes.filter(x => { return /^((GD*)|G)?[0-9]+/.test(x.code); });
+        let xmj = [];
+        const addXmjCheck = function (node) {
+            if (/^((GD*)|G)?[0-9]+/.test(node.code)) xmj.push(node);
+            for (const child of node.children) {
+                addXmjCheck(child);
+            }
+        };
+        for (const topLevel of this.checkBills.children) {
+            if ([1, 3, 4].indexOf(topLevel.node_type) < 0) continue;
+
+            addXmjCheck(topLevel);
+        }
         let check = null;
         while (xmj.length > 0) {
             [check, xmj] = this.ctx.helper._.partition(xmj, x => { return x.code === xmj[0].code; });

+ 13 - 1
app/public/js/ledger_check.js

@@ -117,7 +117,19 @@ const ledgerCheckUtil = {
     },
     checkSameCode: function (ledgerTree, ledgerPos, decimal, option) {
         const error = [];
-        let xmj = ledgerTree.nodes.filter(x => { return /^((GD*)|G)?[0-9]+/.test(x.code); });
+        //let xmj = ledgerTree.nodes.filter(x => { return /^((GD*)|G)?[0-9]+/.test(x.code); });
+        let xmj = [];
+        const addXmjCheck = function (node) {
+            if (/^((GD*)|G)?[0-9]+/.test(node.code)) xmj.push(node);
+            for (const child of node.children) {
+                addXmjCheck(child);
+            }
+        };
+        for (const topLevel of ledgerTree.children) {
+            if ([1, 3, 4].indexOf(topLevel.node_type) < 0) continue;
+
+            addXmjCheck(topLevel);
+        }
         let check = null;
         while (xmj.length > 0) {
             [check, xmj] = _.partition(xmj, x => { return x.code === xmj[0].code; });