浏览代码

缺陷修改

xujie 1 年之前
父节点
当前提交
336f7beb46
共有 3 个文件被更改,包括 30 次插入27 次删除
  1. 16 24
      src/App.vue
  2. 13 2
      src/components/AlarmDeal/index.vue
  3. 1 1
      src/components/SystemNotify/index.vue

+ 16 - 24
src/App.vue

@@ -2,7 +2,7 @@
   <div id="app">
     <watercom ref="watercom"></watercom>
     <router-view />
-    <system-notify ref="notify" :msgData="msgData" @showDailog="showDailog" />
+    <system-notify ref="notify" :msgData="msgData" @showDialog="showDialog" />
     <alarm-deal ref="alarmDeal"  @removeMessage="removeMessage"/>
   </div>
 </template>
@@ -41,16 +41,18 @@ export default {
     ...mapGetters(['userName', 'messageShow']),
   },
   methods: {
-    showDailog(obj){
+    showDialog(obj){
       this.$refs.alarmDeal.show = true;
       this.$refs.alarmDeal.data = obj;
     },
     removeMessage(iotAlarmDataId){
-      console.log("chuliid:"+iotAlarmDataId)
-      if (this.messages.length > 0){
-        this.messages = this.messages.filter(item => item.iotAlarmDataId+'' !== iotAlarmDataId+'');
-        this.currentIndex = 0;
+      console.log("处理报警id:"+iotAlarmDataId)
+      let index = this.messages.findIndex(item => item.iotAlarmDataId+'' === iotAlarmDataId+'');
+      if (index !== -1){
+        this.messages.splice(index, 1)
       }
+      this.currentIndex = 0;
+
       if (this.messages.length === 0){
         //无消息就不显通知
         clearInterval(this.timer);
@@ -59,13 +61,12 @@ export default {
     },
     startLoop() {
       this.$refs.notify.show = false;
-      this.currentItem = this.messages[this.currentIndex];
       this.timer = setInterval(() => {
         if(this.messageShow){
           this.$refs.notify.show = true;
+          this.nextItem();
         }
-        this.nextItem();
-      }, 10 * 1000); // 每 10 秒切换一次
+      }, 15 * 1000); // 每 15 秒切换一次
     },
     nextItem() {
       this.currentIndex = (this.currentIndex + 1) % this.messages.length;
@@ -83,11 +84,7 @@ export default {
       return url;
     },
     initWebSocket() {
-      if(!config.VITE_APP_WEBSOCKET){
-        return;
-      }
-
-      if(!getToken()){
+      if(!config.VITE_APP_WEBSOCKET || !getToken()){
         return;
       }
 
@@ -123,22 +120,17 @@ export default {
       this.startSocketHeartBeat();
     },
     dealMessage(msg) {
+      //收到消息首先清除显示
+      clearInterval(this.timer);
+      this.$refs.notify.show = false;
+
       let alarm =  JSON.parse(msg);
       //如果消息已经被处理了,就从队列中移除
       if(alarm.isDo && alarm.isDo === 1){
-        if (this.messages.length > 0){
-          this.messages = this.messages.filter(item => item.iotAlarmDataId+'' !== alarm.iotAlarmDataId+'');
-          this.currentIndex = 0;
-        }
-        if (this.messages.length === 0){
-          //无消息就不显通知
-          clearInterval(this.timer);
-          this.$refs.notify.show = false;
-        }
+        this.removeMessage(alarm.iotAlarmDataId);
       }else {
         this.messages.push(alarm);
       }
-      //this.messages = alarm;
     },
     clearMessage(){
       //websocket 清空消息

+ 13 - 2
src/components/AlarmDeal/index.vue

@@ -1,6 +1,12 @@
 <template>
   <div>
-    <van-dialog v-model="show" title="告警处理" show-cancel-button :before-close="beforeCloseDialog">
+    <van-dialog
+      v-model="show"
+      title="告警处理"
+      show-cancel-button
+      :safe-area-inset-bottom="true"
+      :before-close="beforeCloseDialog"
+    >
       <div class="dialogContent">
         <van-cell title="所属机构" :value="data.orgName" />
         <van-cell title="设备名称" :value="data.deviceName" />
@@ -83,6 +89,11 @@ export default {
           this.$toast('提交成功')
           this.$store.commit('SET_MESSAGE_SHOW', true)
           this.$emit('removeMessage', this.data.iotAlarmDataId);
+          this.submitData = {
+            doType: null,
+            content: null,
+            iotAlarmDataId: null
+          }
         } else
           this.$toast("处理失败!")
       });
@@ -107,6 +118,6 @@ export default {
 <style scoped>
 .dialogContent{
   width: 100%;
-  height: 70vh;
+  //height: 70vh;
 }
 </style>

+ 1 - 1
src/components/SystemNotify/index.vue

@@ -72,7 +72,7 @@ export default {
     },
     showNotify() {
       this.show = false;
-      this.$emit('showDailog', this.msgData);
+      this.$emit('showDialog', this.msgData);
       this.$store.commit('SET_MESSAGE_SHOW', false)
     }
   }