#
Junjie
3 天以前 08cd84454ec525569c606e81a643fa8dc5759a35
src/main/webapp/views/watch/console.html
@@ -82,12 +82,20 @@
               rgvParam: {
                  rgvNo: 0
               },
               locMastData: []//库位数据
               locMastData: [],//库位数据
               wsReconnectTimer: null,
               wsReconnectAttempts: 0,
               wsReconnectBaseDelay: 1000,
               wsReconnectMaxDelay: 15000
            },
            created() {
               this.init()
            },
            mounted() {
            },
            beforeDestroy() {
               if (this.wsReconnectTimer) { clearTimeout(this.wsReconnectTimer); this.wsReconnectTimer = null; }
               if (ws && (ws.readyState === WebSocket.OPEN || ws.readyState === WebSocket.CONNECTING)) { try { ws.close(); } catch (e) {} }
            },
            watch: {
@@ -100,12 +108,17 @@
                    },
                    webSocketOnOpen() {
                        console.log("WebSocket连接成功");
                        if (this.wsReconnectTimer) { clearTimeout(this.wsReconnectTimer); this.wsReconnectTimer = null; }
                        this.wsReconnectAttempts = 0;
                        this.getMap();
                    },
                    webSocketOnError() {
                        console.log("WebSocket连接发生错误");
                        this.scheduleWsReconnect();
                    },
                    webSocketClose() {
                        console.log("WebSocket连接关闭");
                        this.scheduleWsReconnect();
                    },
                    webSocketOnMessage(e) {
                        const result = JSON.parse(e.data);
@@ -140,15 +153,30 @@
                        }))
                    },
               init() {
                  this.connectWs();
                  this.getSystemRunningStatus() //获取系统运行状态
                  this.getLevList() //获取地图层级列表
                  this.getLocMastData() //获取库位数据
               },
               connectWs() {
                  if (ws && (ws.readyState === WebSocket.OPEN || ws.readyState === WebSocket.CONNECTING)) { return; }
                  ws = new WebSocket("ws://" + window.location.host + baseUrl + "/console/websocket");
                  ws.onopen = this.webSocketOnOpen;
                  ws.onerror = this.webSocketOnError;
                  ws.onmessage = this.webSocketOnMessage;
                  ws.onclose = this.webSocketClose;
                  this.getSystemRunningStatus() //获取系统运行状态
                  this.getLevList() //获取地图层级列表
                  this.getLocMastData() //获取库位数据
               },
               scheduleWsReconnect() {
                  if (this.wsReconnectTimer) { return; }
                  const attempt = this.wsReconnectAttempts + 1;
                  const jitter = Math.floor(Math.random() * 300);
                  const delay = Math.min(this.wsReconnectMaxDelay, this.wsReconnectBaseDelay * Math.pow(2, this.wsReconnectAttempts)) + jitter;
                  this.wsReconnectTimer = setTimeout(() => {
                     this.wsReconnectTimer = null;
                     this.wsReconnectAttempts = attempt;
                     this.connectWs();
                  }, delay);
               },
               getLevList() {
                  let that = this;