Commit 00e0e9bd authored by 耿迪迪's avatar 耿迪迪

出入库websocket前台调整

parent 1fe1e635
......@@ -87,6 +87,7 @@
shelfId: null,
},
ws: null,
heartbeatInterval: null
}
},
created(){
......@@ -240,19 +241,26 @@
this.ws = new WebSocket('ws://' + window.location.host + process.env.VUE_APP_BASE_API + '/ws/notifications');
this.ws.onopen = () => {
console.log('WebSocket Connected');
// 连接建立后,开始定期发送心跳
this.heartbeatInterval = setInterval(() => {
if (this.ws.readyState === WebSocket.OPEN) {
this.ws.send(JSON.stringify({ type: 'ping' }));
console.log("发送心跳")
}
}, 30000);
};
this.ws.onmessage = (event) => {
// Add received message to the list
const message = JSON.parse(event.data);
if(message && message.SHELFID && message.SHELFID == this.$route.query.shelfId){
if(message && message.shelfId && message.shelfId == this.$route.query.shelfId){
//入库
if("I" == message.OPTYPE){
const locationInfo = this.shelfLayoutList.flat().find(location => location.location === message.LOCATION);
locationInfo.rid = message.RID;
if("I" == message.optype){
const locationInfo = this.shelfLayoutList.flat().find(location => location.location === message.location);
locationInfo.rid = message.rid;
}
//出库
if("O" == message.OPTYPE){
const locationInfo = this.shelfLayoutList.flat().find(location => location.location === message.LOCATION);
if("O" == message.optype){
const locationInfo = this.shelfLayoutList.flat().find(location => location.location === message.location);
locationInfo.rid = null;
}
}
......@@ -262,6 +270,7 @@
};
this.ws.onclose = () => {
console.log('WebSocket Closed');
clearInterval(this.heartbeatInterval);
};
},
disconnect() {
......
......@@ -87,6 +87,7 @@
shelfId: null,
},
ws: null,
heartbeatInterval: null
}
},
created(){
......@@ -240,19 +241,26 @@
this.ws = new WebSocket('ws://' + window.location.host + process.env.VUE_APP_BASE_API + '/ws/notifications');
this.ws.onopen = () => {
console.log('WebSocket Connected');
// 连接建立后,开始定期发送心跳
this.heartbeatInterval = setInterval(() => {
if (this.ws.readyState === WebSocket.OPEN) {
this.ws.send(JSON.stringify({ type: 'ping' }));
console.log("发送心跳")
}
}, 30000);
};
this.ws.onmessage = (event) => {
// Add received message to the list
const message = JSON.parse(event.data);
if(message && message.SHELFID && message.SHELFID == this.$route.query.shelfId){
if(message && message.shelfId && message.shelfId == this.$route.query.shelfId){
//入库
if("I" == message.OPTYPE){
const locationInfo = this.shelfLayoutList.flat().find(location => location.location === message.LOCATION);
locationInfo.rid = message.RID;
if("I" == message.optype){
const locationInfo = this.shelfLayoutList.flat().find(location => location.location === message.location);
locationInfo.rid = message.rid;
}
//出库
if("O" == message.OPTYPE){
const locationInfo = this.shelfLayoutList.flat().find(location => location.location === message.LOCATION);
if("O" == message.optype){
const locationInfo = this.shelfLayoutList.flat().find(location => location.location === message.location);
locationInfo.rid = null;
}
}
......@@ -262,6 +270,7 @@
};
this.ws.onclose = () => {
console.log('WebSocket Closed');
clearInterval(this.heartbeatInterval);
};
},
disconnect() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment