Explorar o código

传感器实时数据

王通 %!s(int64=2) %!d(string=hai) anos
pai
achega
b35cb20f2b
Modificáronse 1 ficheiros con 28 adicións e 10 borrados
  1. 28 10
      src/views/monitor.vue

+ 28 - 10
src/views/monitor.vue

@@ -96,7 +96,7 @@
                 :class="{on:listCurrentIndex2 == index}" v-on:click="dropLocation(item.latitude,item.longitude,index)">
                 <div class="d-l-l-text">
                   <i class="iconfont sj-icon-jkzx icon-sxt"></i>
-                  <h4>{{ item.cameraName }}</h4><h4 v-html="cgqData"></h4>
+                  <h4>{{ item.cameraName }}</h4><h4 v-if="onChuan" v-html="cgqData[index]"></h4>
                 </div>
               </div>
             </div>
@@ -209,7 +209,7 @@
     data() {
       return {
         //摄像头名称
-        cgqData:'',
+        cgqData:[],
         rightDeptName: undefined,
         visuForestCloudCameraBOListSearch: [],
         // 部门名称
@@ -286,8 +286,21 @@
       }
     },
     methods: {
-      setcgqValue:function(){
-        let that=this
+      setcgqValue: function() {
+        let that = this
+        for (let i = 0; i < that.visuForestCloudCameraBOListSearch.length; i++) {
+          var color = "green";
+          var value = Math.random();
+          var up = "▲";
+          var down = "▼";
+          if (value > 0.5) {
+            color = "red";
+            value = value + "" + up;
+          } else {
+            value = value + "" + down;
+          }
+          that.cgqData.push("<span style='color:" + color + "'>" + value + "</span>")
+        }
         setInterval(function() {
           var color = "green";
           var value = Math.random();
@@ -299,8 +312,12 @@
           } else {
             value = value + "" + down;
           }
-          that.cgqData =  "<span style='color:" + color + "'>" + value + "</span>";
-        }, 1000)
+          that.cgqData.push("<span style='color:" + color + "'>" + value + "</span>")
+          if (that.cgqData.length > that.visuForestCloudCameraBOListSearch.length) {
+            console.log(that.cgqData)
+            that.cgqData.splice(0, 1)
+          }
+        }, 5000)
       },
       /* 电视墙替换开始 */
       showTVWall(channelCode, channelName) {
@@ -399,9 +416,7 @@
         this.getDlblistBydeptId()
       },
       chuanClick() {
-        this.onLa = false
-        this.onShe = false
-        this.onChuan = true
+
         this.localMark = 'chuan'
         this.placeholderMsg = "请输入传感器名称"
         this.getSensorListByDeptId()
@@ -471,7 +486,6 @@
         let that = this;
         let markersList = [];
         getSensorListByDeptId(that.deptId).then(function(res) {
-          that.setcgqValue()
             that.visuForestCloudCameraBOListSearch = []
             // that.sensorNum = res.data.length
             if (res.data != null && res.data.length > 0) {
@@ -516,6 +530,7 @@
 
                 markersList.push(markersMap);
               }
+              that.setcgqValue()
               setTimeout(() => {
                 that.$refs.supermap.clearM();
               that.$refs.supermap.clearMRadius()
@@ -527,6 +542,9 @@
               that.$refs.supermap.clearMRadius()
               }, 2000);
             }
+            that.onLa = false
+          that.onShe = false
+          that.onChuan = true
           })
           .catch(function(error) {
             console.error(error);