Forráskód Böngészése

修改排序规则

laiguoran 4 éve
szülő
commit
fde093d523

+ 29 - 3
app/public/js/change_information_set.js

@@ -16,10 +16,34 @@ function sortByCode(a, b) {
     for (let i = 0; i < code1length; i ++) {
         if (i+1 <= code2length) {
             if (code1[i] != code2[i]) {
-                if (!/^\d+$/.test(code1[i])) {
-                    return code1[i].charCodeAt() - code2[i].charCodeAt();
-                } else {
+                if (/^\d+$/.test(code1[i]) && /^\d+$/.test(code2[i])) {
                     return parseInt(code1[i]) - parseInt(code2[i]);
+                } else if (!/^\d+$/.test(code1[i]) && /^\d+$/.test(code2[i])) {
+                    return 1;
+                } else if (/^\d+$/.test(code1[i]) && !/^\d+$/.test(code2[i])) {
+                    return -1;
+                } else {
+                    const str1length = code1[i].length;
+                    const str2length = code2[i].length;
+                    for (let j = 0; j < str1length; j++) {
+                        if (j+1 <= str2length) {
+                            if (code1[i].charAt(j) != code2[i].charAt(j)) {
+                                return code1[i].charAt(j).charCodeAt() - code2[i].charAt(j).charCodeAt();
+                            }  else if (j+1 == str1length && code1[i].charAt(j) == code2[i].charAt(j)) {
+                                if (str1length == str2length) {
+                                    return 0;
+                                } else {
+                                    return str1length - str2length;
+                                }
+                            }
+                        } else {
+                            if (j+1 >= str1length) {
+                                return 1;
+                            } else {
+                                return -1;
+                            }
+                        }
+                    }
                 }
             } else if (i+1 == code1length && code1[i] == code2[i]) {
                 if (code1length == code2length) {
@@ -368,7 +392,9 @@ $(document).ready(() => {
                 dealBillList.splice(exist_index, 1);
             }
         }
+        console.log(gclGatherData.concat(dealBillList));
         changeListData = gclGatherData.concat(dealBillList).sort(sortByCode);
+        console.log(changeListData);
         // 先加载台账数据
         let listHtml = '';
         let list_index = 1;

+ 5 - 4
app/public/js/schedule_stage_tp.js

@@ -75,7 +75,7 @@ $(function () {
             const showList = ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'ledger_id', 'ledger_pid', 'order', 'level', 'tender_id', 'full_path',
                 'code', 'name', 'unit', 'dgn_qty1', 'dgn_qty2', 'dgn_price', 'quantity', 'total_price', 'contract_tp', 'qc_tp', 'gather_tp',
                 'pre_contract_tp', 'pre_qc_tp', 'pre_gather_tp', 'end_contract_tp', 'end_qc_tp', 'end_gather_tp', 'end_correct_tp'];
-            const baseLedgerTree = createNewPathTree('base', {
+            const baseLedgerTreeSetting = {
                 id: 'ledger_id',
                 pid: 'ledger_pid',
                 order: 'order',
@@ -83,9 +83,9 @@ $(function () {
                 rootId: -1,
                 fullPath: 'full_path',
                 calcFields: calcList,
-            });
-            baseLedgerTree.updateFields = ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'postil', 'used', 'contract_expr'];
-            baseLedgerTree.calcFun = function (node) {
+            };
+            baseLedgerTreeSetting.updateFields = ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'postil', 'used', 'contract_expr'];
+            baseLedgerTreeSetting.calcFun = function (node) {
                 if (!node.children || node.children.length === 0) {
                     node.pre_gather_qty = ZhCalc.add(node.pre_contract_qty, node.pre_qc_qty);
                     node.gather_qty = ZhCalc.add(node.contract_qty, node.qc_qty);
@@ -111,6 +111,7 @@ $(function () {
                 node.final_dgn_price = ZhCalc.round(ZhCalc.div(node.end_gather_tp, ZhCalc.add(node.deal_dgn_qty1, node.c_dgn_qty1)), tenderInfo.decimal.up);
                 node.dgn_price = ZhCalc.round(ZhCalc.div(node.total_price, node.dgn_qty1), 2);
             };
+            const baseLedgerTree = createNewPathTree('base', baseLedgerTreeSetting);
             // const newLedgerList = setMonthToLedger(data.bills, data.slm);
             baseLedgerTree.loadDatas(data.ledgerData);
             treeCalc.calculateAll(baseLedgerTree);