Browse Source

1-1, 1的排序问题

zhongzewei 6 years ago
parent
commit
3664669c44
2 changed files with 14 additions and 6 deletions
  1. 7 3
      web/maintain/ration_repository/js/ration.js
  2. 7 3
      web/maintain/std_glj_lib/js/glj.js

+ 7 - 3
web/maintain/ration_repository/js/ration.js

@@ -732,12 +732,16 @@ let rationOprObj = {
     },
     sortByCode: function(arr){
         function recurCompare(a, b, index){
-            if (a[index] && b[index]) {
+            if (a[index] && !b[index]) {
+                return 1;
+            } else if (!a[index] && b[index]) {
+                return -1;
+            } else if (a[index] && b[index]) {
                 let aV = a[index],
                     bV = b[index];
                 if (!isNaN(aV) && !isNaN(bV)) {
-                    aV = parseFloat(a[index]),
-                        bV = parseFloat(b[index]);
+                    aV = parseFloat(a[index]);
+                    bV = parseFloat(b[index]);
                 }
                 if (aV > bV) {
                     return 1;

+ 7 - 3
web/maintain/std_glj_lib/js/glj.js

@@ -1614,12 +1614,16 @@ let repositoryGljObj = {
     },
     sortGljDeep: function (datas) {
         function recurCompare(a, b, index){
-            if (a[index] && b[index]) {
+            if (a[index] && !b[index]) {
+                return 1;
+            } else if (!a[index] && b[index]) {
+                return -1;
+            } else if (a[index] && b[index]) {
                 let aV = a[index],
                     bV = b[index];
                 if (!isNaN(aV) && !isNaN(bV)) {
-                    aV = parseFloat(a[index]),
-                        bV = parseFloat(b[index]);
+                    aV = parseFloat(a[index]);
+                    bV = parseFloat(b[index]);
                 }
                 if (aV > bV) {
                     return 1;