提交: 优化项目下 子设备 ws 更新数据问题

This commit is contained in:
23688nl 2022-10-12 18:17:34 +08:00
parent dda6806b0b
commit 8b2caa0333
3 changed files with 29 additions and 60 deletions

View File

@ -261,10 +261,10 @@ export default {
).then((res) => { ).then((res) => {
this.tableList = res.rows; this.tableList = res.rows;
this.deviceTotal = res.total; this.deviceTotal = res.total;
if (this.stompClient) { // if (this.stompClient) {
this.closeSocket(); // this.closeSocket();
} // }
this.connection(); // this.connection();
}); });
}, },
// //
@ -364,9 +364,9 @@ export default {
this.stompClient.onmessage = this.socket_message; this.stompClient.onmessage = this.socket_message;
this.stompClient.onclose = this.socket_onclose; this.stompClient.onclose = this.socket_onclose;
}, },
socket_message(evt) { socket_message(data) {
console.log("wsljcg:=", evt); console.log("wsljcg:=", data);
const data = JSON.parse(evt.data); // const data = JSON.parse(evt.data);
// this.actualEnergyCensus = data.params || {}; // this.actualEnergyCensus = data.params || {};
console.log("socket-message:", data); console.log("socket-message:", data);
this.handleDeviceInfo(data); this.handleDeviceInfo(data);

View File

@ -181,6 +181,7 @@
</div> </div>
<div v-if="showChildrenView"> <div v-if="showChildrenView">
<e-device-children <e-device-children
ref="eDeviceChildren"
:gatewayDevice="showGatewayInfo" :gatewayDevice="showGatewayInfo"
:sourceId="sourceId" :sourceId="sourceId"
:deviceType="deviceType" :deviceType="deviceType"
@ -227,59 +228,6 @@ export default {
}, },
showChildrenView: false, showChildrenView: false,
list: [], list: [],
mockerList: [
{
createTime: "2022-07-27 16:33:58",
deviceAddress: "福建省福州市闽侯县甘蔗街道闽侯榕新工艺有限公司",
deviceId: "821d1121a4bf426883a5266f12f8b758",
deviceKey: "ceshixinzeng",
deviceName: "ceshixinzeng",
deviceSecret: "bc6eafae957b43f682d6eaef56aac988",
deviceState: "UNACTIVE",
deviceStatus: "0",
deviceType: "GATEWAY_CONTROLLER",
deviceTypeName: "物联网网关",
modelId: "03e27dec4cb6464c809906fa41ddf7dc",
modelName: "网关-测试型号0513",
prodKey: "testpk220513",
updateTime: "2022-07-27 16:33:59",
parentId: "0",
},
{
createTime: "2022-07-27 16:33:58",
deviceAddress: "福建省福州市闽侯县甘蔗街道闽侯榕新工艺有限公司",
deviceId: "821d1121a4bf426883a5266f12f8b758",
deviceKey: "ceshixinzeng",
deviceName: "ceshixinzeng",
deviceSecret: "bc6eafae957b43f682d6eaef56aac988",
deviceState: "UNACTIVE",
deviceStatus: "1",
deviceType: "GATEWAY_CONTROLLER",
deviceTypeName: "物联网网关",
modelId: "03e27dec4cb6464c809906fa41ddf7dc",
modelName: "网关-测试型号0513",
prodKey: "testpk220513",
updateTime: "2022-07-27 16:33:59",
parentId: "0",
},
{
createTime: "2022-07-27 16:33:58",
deviceAddress: "福建省福州市闽侯县甘蔗街道闽侯榕新工艺有限公司",
deviceId: "821d1121a4bf426883a5266f12f8b758",
deviceKey: "ceshixinzeng",
deviceName: "ceshixinzeng",
deviceSecret: "bc6eafae957b43f682d6eaef56aac988",
deviceState: "ONLINE",
deviceStatus: "0",
deviceType: "GATEWAY_CONTROLLER",
deviceTypeName: "物联网网关",
modelId: "03e27dec4cb6464c809906fa41ddf7dc",
modelName: "网关-测试型号0513",
prodKey: "testpk220513",
updateTime: "2022-07-27 16:33:59",
parentId: "0",
},
],
showGatewayInfo: {}, showGatewayInfo: {},
projectModelList: [], projectModelList: [],
stompClient: null, stompClient: null,
@ -419,6 +367,7 @@ export default {
// socket // socket
handleDeviceInfo(param) { handleDeviceInfo(param) {
if (this.list && this.list.length > 0) { if (this.list && this.list.length > 0) {
// let result = this.list.filter(v => { if (v['deviceKey'] === param['deviceKey']) { return v }});
this.list = this.list.map((v) => { this.list = this.list.map((v) => {
if (v["deviceKey"] === param["deviceKey"]) { if (v["deviceKey"] === param["deviceKey"]) {
return Object.assign(v, param); return Object.assign(v, param);
@ -426,6 +375,7 @@ export default {
return v; return v;
} }
}); });
this.$refs.eDeviceChildren.socket_message(param);
} }
}, },
socket_onclose(e) { socket_onclose(e) {

View File

@ -21,6 +21,9 @@
<el-button plain size="mini" @click="handleAllStatus('false')" <el-button plain size="mini" @click="handleAllStatus('false')"
>一键分闸</el-button >一键分闸</el-button
> >
<el-button plain size="mini" @click="handleAllSelect()"
>{{ childDeviceList.length > tSelectList.length ? '全选' : '取消' }}</el-button
>
<span class="title-span">已选择设备</span> <span class="title-span">已选择设备</span>
<span v-if="tSelectLabelList.length <= 0">当前未选择设备</span> <span v-if="tSelectLabelList.length <= 0">当前未选择设备</span>
<el-tag <el-tag
@ -374,6 +377,22 @@ export default {
} }
}, },
handleAllSelect() {
if (this.childDeviceList.length > 0) {
if (this.tSelectList.length >= this.childDeviceList.length) {
this.tSelectList = [];
this.tSelectLabelList = [];
} else {
this.childDeviceList.forEach((v) => {
if (this.tSelectList.indexOf(v.deviceId) < 0) {
this.tSelectList.push(v.deviceId);
this.tSelectLabelList.push(v.deviceName);
}
});
}
}
},
// 线 // 线
handleChildStatus(type) { handleChildStatus(type) {
this.$prompt("请输入登录密码", "提示", { this.$prompt("请输入登录密码", "提示", {