Browse Source

数据中心

wangzhe 2 năm trước cách đây
mục cha
commit
890597d0db
1 tập tin đã thay đổi với 42 bổ sung4 xóa
  1. 42 4
      src/views/datacenter.vue

+ 42 - 4
src/views/datacenter.vue

@@ -317,11 +317,49 @@ export default {
         //截取data.resourceTable字段中“_”分隔符最后一个作为关键字,重新拼接成前端需要的图标:class,格式sj-icon-xxxx,将其set回原数组
         res.data.forEach(function(data, index) {
           that.$set(that.resourcesList[index], 'icon', 'sj' + '-' + 'icon' + '-' + data.type.replaceAll("_", "-"));
-          if(index < 5){
-            // that.fireControlViewPoint(data.type, 'undefined');
-            that.indentleftSetMarkers(data.type, '所有');
-          }
+          // if(index < 5){
+          //   // that.fireControlViewPoint(data.type, 'undefined');
+          //   that.indentleftSetMarkers(data.type, '所有');
+          // }
         })
+        //数据自动落点开始
+        let maxCount = 100;//落点数超过这个数的资源不落点
+        let list = res.data;
+        let counts = [];
+        let points = [];
+        let types = [];
+        for(let i = 0; i < list.length; i++){//获取符合要求的类型及数量
+          if(list[i].num <= maxCount){
+            counts.push(list[i].num);
+            points.push({
+              "type": list[i].type,
+              "count": list[i].num
+            });
+          }
+        }
+        for(let i = 0; i < points.length; i++){
+          if(points[i].count == Math.max(...counts)){
+            types.push(points[i].type);
+            let countsTemp = [];
+            for (let j = 0; j < counts.length; j++) {
+              if(counts[j] != Math.max(...counts)){
+                countsTemp.push(counts[j]);
+              }
+            }
+            counts = countsTemp;
+            break;
+          }
+        }
+        for(let i = 0; i < points.length; i++){
+          if(points[i].count == Math.max(...counts)){
+            types.push(points[i].type);
+            break;
+          }
+        }
+        for(let i = 0; i < types.length; i++){
+          that.indentleftSetMarkers(types[i], '所有');
+        }
+        //数据自动落点结束
       })
     },
     indentleftSetMarkers(resourceTable, name) {