Просмотр исходного кода

前端异常警报功能处理

oyq28 1 неделя назад
Родитель
Сommit
1f4c3e6ee1

+ 4 - 4
imcs-ui/src/api/lineSideLibrary/warnLog.js

@@ -66,9 +66,9 @@ const apiList = {
     method: 'POST',
     url: `/authority/dispatchException/nodeCallback`
   },
-  synLineWarn: {
+  getLineWarn: {
     method: 'POST',
-    url: `/authority/warnLog/synLineWarn`
+    url: `/authority/warnLog/getLineWarn`
   }
 }
 
@@ -183,9 +183,9 @@ export default {
       data
     })
   },
-  synLineWarn (data) {
+  getLineWarn (data) {
     return axiosApi({
-      ...apiList.synLineWarn,
+      ...apiList.getLineWarn,
       data
     })
   }

+ 42 - 2
imcs-ui/src/layout/index.vue

@@ -19,6 +19,7 @@
 import RightPanel from '@/components/RightPanel'
 import { AppMain, Navbar, Settings, Sidebar, TagsView } from './components'
 import ResizeMixin from './mixin/ResizeHandler'
+import warnLogApi from "@/api/lineSideLibrary/warnLog"
 
 export default {
   name: 'Layout',
@@ -31,6 +32,12 @@ export default {
     TagsView
   },
   mixins: [ResizeMixin],
+  data () {
+    return {
+      timer: null,
+      dataList:[]
+    }
+  }, 
   computed: {
     sidebar() {
       return this.$store.state.setting.sidebar
@@ -57,15 +64,48 @@ export default {
     }   
   },
   watch: {
+      dataList:{
+        handler(){
+           //console.log('警报日志数据发生变化')
+        },
+        deep: true        
+      }
 	},
   mounted() {
-    
+    this.changeWarn()
   },  
   methods: {
     handleClickOutside() {
       this.$store.commit('setting/closeSidebar', { withoutAnimation: false })
+    },
+    changeWarn(){
+       this.timer = setInterval(()=>{
+          this.fetch();
+       }, 12000)
+    },
+    fetch(){
+      warnLogApi.getLineWarn().then(response => {
+	        const res = response.data
+	        if (res.isSuccess) {
+            //console.log(res.data)
+	          this.dataList = res.data
+            this.dataList.forEach((data)=>{
+                  let msg = data.feedback ? data.feedback : " 响应超时 ";
+                  let url = "#/developer/warnLong"
+                  let content = "<a href='"+url+"'>"+(data.resourceName? "["+ data.resourceName +"] " : "" )+(data.procedureName? data.procedureName : "")
+                   + (data.instructionName? "("+data.instructionName+")" : "") + msg+"</a>";                  
+                  this.$notification.error(content, { messageIsHTML: true, timer:10, title:"异常警报", showCloseIcn:true });
+              })
+	        }	       
+	      }).finally(() => {})
     }    
-  }
+  },
+  beforeDestroy() {
+    if (!this.timer) {
+      clearInterval(this.timer);
+      this.timer = null;
+    }    
+  },
 }
 </script>
 

+ 8 - 61
imcs-ui/src/views/zuihou/developer/warnLong/Index.vue

@@ -249,9 +249,7 @@
 	  	// 调用常量-审核状态
 	  	this.audioStatus = this.$constWKS.OPTTYPE
 	  	// 加载【字典】
-	  	initDicts(['NATION'], this.dicts);
-		// 同步产线警报
-		this.synLineWarn()
+	  	initDicts(['NATION'], this.dicts);		
 	  	// 加载列表数据
 	  	this.fetch()
 		},
@@ -261,27 +259,17 @@
 	    },
 	    nationList() {
         return convertEnum(this.dicts.NATION)
-      	},
-		websocketMsg() {
-	      return this.$store.getters.STAFF_UPDATE.msg
-	    },
+      	}		
 	  },
 	  watch: {
-	  	websocketMsg(curVal, oldVal) {
-	      	let obj = JSON.parse(curVal)
-	      	this.openMessageTips(obj)
-	    }
-	},
+	  	
+	 },
 	  mounted () {
-	     // 判断长连接,是否已经开启      
-	  	if(this.$store.state.websocket.websock == null){
-	  		// 页面刚进入时开启长连接
-    		this.$store.dispatch('STAFF_WEBSOCKET')	        
-	  	}     
+	    
 	  },
 	  // 销毁
       destroyed() {
-	  this.websocketClose()
+	  
 	  },
 	  methods: {
 	    viewClose () {
@@ -410,16 +398,7 @@
 	      this.$refs.edit.type = "edit"
 	      this.dialog.title = this.$t("common.edit")
 	      this.dialog.isVisible = true
-	    },
-		synLineWarn(){			
-			warnLogApi.synLineWarn({}).then(response => {
-	        const res = response.data
-	        if (res.isSuccess) {
-	          
-	        }
-	      }).finally(() => {})
-
-		},
+	    },		
 	    fetch (params = {}) {
 	      this.loading = true		  
 	      if (this.queryParams.timeRange) {
@@ -459,39 +438,7 @@
 	      if (!flag) {
 	        this.$refs.table.toggleRowSelection(row, true)
 	      }
-	    },
-		openMessageTips(data){      //排除数字大屏         
-      if(this.$route.fullPath.indexOf("/largeScreen")<0){
-        //console.log("接收websocket的推送信息 == ", data)        
-        if(data!=null && data.type == 'PUSH_TYPE_GLOBAL_EXCEPTION'){		  	          
-          this.$nextTick(()=> {			  
-              let datas = data.data.warnMap.warnData.records              
-              datas.forEach((data)=>{
-                  let msg = data.feedback ? data.feedback : " 响应超时 ";
-                  //let url = data.taskNodeId ? "#/dispatchMgr/exception":"#/developer/warnLong";
-                  let url = "#/developer/warnLong"
-                  let content = "<a href='"+url+"'>"+(data.resourceName? "["+ data.resourceName +"] " : "" )+(data.procedureName? data.procedureName : "")
-                   + (data.instructionName? "("+data.instructionName+")" : "") + msg+"</a>";  
-                  this.$notification.error(content, { messageIsHTML: true, timer:10, title:"异常警报", showCloseIcn:true});
-              })
-          });
-        }
-      }
-    },
-    // 组件销毁的时候,关闭websocket连接
-	  websocketClose() { 
-	      this.$store.getters.STAFF_UPDATE.lockReconnect = true
-	      this.$store.getters.STAFF_UPDATE.websock.close() // 离开路由之后断开websocket连接
-	      clearTimeout(this.$store.getters.STAFF_UPDATE.reconnectData) // 离开清除 timeout
-	      clearTimeout(this.$store.getters.STAFF_UPDATE.timeoutObj) // 离开清除 timeout
-	      clearTimeout(this.$store.getters.STAFF_UPDATE.serverTimeoutObj) // 离开清除 timeout
-	    },
-	  	// websocket信息变更
-	  onmessage() {
-	      this.$store.getters.STAFF_UPDATE.websock.onmessage = function(evt) {	       
-		     	console.log("websocket获取数据==="+evt)
-	      }
-	  }
+	    }
 	  }
 	}
 </script>

+ 2 - 1
imcs-ui/src/views/zuihou/dispatchMgr/tools/Index.vue

@@ -544,7 +544,8 @@
   			</el-form-item>
 	  </el-form>
 	</el-card>
-  </div>
+
+    </div>
 </template>
 
 <script>