diff --git a/src/views/emergen_cyrescue/emergency_map/components/mapAssembly.vue b/src/views/emergen_cyrescue/emergency_map/components/mapAssembly.vue index 9111959..b3e526b 100644 --- a/src/views/emergen_cyrescue/emergency_map/components/mapAssembly.vue +++ b/src/views/emergen_cyrescue/emergency_map/components/mapAssembly.vue @@ -272,8 +272,11 @@ export default { // 当前点击后选择的二级坐标点位分类集合 currSubControlPoint: [], subControlPointIndex: 0, - webSocket: {}, - REPORT_ID: '1' + webSocket: null, + heartbeat: null, + REPORT_ID: null, + FIRERESERVEPLAN_ID: null, + CORPIFNO_ID: sessionStorage.getItem('user').CORPIFNO_ID } }, mounted() { @@ -285,10 +288,22 @@ export default { this.currSubControlPoint = this.subControlPoint['0'] }, created() { + console.log(this.$route.query) this.REPORT_ID = this.$route.query.REPORT_ID + this.FIRERESERVEPLAN_ID = this.$route.query.FIRERESERVEPLAN_ID this.initInfo() this.initWebsocket() }, + beforeDestroy() { + if (this.webSocket) { + console.log('关闭websocket') + this.webSocket.close() + } + if (this.heartbeat) { + console.log('清除定时器') + clearInterval(this.heartbeat) + } + }, methods: { /** 地图初始化 */ mapInit() { @@ -297,7 +312,6 @@ export default { mapInstance.enableScrollWheelZoom(true) // 开启鼠标滚轮缩放能力 }, setActive(item, index) { - console.log('item :>> ', item) // 设置被选中项的索引 this.activeIndex = index }, @@ -417,8 +431,6 @@ export default { item.check = false } }) - console.log('item :>> ', item) - console.log('index :>> ', index) this.currSubControlPoint = this.subControlPoint[index] }, // 二级坐标点位点击事件 @@ -430,7 +442,6 @@ export default { item.check = false } }) - console.log('sos :>> ', sos) }, // 接收子组件传递出来的指令发送的事件 handlerOrderMessage() { @@ -446,12 +457,11 @@ export default { requestFN( '/bi/emergency/getYjBiInformation', { - FIRERESERVEPLAN_ID: '1458bd17152c44e1aa733408d3b84b98', - REPORT_ID: '4a225c74482140c0a4838704304cfb47', - CORP_ID: '13cf0f4ec77e4d98ae8cdd9c3386ae0c' + FIRERESERVEPLAN_ID: this.FIRERESERVEPLAN_ID, + REPORT_ID: this.REPORT_ID, + CORP_ID: this.CORPIFNO_ID } ).then((data) => { - console.log(data) if (data.result === 'success') { // 值班列表 this.info.dutyInfoData = data.dutyList @@ -459,7 +469,6 @@ export default { this.info.reservePlan = data.planInfo this.info.addressBook = data.addressBookList this.chatData = data.instructList - console.log(data.instructList) } loading.close() }).catch((e) => { @@ -472,16 +481,30 @@ export default { this.webSocket = new WebSocket(encodeURI(wsUrl)) this.webSocket.onopen = () => { console.info('指挥调度的webSocket链接成功') + this.webSocket.send('链接成功') } - this.webSocket.onerror = function() { - console.info('指挥调度的webSocket连接失败') - this.$message.error('消息链接失败!') + this.webSocket.onerror = () => { + this.$router.back() + } + this.webSocket.onclose = () => { + this.$router.push('/emergen_cyrescue/incident_management') } var _this = this this.webSocket.onmessage = function(message) { console.log(message) _this.initInfo() } + // 新建心跳,持续监听链接是否存活 + this.heartbeat = setInterval(() => { + console.log('发送心跳') + try { + if (this.webSocket) { + this.webSocket.send('心跳') + } + } catch (e) { + console.log('链接已断开') + } + }, 3000) } } } diff --git a/src/views/emergen_cyrescue/emergency_report/incident_report/components/list.vue b/src/views/emergen_cyrescue/emergency_report/incident_report/components/list.vue index 6cfba0f..e2d56df 100644 --- a/src/views/emergen_cyrescue/emergency_report/incident_report/components/list.vue +++ b/src/views/emergen_cyrescue/emergency_report/incident_report/components/list.vue @@ -41,7 +41,7 @@