Bladeren bron

更新排序方法

zhangweicheng 7 jaren geleden
bovenliggende
commit
ae2d9bc76b

+ 9 - 0
web/building_saas/glj/js/project_glj.js

@@ -229,6 +229,7 @@ function init() {
             // 赋值
             jsonData = data.gljList !== undefined && data.gljList.length > 0 ? data.gljList : [];
             jsonData= filterProjectGLJ(jsonData);
+            jsonData = sortProjectGLJ(jsonData);
             mixRatioConnectData = data.mixRatioConnectData !== undefined ? data.mixRatioConnectData : mixRatioConnectData;
             mixRatioMap = data.mixRatioMap !== undefined ? data.mixRatioMap : mixRatioMap;
             host = data.constData.hostname !== undefined ? data.constData.hostname : '';
@@ -389,3 +390,11 @@ function filterProjectGLJ(jsonData) {
     return jsonData;
 }
 
+function sortProjectGLJ(jsonData) {
+    if (jsonData.length > 0){
+        jsonData = _.sortByAll(jsonData,[function (item) {
+            return item.unit_price.type+"";
+        },'code']);
+    }
+    return jsonData
+}

+ 1 - 0
web/building_saas/main/js/models/project_glj.js

@@ -140,6 +140,7 @@ ProjectGLJ.prototype.loadCacheData = function() {
     }
     jsonData = data.gljList !== undefined && data.gljList.length > 0 ? data.gljList : [];
     jsonData=filterProjectGLJ(jsonData);
+    jsonData = sortProjectGLJ(jsonData);
     projectGLJSheet.setData(jsonData);
     projectGLJSpread.specialColumn(jsonData);
 };

+ 8 - 1
web/building_saas/main/js/views/glj_view.js

@@ -559,7 +559,7 @@ var gljOprObj = {
         this.sheet.setRowCount(0);
         //console.log(+new Date())
         //this.sheet.getRange(0,-1,this.sheet.getRowCount(),-1).visible(true); //这个方法导致加载缓慢
-        this.sheetData=_.sortByAll(this.sheetData,['type','code']);
+        this.sheetData=sortRationGLJ(this.sheetData);
         this.sumQuantity();//计算总消耗量
         this.addMixRatioToShow();//显示组成物信息
         this.initRationTree(init);
@@ -1298,4 +1298,11 @@ function getFormatter(decimal) {
         pre += "0"
     }
     return pre;
+}
+
+function sortRationGLJ(list) {
+    list= _.sortByAll(list,[function (item) {
+        return item.type+"";
+    },"code"])
+    return list;
 }