laiguoran 4 年之前
父節點
當前提交
36f8b2a8e2
共有 1 個文件被更改,包括 31 次插入2 次删除
  1. 31 2
      app/public/js/shenpi.js

+ 31 - 2
app/public/js/shenpi.js

@@ -1063,7 +1063,36 @@ function setAllChildrenCanEdit(ledgerInfo, flag) {
         }
     }
 }
-
+// 编号排序,多重判断
+function sortByCode(a, b) {
+    let code1 = a.code.split('-');
+    let code2 = b.code.split('-');
+    let code1length = code1.length;
+    let code2length = code2.length;
+    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 {
+                    return parseInt(code1[i]) - parseInt(code2[i]);
+                }
+            } else if (i+1 == code1length && code1[i] == code2[i]) {
+                if (code1length == code2length) {
+                    return 0;
+                } else {
+                    return code1length - code2length;
+                }
+            }
+        } else {
+            if (i+1 >= code1length) {
+                return 1;
+            } else {
+                return -1;
+            }
+        }
+    }
+}
 function setLeftTable(ledgerList, coolist, uid, title) {
     $('#stage_audit').text(title);
     const showCooList = _.filter(coolist, { 'user_id': parseInt(uid) });
@@ -1084,7 +1113,7 @@ function setLeftTable(ledgerList, coolist, uid, title) {
     }
 
     let html = '';
-    for (const sc of showCooList) {
+    for (const sc of showCooList.sort(sortByCode)) {
         const pichtml = sc.sign_path ? `<img src="/${sc.sign_path}" width="60"><input type="file" data-id="${sc.id}" class="upload-img-file" style="display: none;"><a href="javascript: void(0);" class="d-inline-flex upload-img">更改</a>`
             : `<img src="" style="display: none" width="60"><input type="file" data-id="${sc.id}" class="upload-img-file" style="display: none;"><a href="javascript: void(0);" class="btn btn-outline-primary btn-sm upload-img">上传签名</a>`;
         html += `<tr>` +