Przeglądaj źródła

逆变器单机页面

wsy 3 lat temu
rodzic
commit
917759daf7
1 zmienionych plików z 79 dodań i 21 usunięć
  1. 79 21
      src/views/WindSite/pages/Inverter-Info.vue

+ 79 - 21
src/views/WindSite/pages/Inverter-Info.vue

@@ -18,13 +18,13 @@
       </div>
       <div class="Inverter-Info-body">
         <div class="Inverter-Info-title">
-          <div class="title">3#逆变器</div>
+          <div class="title">{{info.name}}</div>
 
           <div class="title-tools-left">
-            <div class="other">逆变器型号:GBL-200</div>
+            <div class="other">逆变器型号:{{info.modelid}}</div>
             <div class="state">
               状态:
-              <div class="dot red"></div>
+              <div class="dot" :class="stateColor"></div>
             </div>
           </div>
           <!-- <div class="title-tools">
@@ -107,9 +107,13 @@ export default {
   // 数据
   data() {
     return {
+      timmer: null,
+      timmer1: null,
       WindSites: [],
       diAll: [],
       diOn: [],
+      info: {},
+      stateColor: "blue",
       list: {
         title: "逆变器列表",
         datas: [
@@ -159,6 +163,7 @@ export default {
       let WindSites = [];
       res.data.data.forEach((ele, index) => {
         ele.inverterls.forEach(function(inver) {
+          // inver["text"] = inver["wtnum"];
           inver["text"] = inver["wtnum"];
           inver["color"] = "blue";
         });
@@ -180,8 +185,8 @@ export default {
         }
       });
       const aiData = [];
-      if (res.data.data) {
-        const arr = res.data.data;
+      if (res.data.data.listAI) {
+        const arr = res.data.data.listAI;
         for (let index = 0; index < arr.length; index = index + 2) {
           const elem1 = arr[index];
           const elem2 = arr[index + 1];
@@ -192,20 +197,12 @@ export default {
         }
       }
       this.aiData = aiData;
-    },
-    async getDIData() {
-      let res = await this.API.requestData({
-        method: "POST",
-        // baseURL: "http://localhost:8082/",
-        subUrl: "monitorinverter/findInverterDI",
-        data: {
-          wtId: this.wtId
-        }
-      });
-      if (res.data.data) {
-        this.diAll = res.data.data.allList;
-        this.diOn = res.data.data.onList;
+      // di
+      if (res.data.data.listDI) {
+        this.diAll = res.data.data.listDI.allList;
+        this.diOn = res.data.data.listDI.onList;
       }
+      this.info = res.data.data.info;
     },
     async getLineChart() {
       let res = await this.API.requestData({
@@ -234,6 +231,56 @@ export default {
           value: result
         }
       ];
+    },
+    async getTurbinesState() {
+      let that = this;
+      let res = await this.API.requestData({
+        method: "POST",
+        subUrl: "matrix/matrixDetialGfPush"
+      });
+      const ztmap = {};
+      if (res && res.data && res.data.data && res.data.data.fjmap) {
+        res.data.data.fjmap.forEach(function(fcList) {
+          fcList.forEach(function(fjItem) {
+            ztmap[fjItem["wtId"]] = fjItem["fjzt"];
+          });
+        });
+      }
+      that.stateColor = that.getColor(ztmap[that.wtId]);
+      if (this.WindSites) {
+        this.WindSites.forEach(function(ws) {
+          if (ws.children) {
+            ws.children.forEach(function(fj) {
+              fj["color"] = that.getColor(ztmap[fj.wtId]);
+            });
+          }
+        });
+      }
+    },
+    getColor(fjzt) {
+      switch (fjzt) {
+        case 0:
+          return "green";
+          break;
+        case 1:
+          return "blue";
+          break;
+        case 2:
+          return "red";
+          break;
+        case 3:
+          return "gray";
+          break;
+        case 4:
+          return "orange";
+          break;
+        case 5:
+          return "purple";
+          break;
+        case 6:
+          return "write";
+          break;
+      }
     }
   },
   // 生命周期钩子
@@ -242,13 +289,15 @@ export default {
   },
   created() {
     this.buildSelectList();
+    this.getTurbinesState();
     this.getData();
-    this.getDIData();
+    // this.getDIData();
     this.getLineChart();
     let that = this;
     that.timmer = setInterval(() => {
       that.getData();
-      that.getDIData();
+      // that.getDIData();
+      that.getTurbinesState();
     }, 2000);
     that.timmer1 = setInterval(() => {
       that.getLineChart();
@@ -265,6 +314,12 @@ export default {
   },
   updated() {
     // 数据更新后
+  },
+  unmounted() {
+    clearInterval(this.timmer);
+    this.timmer = null;
+    clearInterval(this.timmer1);
+    this.timmer1 = null;
   }
 };
 </script>
@@ -356,7 +411,7 @@ export default {
         .title-tools-left {
           position: absolute;
           top: 0;
-          left: 100px;
+          left: 150px;
           // margin-left: 10px;
           display: flex;
           color: @gray-l;
@@ -390,6 +445,9 @@ export default {
               &.red {
                 background: @red;
               }
+              &.blue {
+                background: @blue;
+              }
             }
           }
         }