Browse Source

对接铜管追溯信息导出,及完善设备报警

zhifei 1 year ago
parent
commit
87ead028f3
4 changed files with 55 additions and 52 deletions
  1. 1 1
      .env.production
  2. 0 49
      src/App.vue
  3. 44 0
      src/views/index.vue
  4. 10 2
      src/views/trace/process/index.vue

+ 1 - 1
.env.production

@@ -5,4 +5,4 @@ VUE_APP_TITLE = 海亮工艺追溯系统
 ENV = 'production'
 
 # 海亮工艺追溯系统/生产环境
-VUE_APP_BASE_API = 'http://localhost:8080'
+VUE_APP_BASE_API = 'http://172.20.2.8/prod-api'

+ 0 - 49
src/App.vue

@@ -20,55 +20,6 @@ export default {
       websocket:null
     }
   },
-  created() {
-    setTimeout(() => {
-      this.initWebSocket()
-
-    }, 2000)
-  },
-  methods: {
-    initWebSocket() {
-      let name = this.$store.state.user.name
-      let url = process.env.VUE_APP_BASE_API.replace("https://", "wss://").replace("http://", "ws://") + "/websocket/device/" + name;
-      this.websocket = new WebSocket(url);
-      this.websocket.addEventListener('beforeSend', function (event) {
-        event.target.setRequestHeader('Authorization', 'Bearer ' + this.$store.state.user.token);
-      });
-      this.websocket.onopen = this.websocketonopen;
-      this.websocket.onerror = this.websocketonerror;
-      this.websocket.onmessage = this.websocketonmessage;
-      this.websocket.onclose = this.websocketclose;
-    },
-    // 连接成功后调用
-    websocketonopen: function () {
-      console.log("WebSocket连接成功");
-    },
-    // 发生错误时调用
-    websocketonerror: function (e) {
-      console.log("WebSocket连接发生错误");
-    },
-    websocketonmessage: function (e) {
-      const  notify =  JSON.parse(e.data)
-      console.log(e.data)
-      if (notify.status=="1"){
-        this.$notify.info({
-          title: notify.deviceId,
-          message: notify.content,
-          showClose: false
-        });
-      }else {
-        this.$notify.error({
-          title:  notify.deviceId,
-          message: notify.content,
-          duration: 0
-        });
-      }
-    },
-    // 关闭连接时调用
-    websocketclose: function (e) {
-      console.log("connection closed (" + e.code + ")");
-    }
-  }
 };
 </script>
 <style scoped>

+ 44 - 0
src/views/index.vue

@@ -11,6 +11,50 @@ export default {
     };
   },
   methods: {
+    initWebSocket() {
+      let name = this.$store.state.user.name
+      let url = process.env.VUE_APP_BASE_API.replace("https://", "wss://").replace("http://", "ws://") + "/websocket/device/" + name;
+      this.websocket = new WebSocket(url);
+      this.websocket.addEventListener('beforeSend', function (event) {
+        event.target.setRequestHeader('Authorization', 'Bearer ' + this.$store.state.user.token);
+      });
+      this.websocket.onopen = this.websocketonopen;
+      this.websocket.onerror = this.websocketonerror;
+      this.websocket.onmessage = this.websocketonmessage;
+      this.websocket.onclose = this.websocketclose;
+    },
+    // 连接成功后调用
+    websocketonopen: function () {
+      console.log("WebSocket连接成功");
+    },
+    // 发生错误时调用
+    websocketonerror: function (e) {
+      console.log("WebSocket连接发生错误");
+    },
+    websocketonmessage: function (e) {
+      const  notify =  JSON.parse(e.data)
+      console.log(e.data)
+      if (notify.status=="1"){
+        this.$notify.info({
+          title: notify.deviceId,
+          message: notify.content,
+          showClose: false
+        });
+      }else {
+        this.$notify.error({
+          title:  notify.deviceId,
+          message: notify.content,
+          duration: 0
+        });
+      }
+    },
+    // 关闭连接时调用
+    websocketclose: function (e) {
+      console.log("connection closed (" + e.code + ")");
+    }
+  },
+  created() {
+    this.initWebSocket()
   }
 };
 </script>

+ 10 - 2
src/views/trace/process/index.vue

@@ -182,12 +182,20 @@ export default{
     },
     // 多选框选中数据
     handleSelectionChange(selection) {
-      this.ids = selection.map(item => item.roleId)
+      this.ids = selection.map(item => item.historyId)
       this.single = selection.length!=1
       this.multiple = !selection.length
     },
     handleExport(){
-
+      if (this.ids.length>0){
+        this.download('retroactive/history/exportByIds', {
+          ids:this.ids.join(",")
+        }, `铜管追溯_${new Date().getTime()}.xlsx`)
+      }else {
+        this.download('retroactive/history/export', {
+          ...this.queryParams
+        }, `铜管追溯_${new Date().getTime()}.xlsx`)
+      }
     }
   }
 }