From 10f93ef6ff0960d847e81e5e5b79e68daf4df304 Mon Sep 17 00:00:00 2001 From: fhysy <1149505133@qq.com> Date: Tue, 20 Aug 2024 09:38:30 +0800 Subject: [PATCH] =?UTF-8?q?=20fix(=E8=AE=BE=E5=A4=87=E7=AE=A1=E7=90=86):?= =?UTF-8?q?=20=E8=B0=83=E6=95=B4=E8=AE=BE=E5=A4=87=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E6=97=B6switch=E4=B8=BAnull=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E8=A6=86=E7=9B=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DeviceDetailsView/deviceSelectNav.vue | 12 +++-- src/views/profile/DeviceRunStarts/index.vue | 54 +++++++++---------- 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/src/views/profile/DeviceDetailsView/deviceSelectNav.vue b/src/views/profile/DeviceDetailsView/deviceSelectNav.vue index 96a5eaf2..8fa677f2 100644 --- a/src/views/profile/DeviceDetailsView/deviceSelectNav.vue +++ b/src/views/profile/DeviceDetailsView/deviceSelectNav.vue @@ -410,10 +410,13 @@ export default { this.childDeviceList[i]["deviceId"] === this.wsDeviceInfo["deviceId"] ) { - this.childDeviceList[i]["switch"] = - this.wsDeviceInfo?.switch !== null - ? this.wsDeviceInfo?.switch.toString() - : this.wsDeviceInfo?.switch; + if(this.wsDeviceInfo?.switch !== null){ + this.wsDeviceInfo.switch = this.wsDeviceInfo.switch.toString(); + } + // this.childDeviceList[i]["switch"] = + // this.wsDeviceInfo?.switch !== null + // ? this.wsDeviceInfo?.switch.toString() + // : this.wsDeviceInfo?.switch // this.wsDeviceInfo?.switch; this.$forceUpdate(); break; @@ -454,6 +457,7 @@ export default { },${str}`; }, wsMessage(e) { + // debugger if ( e["deviceState"] || (e["switch"] !== null && e["switch"] !== undefined) diff --git a/src/views/profile/DeviceRunStarts/index.vue b/src/views/profile/DeviceRunStarts/index.vue index 46c5fc98..9baaafa8 100644 --- a/src/views/profile/DeviceRunStarts/index.vue +++ b/src/views/profile/DeviceRunStarts/index.vue @@ -71,9 +71,9 @@ import { iotWebSocketBaseUrl } from "@/config/env"; import RunStateTable from "./table"; export default { name: "RunStartsWrap", - props: ["prodId", "sourceId", "deviceInfo", 'wsUrl', 'realTimeData'], + props: ["prodId", "sourceId", "deviceInfo", "wsUrl", "realTimeData"], components: { - RunStateTable, + RunStateTable }, data() { return { @@ -84,7 +84,7 @@ export default { socket_flag: true, dialogData: {}, dialogShow: false, - firstWsMassage: true, + firstWsMassage: true }; }, created() { @@ -116,7 +116,7 @@ export default { let headers = { clientid: this.deviceInfo.wsClientId, username: this.deviceInfo.wsUsername, - sign: this.deviceInfo.wsSign, + sign: this.deviceInfo.wsSign }; this.stompClient = new WebSocket( `${this.wsUrl}${headers.clientid}/${headers.username}/${headers.sign}` @@ -151,21 +151,18 @@ export default { // } // // } // } else { - if (result["cmd"] && list[i]["cmdKey"] === result["cmd"]) { - for (var v = 0; v < list[i].children.length; v++) { - if ( - result.params[list[i].children[v]["funKey"]] !== null && - result.params[list[i].children[v]["funKey"]] !== undefined - ) { - (list[i].children[v]["lastValue"] = - result.params[list[i].children[v]["funKey"]]), - (list[i].children[v]["lastTime"] = result.params["timestamp"] - ? result.params["timestamp"] - : ""); - } + if (result["cmd"] && list[i]["cmdKey"] === result["cmd"]) { + for (var v = 0; v < list[i].children.length; v++) { + if ( + result.params[list[i].children[v]["funKey"]] !== null && + result.params[list[i].children[v]["funKey"]] !== undefined + ) { + list[i].children[v]["lastValue"] = result.params[list[i].children[v]["funKey"]]; + list[i].children[v]["lastTime"] = result.params["timestamp"] ? result.params["timestamp"] : ""; } - break; } + break; + } // } } }, @@ -174,7 +171,7 @@ export default { if (this.socket_flag) { this.socket_flag = false; let self = this; - setTimeout(function () { + setTimeout(function() { self.socket_flag = true; self.connection(); }, 10000); @@ -185,9 +182,9 @@ export default { cmdId: row.cmdId, deviceId: this.deviceInfo.deviceId, cmdKey: row.cmdKey, - deviceKey: this.deviceInfo.deviceKey, + deviceKey: this.deviceInfo.deviceKey }; - getDeviceFunList(param).then((res) => { + getDeviceFunList(param).then(res => { row["children"] = res.data || []; this.$forceUpdate(); }); @@ -204,9 +201,10 @@ export default { getCmdList() { const params = { deviceId: this.deviceInfo.deviceId, - cmdType: "1", + cmdType: "1" }; - getDeviceCmdList(params).then((response) => { + getDeviceCmdList(params).then(response => { + // debugger this.cmdList = response.data; }); }, @@ -217,7 +215,7 @@ export default { this.socket_flag = false; this.stompClient = null; clearTimeout(this.setTimeOut_flag); - }, + } }, destroyed() { this.closeWebscoket(); @@ -233,12 +231,12 @@ export default { } }, realTimeData: { - handler: function () { - this.setListData(this.realTimeData) + handler: function() { + this.setListData(this.realTimeData); }, - deep: true, + deep: true } - }, + } };