Przeglądaj źródła

修复变更令清单排序bug

ellisran 3 tygodni temu
rodzic
commit
cdcad0c85e

+ 8 - 2
app/public/js/change_information.js

@@ -17,8 +17,14 @@ const is_numeric = (value) => {
     }
 };
 function sortByCode(a, b) {
-    let code1 = a.code.split('-');
-    let code2 = b.code.split('-');
+    const codeValue1 = a && a.code != null ? String(a.code) : '';
+    const codeValue2 = b && b.code != null ? String(b.code) : '';
+    // 空编号排在最后,两者都为空时保持原顺序。
+    if (codeValue1 === '' || codeValue2 === '') {
+        return codeValue1 === codeValue2 ? 0 : (codeValue1 === '' ? 1 : -1);
+    }
+    let code1 = codeValue1.split('-');
+    let code2 = codeValue2.split('-');
     let code1length = code1.length;
     let code2length = code2.length;
     for (let i = 0; i < code1length; i ++) {

+ 8 - 2
app/public/js/change_information_add_list.js

@@ -9,8 +9,14 @@
  */
 // 编号排序,多重判断
 function sortByCode(a, b) {
-    let code1 = a.code.split('-');
-    let code2 = b.code.split('-');
+    const codeValue1 = a && a.code != null ? String(a.code) : '';
+    const codeValue2 = b && b.code != null ? String(b.code) : '';
+    // 空编号排在最后,两者都为空时保持原顺序。
+    if (codeValue1 === '' || codeValue2 === '') {
+        return codeValue1 === codeValue2 ? 0 : (codeValue1 === '' ? 1 : -1);
+    }
+    let code1 = codeValue1.split('-');
+    let code2 = codeValue2.split('-');
     let code1length = code1.length;
     let code2length = code2.length;
     for (let i = 0; i < code1length; i ++) {

+ 8 - 2
app/public/js/change_information_set.js

@@ -9,8 +9,14 @@
  */
 // 编号排序,多重判断
 function sortByCode(a, b) {
-    let code1 = a.code.split('-');
-    let code2 = b.code.split('-');
+    const codeValue1 = a && a.code != null ? String(a.code) : '';
+    const codeValue2 = b && b.code != null ? String(b.code) : '';
+    // 空编号排在最后,两者都为空时保持原顺序。
+    if (codeValue1 === '' || codeValue2 === '') {
+        return codeValue1 === codeValue2 ? 0 : (codeValue1 === '' ? 1 : -1);
+    }
+    let code1 = codeValue1.split('-');
+    let code2 = codeValue2.split('-');
     let code1length = code1.length;
     let code2length = code2.length;
     for (let i = 0; i < code1length; i ++) {

+ 8 - 2
app/public/js/change_revise.js

@@ -6262,8 +6262,14 @@ function findDecimal(unit) {
 
 // 编号排序,多重判断
 function sortByCode(a, b, code = 'b_code') {
-    let code1 = a[code].split('-');
-    let code2 = b[code].split('-');
+    const codeValue1 = a && a[code] != null ? String(a[code]) : '';
+    const codeValue2 = b && b[code] != null ? String(b[code]) : '';
+    // 空编号排在最后,两者都为空时保持原顺序。
+    if (codeValue1 === '' || codeValue2 === '') {
+        return codeValue1 === codeValue2 ? 0 : (codeValue1 === '' ? 1 : -1);
+    }
+    let code1 = codeValue1.split('-');
+    let code2 = codeValue2.split('-');
     let code1length = code1.length;
     let code2length = code2.length;
     for (let i = 0; i < code1length; i ++) {

+ 8 - 2
app/public/js/change_set.js

@@ -11,8 +11,14 @@
 $(document).ready(() => {
     // 编号排序,多重判断
     function sortByCode(a, b) {
-        let code1 = a.code.split('-');
-        let code2 = b.code.split('-');
+        const codeValue1 = a && a.code != null ? String(a.code) : '';
+        const codeValue2 = b && b.code != null ? String(b.code) : '';
+        // 空编号排在最后,两者都为空时保持原顺序。
+        if (codeValue1 === '' || codeValue2 === '') {
+            return codeValue1 === codeValue2 ? 0 : (codeValue1 === '' ? 1 : -1);
+        }
+        let code1 = codeValue1.split('-');
+        let code2 = codeValue2.split('-');
         let code1length = code1.length;
         let code2length = code2.length;
         for (let i = 0; i < code1length; i ++) {

+ 8 - 2
app/view/change/modal.ejs

@@ -1193,8 +1193,14 @@
 
         // 编号排序,多重判断
         function sortByCode(a, b) {
-            let code1 = a.code.split('-');
-            let code2 = b.code.split('-');
+            const codeValue1 = a && a.code != null ? String(a.code) : '';
+            const codeValue2 = b && b.code != null ? String(b.code) : '';
+            // 空编号排在最后,两者都为空时保持原顺序。
+            if (codeValue1 === '' || codeValue2 === '') {
+                return codeValue1 === codeValue2 ? 0 : (codeValue1 === '' ? 1 : -1);
+            }
+            let code1 = codeValue1.split('-');
+            let code2 = codeValue2.split('-');
             let code1length = code1.length;
             let code2length = code2.length;
             for (let i = 0; i < code1length; i ++) {