|
|
@@ -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 清空消息
|