修复新增设备报错

This commit is contained in:
kerwincui
2022-08-06 00:30:36 +08:00
parent fb51c2a205
commit 1947a67827
2 changed files with 11 additions and 3 deletions

View File

@@ -444,7 +444,8 @@ export default {
} else { } else {
addDevice(this.form).then(response => { addDevice(this.form).then(response => {
this.form = response.data; this.form = response.data;
this.oldDeviceStatus = this.from.status; console.log(response);
this.oldDeviceStatus = this.form.status;
if (this.form.deviceId == null || this.form.deviceId == 0) { if (this.form.deviceId == null || this.form.deviceId == 0) {
this.$modal.alertError("设备编号已经存在,添加设备失败"); this.$modal.alertError("设备编号已经存在,添加设备失败");
} else { } else {

View File

@@ -217,6 +217,7 @@ export default {
this.MonitorChart(); this.MonitorChart();
}); });
}); });
this.connectMqtt();
} }
} }
}, },
@@ -259,10 +260,16 @@ export default {
} }
}, },
created() { created() {
// 回调处理
this.mqttCallback();
}, },
methods: { methods: {
/* 连接Mqtt消息服务器 */
async connectMqtt() {
if (this.$mqttTool.client == null) {
await this.$mqttTool.connect(this.vuex_token);
}
this.mqttCallback();
},
/* Mqtt回调处理 */ /* Mqtt回调处理 */
mqttCallback() { mqttCallback() {
this.$mqttTool.client.on('message', (topic, message, buffer) => { this.$mqttTool.client.on('message', (topic, message, buffer) => {