fix(设备管理): 调整设备列表切换时switch为null,不覆盖

This commit is contained in:
fhysy 2024-08-20 09:38:30 +08:00
parent a9395ad80b
commit 10f93ef6ff
2 changed files with 34 additions and 32 deletions

View File

@ -410,10 +410,13 @@ export default {
this.childDeviceList[i]["deviceId"] === this.childDeviceList[i]["deviceId"] ===
this.wsDeviceInfo["deviceId"] this.wsDeviceInfo["deviceId"]
) { ) {
this.childDeviceList[i]["switch"] = if(this.wsDeviceInfo?.switch !== null){
this.wsDeviceInfo?.switch !== null this.wsDeviceInfo.switch = this.wsDeviceInfo.switch.toString();
? this.wsDeviceInfo?.switch.toString() }
: this.wsDeviceInfo?.switch; // this.childDeviceList[i]["switch"] =
// this.wsDeviceInfo?.switch !== null
// ? this.wsDeviceInfo?.switch.toString()
// : this.wsDeviceInfo?.switch
// this.wsDeviceInfo?.switch; // this.wsDeviceInfo?.switch;
this.$forceUpdate(); this.$forceUpdate();
break; break;
@ -454,6 +457,7 @@ export default {
},${str}`; },${str}`;
}, },
wsMessage(e) { wsMessage(e) {
// debugger
if ( if (
e["deviceState"] || e["deviceState"] ||
(e["switch"] !== null && e["switch"] !== undefined) (e["switch"] !== null && e["switch"] !== undefined)

View File

@ -71,9 +71,9 @@ import { iotWebSocketBaseUrl } from "@/config/env";
import RunStateTable from "./table"; import RunStateTable from "./table";
export default { export default {
name: "RunStartsWrap", name: "RunStartsWrap",
props: ["prodId", "sourceId", "deviceInfo", 'wsUrl', 'realTimeData'], props: ["prodId", "sourceId", "deviceInfo", "wsUrl", "realTimeData"],
components: { components: {
RunStateTable, RunStateTable
}, },
data() { data() {
return { return {
@ -84,7 +84,7 @@ export default {
socket_flag: true, socket_flag: true,
dialogData: {}, dialogData: {},
dialogShow: false, dialogShow: false,
firstWsMassage: true, firstWsMassage: true
}; };
}, },
created() { created() {
@ -116,7 +116,7 @@ export default {
let headers = { let headers = {
clientid: this.deviceInfo.wsClientId, clientid: this.deviceInfo.wsClientId,
username: this.deviceInfo.wsUsername, username: this.deviceInfo.wsUsername,
sign: this.deviceInfo.wsSign, sign: this.deviceInfo.wsSign
}; };
this.stompClient = new WebSocket( this.stompClient = new WebSocket(
`${this.wsUrl}${headers.clientid}/${headers.username}/${headers.sign}` `${this.wsUrl}${headers.clientid}/${headers.username}/${headers.sign}`
@ -157,11 +157,8 @@ export default {
result.params[list[i].children[v]["funKey"]] !== null && result.params[list[i].children[v]["funKey"]] !== null &&
result.params[list[i].children[v]["funKey"]] !== undefined result.params[list[i].children[v]["funKey"]] !== undefined
) { ) {
(list[i].children[v]["lastValue"] = list[i].children[v]["lastValue"] = result.params[list[i].children[v]["funKey"]];
result.params[list[i].children[v]["funKey"]]), list[i].children[v]["lastTime"] = result.params["timestamp"] ? result.params["timestamp"] : "";
(list[i].children[v]["lastTime"] = result.params["timestamp"]
? result.params["timestamp"]
: "");
} }
} }
break; break;
@ -174,7 +171,7 @@ export default {
if (this.socket_flag) { if (this.socket_flag) {
this.socket_flag = false; this.socket_flag = false;
let self = this; let self = this;
setTimeout(function () { setTimeout(function() {
self.socket_flag = true; self.socket_flag = true;
self.connection(); self.connection();
}, 10000); }, 10000);
@ -185,9 +182,9 @@ export default {
cmdId: row.cmdId, cmdId: row.cmdId,
deviceId: this.deviceInfo.deviceId, deviceId: this.deviceInfo.deviceId,
cmdKey: row.cmdKey, cmdKey: row.cmdKey,
deviceKey: this.deviceInfo.deviceKey, deviceKey: this.deviceInfo.deviceKey
}; };
getDeviceFunList(param).then((res) => { getDeviceFunList(param).then(res => {
row["children"] = res.data || []; row["children"] = res.data || [];
this.$forceUpdate(); this.$forceUpdate();
}); });
@ -204,9 +201,10 @@ export default {
getCmdList() { getCmdList() {
const params = { const params = {
deviceId: this.deviceInfo.deviceId, deviceId: this.deviceInfo.deviceId,
cmdType: "1", cmdType: "1"
}; };
getDeviceCmdList(params).then((response) => { getDeviceCmdList(params).then(response => {
// debugger
this.cmdList = response.data; this.cmdList = response.data;
}); });
}, },
@ -217,7 +215,7 @@ export default {
this.socket_flag = false; this.socket_flag = false;
this.stompClient = null; this.stompClient = null;
clearTimeout(this.setTimeOut_flag); clearTimeout(this.setTimeOut_flag);
}, }
}, },
destroyed() { destroyed() {
this.closeWebscoket(); this.closeWebscoket();
@ -233,12 +231,12 @@ export default {
} }
}, },
realTimeData: { realTimeData: {
handler: function () { handler: function() {
this.setListData(this.realTimeData) this.setListData(this.realTimeData);
}, },
deep: true, deep: true
}
} }
},
}; };
</script> </script>
<style lang="scss"> <style lang="scss">
@ -348,7 +346,7 @@ export default {
border: 1px solid #b7b4b4; border: 1px solid #b7b4b4;
margin-left: -1px; margin-left: -1px;
margin-top: -1px; margin-top: -1px;
border-color:#e0e0e0; border-color: #e0e0e0;
.title-top { .title-top {
height: 30px; height: 30px;
display: flex; display: flex;