xushining 3 سال پیش
والد
کامیت
ad6c4fdfa5
2فایلهای تغییر یافته به همراه57 افزوده شده و 26 حذف شده
  1. 49 23
      src/App.vue
  2. 8 3
      src/components/CenterPage.vue

+ 49 - 23
src/App.vue

@@ -1,6 +1,6 @@
 <template>
   <TitleBar />
-  <CenterPage :datas="datas" :values="values"></CenterPage>
+  <CenterPage ref="center" :problemDatas="problemDatas" :values="values"></CenterPage>
   <StatusBar />
 </template>
 
@@ -17,32 +17,58 @@ export default {
     CenterPage,
     StatusBar,
   },
-  props: {
-    values:Array,
-    datas:Array,
+  props:{
+    problemDatas:Array,
   },
   created: function () {
-    initData();
+    this.initData();
   },
-  methods: {},
-};
+  methods: {
+    initData() {
+      var mb = MessageBridge.getInstance();
+      var vs = [
+        { key: "/topic/windturbine", action: this.windturbineMessage },
+        { key: "/topic/suggestion", action: this.suggestion },
+      ];
+      mb.register(vs);
+    },
+    windturbineMessage(msg) {
+      console.log(msg);
+      var val = JSON.parse(msg);
+      this.problem(val);
+      this.$refs.center.windturbineInfo(msg);
+      console.log(val);
+    },
+
+    suggestion(msg) {
+      console.log(msg);
+    },
 
-function initData() {
-  var mb = MessageBridge.getInstance();
-  var vs = [
-    { key: "/topic/windturbine", action: windturbineMessage },
-    {key:"/topic/suggestion",action:suggestion}
-  ];
-  mb.register(vs);
-}
-function windturbineMessage(msg) {
-  console.log(msg);
-  values=msg;
-}
-function suggestion(msg){
-  console.log(msg);
-  datas=msg;
-}
+    problem(msg) {
+      var ls = { maintain: [], malfunction: [], offline: [], lockd: [] };
+      for (var id in msg) {
+        var val = msg[id];
+        if (val.status == 6) {
+          // 维护
+          ls.maintain.push(val);
+        } else if (val.status == 7) {
+          // 离线
+          ls.offline.push(val);
+          console.log(id);
+        } else if (val.status == 5) {
+          // 故障
+          ls.malfunction.push(val);
+          console.log(id);
+        } else if (val.lockValue > 0) {
+          // 挂牌
+          ls.lockd.push(val);
+          console.log(id);
+        }
+      }
+      this.problemDatas=ls;
+    },
+  },
+};
 </script>
 
 <style scoped>

+ 8 - 3
src/components/CenterPage.vue

@@ -3,7 +3,7 @@
     <div class='center-bar'>
         <el-row :gutter="10">
             <el-col :span="8">
-                <ProblemArea/>
+                <ProblemArea ref="problem" :datas="problemDatas"/>
             </el-col>
             <el-col :span="8">
                 <el-row>
@@ -55,8 +55,13 @@
             RecommendedArea
         },
         props:{
-            datas:Array,
-            values:Array,
+            problemDatas:Array,
+        },
+        methods:{
+            windturbineInfo(infos){
+                console.log(infos);
+            }
+
         }
     }
 </script>