Procházet zdrojové kódy

前端websocket性能优化

oyq28 před 1 týdnem
rodič
revize
f6bb389145

+ 4 - 51
imcs-ui/src/layout/index.vue

@@ -54,64 +54,17 @@ export default {
         withoutAnimation: this.sidebar.withoutAnimation,
         mobile: this.device === 'mobile'
       }
-    },
-    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: {
     handleClickOutside() {
       this.$store.commit('setting/closeSidebar', { withoutAnimation: false })
-    },
-    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>

+ 52 - 3
imcs-ui/src/views/zuihou/developer/warnLong/Index.vue

@@ -261,10 +261,27 @@
 	    },
 	    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 () {
@@ -433,7 +450,39 @@
 	      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>

+ 1 - 1
imcs-ui/src/views/zuihou/developer/warnLong/components/View.vue

@@ -1,7 +1,7 @@
 <template>
   <el-dialog
     :title="$t(&quot;common.view&quot;)"
-    :width="width"
+    width="70%"
     :append-to-body="true"
     :visible.sync="isVisible"
     class="tenant-view"

+ 21 - 3
imcs-ui/src/views/zuihou/statisticalAnalysis/taskAnalysis/Index.vue

@@ -17,7 +17,22 @@
               :value="item.key"
             />
           </el-select>
-        </el-form-item>        
+        </el-form-item> 
+        <el-form-item label="操作类型">
+          <el-select
+            v-model="searchObj.funcType"
+            clearable
+            placeholder="请选择"
+            style="width: 100%"
+          >
+            <el-option
+              v-for="(item, index) in funcTypes"
+              :key="index"
+              :label="item.name"
+              :value="item.key"
+            />
+          </el-select>
+        </el-form-item>         
         <el-form-item label="生产时间">
           <el-date-picker
             v-model="searchObj.startDate"
@@ -255,10 +270,12 @@ export default {
       limit2: 10, // 每页记录数
       total2: 0, // 总记录数
       searchObj: {
-        taskType:''
+        taskType:'',
+        funcType:'',
       }, // 查询条件
       dialogVisible: false, //是否弹框
       taskType: [{id:"1",name:"上下料站",key:""},{id:"2",name:"上料用户",key:"1"}],
+      funcTypes: [{id:"",name:"默认",key:""},{id:"1",name:"上料",key:"1"},{id:"2",name:"下料",key:"2"}],
       resourceIds: [],
       row2: {},
       totalNum: 0
@@ -326,7 +343,8 @@ export default {
       this.row2 = row
       this.dialogVisible = true;
       const obj = {
-        resourceId: this.searchObj.taskType=="" ? row.resourceId : row.updateUser,        
+        resourceId: this.searchObj.taskType=="" ? row.resourceId : row.updateUser, 
+        funcType: this.searchObj.funcType,       
         taskType: this.searchObj.taskType,
         startDate: this.searchObj.startDate,        
         endDate: this.searchObj.endDate,