|
@ -35,28 +35,7 @@ export default { |
|
|
}, |
|
|
}, |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
tableData: [], // 正在展示的警情数据 |
|
|
|
|
|
// receivedData: [], // 接收到的最新警情数据 |
|
|
|
|
|
// displayNum: 0, |
|
|
|
|
|
// lockReconnect: false, // 避免重复连接 |
|
|
|
|
|
// heartCheck: { |
|
|
|
|
|
// timeout: 3000, |
|
|
|
|
|
// timeoutobj: null, |
|
|
|
|
|
// // serverTimeoutObj: null, |
|
|
|
|
|
// start: () => { |
|
|
|
|
|
// // const that = this |
|
|
|
|
|
// clearTimeout(this.timeoutObj) |
|
|
|
|
|
// // clearTimeout(this.serverTimeoutObj) |
|
|
|
|
|
// this.timeoutobj = setTimeout(() => { |
|
|
|
|
|
// // 这里发送一个心跳,后端收到后,返回一个心跳,这里用的ping-pong |
|
|
|
|
|
// this.socket.send('ping') |
|
|
|
|
|
// // that.serverTimeoutObj = setTimeout(() => { |
|
|
|
|
|
// // this.socket.close() |
|
|
|
|
|
// // }, that.timeout) |
|
|
|
|
|
// }, this.timeout) |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
socket: null |
|
|
|
|
|
|
|
|
tableData: [] // 正在展示的警情数据 |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
watch: { |
|
|
watch: { |
|
@ -66,11 +45,6 @@ export default { |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
created() { |
|
|
created() { |
|
|
// securitydoor().then((data) => { |
|
|
|
|
|
// this.tableData.push(...data) |
|
|
|
|
|
// }) |
|
|
|
|
|
// this.openSocket() |
|
|
|
|
|
console.log(111111) |
|
|
|
|
|
alarmApi.info({ storeroomId: this.storeroomId }).then((data) => { |
|
|
alarmApi.info({ storeroomId: this.storeroomId }).then((data) => { |
|
|
if (data && data.length > 0) { |
|
|
if (data && data.length > 0) { |
|
|
this.tableData.push(...data) |
|
|
this.tableData.push(...data) |
|
@ -79,9 +53,6 @@ export default { |
|
|
}, |
|
|
}, |
|
|
destroyed() { |
|
|
destroyed() { |
|
|
clearInterval(this.timer) |
|
|
clearInterval(this.timer) |
|
|
if (this.socket) { |
|
|
|
|
|
this.socket.close() |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
// 表格隔行变色 |
|
|
// 表格隔行变色 |
|
@ -136,42 +107,6 @@ export default { |
|
|
}, 1000 * 3 * this.displayNum) |
|
|
}, 1000 * 3 * this.displayNum) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
// , |
|
|
|
|
|
// openSocket() { |
|
|
|
|
|
// if (!('WebSocket' in window)) { |
|
|
|
|
|
// console.log('您的浏览器不支持WebSocket') |
|
|
|
|
|
// } else { |
|
|
|
|
|
// console.log('您的浏览器支持WebSocket') |
|
|
|
|
|
// const socketUrl = process.env.VUE_APP_WS_API + '/webSocket' |
|
|
|
|
|
// if (this.socket != null) { |
|
|
|
|
|
// this.socket.close() |
|
|
|
|
|
// this.socket = null |
|
|
|
|
|
// } |
|
|
|
|
|
// this.socket = new WebSocket(socketUrl) |
|
|
|
|
|
// // 打开事件 |
|
|
|
|
|
// this.socket.onopen = () => { |
|
|
|
|
|
// console.log('websocket已经打开') |
|
|
|
|
|
// // 心跳检测重置 |
|
|
|
|
|
// // this.heartCheck.start() |
|
|
|
|
|
// } |
|
|
|
|
|
// // 获得消息 |
|
|
|
|
|
// this.socket.onmessage = (msg) => { |
|
|
|
|
|
// console.log(msg) |
|
|
|
|
|
// this.tableData.splice(0, this.tableData.length, ...JSON.parse(msg.data.slice(7, msg.data.length - 2)).Data) |
|
|
|
|
|
// // 对返回数据进行处理 |
|
|
|
|
|
// // this.heartCheck.start() |
|
|
|
|
|
// } |
|
|
|
|
|
// // 关闭事件 |
|
|
|
|
|
// this.socket.onclose = function() { |
|
|
|
|
|
// console.log('websocket已关闭') |
|
|
|
|
|
// } |
|
|
|
|
|
// // 发生了错误事件 |
|
|
|
|
|
// this.socket.onerror = function(e) { |
|
|
|
|
|
// console.log('websocket发生了错误') |
|
|
|
|
|
// console.log(e) |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
// } |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|