设备控制

master
lld 2026-02-01 15:32:23 +08:00
parent 65281bbce2
commit 2a34df477f
1 changed files with 8 additions and 10 deletions

View File

@ -251,7 +251,6 @@ export default {
jm3kLimit: 0, jm3kLimit: 0,
jm3gLimit: 0 jm3gLimit: 0
}, },
deviceType: '',
status: { status: {
jbk: 0, jbk: 0,
jbg: 0, jbg: 0,
@ -417,7 +416,6 @@ export default {
// //
this.publishMessage(); this.publishMessage();
// //
this.deviceType = type;
//todo //todo
// this.testAuto(type); // this.testAuto(type);
@ -479,7 +477,6 @@ export default {
jm3kLimit: 0, jm3kLimit: 0,
jm3gLimit: 0 jm3gLimit: 0
}; };
this.deviceType = '';
this.control = '正在加载中...'; this.control = '正在加载中...';
this.message = {}; this.message = {};
this.temp = ''; this.temp = '';
@ -531,8 +528,6 @@ export default {
this.message = JSON.stringify({[`${type}1`]: status}) this.message = JSON.stringify({[`${type}1`]: status})
// //
this.publishMessage(); this.publishMessage();
//
this.deviceType = type;
//todo //todo
// this.testAuto(type); // this.testAuto(type);
@ -580,7 +575,7 @@ export default {
// 3. // 3.
if (msgData.prop && "suc" in msgData) { if (msgData.prop && "suc" in msgData) {
this.handleCommandAck(msgData, this.deviceType); this.handleCommandAck(msgData);
} else if ("msg" in msgData && "clientId" in msgData) { } else if ("msg" in msgData && "clientId" in msgData) {
if (mqttUtil.getMqttState().clientId === msgData.clientId) { if (mqttUtil.getMqttState().clientId === msgData.clientId) {
this.$modal.msg( this.$modal.msg(
@ -597,21 +592,24 @@ export default {
}, },
// + // +
handleCommandAck(ackData, type) { handleCommandAck(ackData) {
// jm2ksuc // jm2ksuc
const commandField = Object.keys(ackData.prop)[0]; // "jm2k" const commandField = Object.keys(ackData.prop)[0]; // "jm2k"
const commandValue = ackData.prop[commandField]; // 0/1 const commandValue = ackData.prop[commandField]; // 0/1
const isSuccess = ackData.suc; // true const isSuccess = ackData.suc; // true
const type = commandField.substring(0,commandField.length -1);
if (isSuccess) { if (isSuccess) {
// 使$set // 使$set
this.$set(this.status, type, this.status[type] === 0 ? 1 : 0); this.$set(this.status, type, commandValue);
this.$set(this.show, type, this.status[type] === 0 ? "暂停" : "运行"); this.$set(this.show, type, commandValue === 0 ? "暂停" : "运行");
console.info(`收到回执,更新功能码成功:{"${type}":${commandValue}}`)
} }
this.deviceType = '';
// ========== ========== // ========== ==========
if (ackData.clientId && (ackData.clientId===mqttUtil.getMqttState().clientId)) { if (ackData.clientId && (ackData.clientId===mqttUtil.getMqttState().clientId)) {
console.info("用户提示成功!")
this.$modal[isSuccess ? 'msgSuccess' : 'msgError']( this.$modal[isSuccess ? 'msgSuccess' : 'msgError'](
`设备操作${isSuccess ? "成功" : "失败"}` `设备操作${isSuccess ? "成功" : "失败"}`
); );