|
@ -16,6 +16,7 @@ |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
<script> |
|
|
<script> |
|
|
|
|
|
import alarmApi from '@/api/home/alarm' |
|
|
export default { |
|
|
export default { |
|
|
name: 'WarehouseWarning', |
|
|
name: 'WarehouseWarning', |
|
|
props: { |
|
|
props: { |
|
@ -26,6 +27,10 @@ export default { |
|
|
height: { |
|
|
height: { |
|
|
type: String, |
|
|
type: String, |
|
|
default: '100%' |
|
|
default: '100%' |
|
|
|
|
|
}, |
|
|
|
|
|
storeroomId: { |
|
|
|
|
|
type: String, |
|
|
|
|
|
default: '' |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
data() { |
|
|
data() { |
|
@ -61,7 +66,13 @@ export default { |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
created() { |
|
|
created() { |
|
|
this.openSocket() |
|
|
|
|
|
|
|
|
// securitydoor().then((data) => { |
|
|
|
|
|
// this.tableData.push(...data) |
|
|
|
|
|
// }) |
|
|
|
|
|
// this.openSocket() |
|
|
|
|
|
alarmApi.info({ storeroomId: this.storeroomId }).then((data) => { |
|
|
|
|
|
this.tableData.push(...data) |
|
|
|
|
|
}) |
|
|
}, |
|
|
}, |
|
|
destroyed() { |
|
|
destroyed() { |
|
|
clearInterval(this.timer) |
|
|
clearInterval(this.timer) |
|
@ -121,42 +132,43 @@ 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) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
// , |
|
|
|
|
|
// 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> |
|
|