提交: 优化项目下 子设备 ws 更新数据问题
This commit is contained in:
parent
dda6806b0b
commit
8b2caa0333
|
@ -261,10 +261,10 @@ export default {
|
|||
).then((res) => {
|
||||
this.tableList = res.rows;
|
||||
this.deviceTotal = res.total;
|
||||
if (this.stompClient) {
|
||||
this.closeSocket();
|
||||
}
|
||||
this.connection();
|
||||
// if (this.stompClient) {
|
||||
// this.closeSocket();
|
||||
// }
|
||||
// this.connection();
|
||||
});
|
||||
},
|
||||
// 动态表格 返回的 勾选数据
|
||||
|
@ -364,9 +364,9 @@ export default {
|
|||
this.stompClient.onmessage = this.socket_message;
|
||||
this.stompClient.onclose = this.socket_onclose;
|
||||
},
|
||||
socket_message(evt) {
|
||||
console.log("wsljcg:=", evt);
|
||||
const data = JSON.parse(evt.data);
|
||||
socket_message(data) {
|
||||
console.log("wsljcg:=", data);
|
||||
// const data = JSON.parse(evt.data);
|
||||
// this.actualEnergyCensus = data.params || {};
|
||||
console.log("socket-message:", data);
|
||||
this.handleDeviceInfo(data);
|
||||
|
|
|
@ -181,6 +181,7 @@
|
|||
</div>
|
||||
<div v-if="showChildrenView">
|
||||
<e-device-children
|
||||
ref="eDeviceChildren"
|
||||
:gatewayDevice="showGatewayInfo"
|
||||
:sourceId="sourceId"
|
||||
:deviceType="deviceType"
|
||||
|
@ -227,59 +228,6 @@ export default {
|
|||
},
|
||||
showChildrenView: false,
|
||||
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: {},
|
||||
projectModelList: [],
|
||||
stompClient: null,
|
||||
|
@ -419,6 +367,7 @@ export default {
|
|||
// 处理 socket 数据返回 赋值问题
|
||||
handleDeviceInfo(param) {
|
||||
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) => {
|
||||
if (v["deviceKey"] === param["deviceKey"]) {
|
||||
return Object.assign(v, param);
|
||||
|
@ -426,6 +375,7 @@ export default {
|
|||
return v;
|
||||
}
|
||||
});
|
||||
this.$refs.eDeviceChildren.socket_message(param);
|
||||
}
|
||||
},
|
||||
socket_onclose(e) {
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
<el-button plain size="mini" @click="handleAllStatus('false')"
|
||||
>一键分闸</el-button
|
||||
>
|
||||
<el-button plain size="mini" @click="handleAllSelect()"
|
||||
>{{ childDeviceList.length > tSelectList.length ? '全选' : '取消' }}</el-button
|
||||
>
|
||||
<span class="title-span">已选择设备:</span>
|
||||
<span v-if="tSelectLabelList.length <= 0">当前未选择设备</span>
|
||||
<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) {
|
||||
this.$prompt("请输入登录密码", "提示", {
|
||||
|
|
Loading…
Reference in New Issue