批量报警,获取设备实时状态
This commit is contained in:
@ -309,6 +309,7 @@
|
||||
lightModeB: false,
|
||||
lightModeC: false, //激光提示框
|
||||
items: [],
|
||||
pendingMainMode: null, // 选中的索引
|
||||
isFormExpanded: true, // 默认展开
|
||||
deviceID: '',
|
||||
itemInfo: {},
|
||||
@ -553,21 +554,38 @@
|
||||
toggleForm() {
|
||||
this.isFormExpanded = !this.isFormExpanded;
|
||||
},
|
||||
// onItemClick(index) {
|
||||
// const selectedItem = this.items[index];
|
||||
// if (selectedItem.text === '激光') {
|
||||
// this.lightModeC = true;
|
||||
// } else {
|
||||
// // 更新选中状态
|
||||
// this.items = this.items.map((item, i) => ({
|
||||
// ...item,
|
||||
// selected: i === index
|
||||
// }));
|
||||
// this.currentMainMode = selectedItem.text;
|
||||
// this.selectedItemIndex = index;
|
||||
// // 强制更新视图(如果需要)
|
||||
// this.$forceUpdate();
|
||||
// }
|
||||
// },
|
||||
onItemClick(index) {
|
||||
const selectedItem = this.items[index];
|
||||
if (selectedItem.text === '激光') {
|
||||
const item = this.items[index];
|
||||
// 激光模式特殊处理
|
||||
if (item.text === '激光') {
|
||||
this.lightModeC = true;
|
||||
} else {
|
||||
// 更新选中状态
|
||||
this.items = this.items.map((item, i) => ({
|
||||
...item,
|
||||
selected: i === index
|
||||
}));
|
||||
this.currentMainMode = selectedItem.text;
|
||||
this.selectedItemIndex = index;
|
||||
// 强制更新视图(如果需要)
|
||||
this.$forceUpdate();
|
||||
return;
|
||||
}
|
||||
// 只更新临时选中状态
|
||||
this.selectedItemIndex = index;
|
||||
// UI高亮效果(不影响实际模式)
|
||||
this.items = this.items.map((item, i) => ({
|
||||
...item,
|
||||
selected: i === index
|
||||
}));
|
||||
// 显示临时选中的模式名称(视觉反馈)
|
||||
this.pendingMainMode = item.text;
|
||||
},
|
||||
// 灯光模式的确认
|
||||
handleSumbit() {
|
||||
@ -589,7 +607,6 @@
|
||||
this.isProcessing = true
|
||||
if (this.selectedItemIndex === null) return;
|
||||
const selectedItem = this.items[this.selectedItemIndex];
|
||||
// 准备请求数据
|
||||
let data = {
|
||||
deviceId: this.computedDeviceId,
|
||||
instructValue: selectedItem.instructValue,
|
||||
@ -598,6 +615,9 @@
|
||||
};
|
||||
lightModeSettings(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
// 只有确认成功才更新实际模式,选中模式
|
||||
this.currentMainMode = this.pendingMainMode;
|
||||
this.selectedItemIndex = selectedItem;
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
@ -914,20 +934,29 @@
|
||||
};
|
||||
// 3.解除告警状态
|
||||
const registerRes = await deviceSendAlarmMessage(data);
|
||||
if (registerRes.code == 200) {
|
||||
if (registerRes.code !== 200) {
|
||||
uni.showToast({
|
||||
title: registerRes.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
// 4. 获取设备状态
|
||||
const statusRes = await this.getdeviceSTatus(2, batchId);
|
||||
if (statusRes.data.functionAccess === 'OK') {
|
||||
uni.showToast({
|
||||
title: statusRes.msg,
|
||||
icon: 'none'
|
||||
});
|
||||
// 刷新详情接口
|
||||
this.fetchDeviceDetail(this.computedDeviceId, true);
|
||||
uni.$emit('deviceStatusUpdate', {});
|
||||
this.showPopupFlag = false
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: registerRes.message,
|
||||
icon: 'none'
|
||||
});
|
||||
if (this.apiType === 'listA') {
|
||||
this.fetchDeviceDetail(this.computedDeviceId)
|
||||
} else {
|
||||
// 分享权限详情
|
||||
this.fetchSharedDeviceDetail(this.itemInfo.id)
|
||||
}
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
uni.showToast({
|
||||
@ -1091,6 +1120,7 @@
|
||||
title: error.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
uni.hideLoading()
|
||||
}
|
||||
},
|
||||
// 操作说明
|
||||
@ -1187,15 +1217,18 @@
|
||||
this.deviceInfo.batteryRemainingTime = deviceState[5];
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.fetchDeviceDetail(data.data.id, true).then(
|
||||
() => {
|
||||
if (this.deviceInfo.batteryPercentage <
|
||||
20) {
|
||||
this.popupType = 'bettery';
|
||||
this.popupMessage = '请及时充电';
|
||||
this.showPopupFlag = true;
|
||||
}
|
||||
});
|
||||
if (this.deviceInfo.batteryPercentage <
|
||||
20) {
|
||||
this.popupType = 'bettery';
|
||||
this.popupMessage = '请及时充电';
|
||||
this.showPopupFlag = true;
|
||||
}
|
||||
if (this.apiType === 'listA') {
|
||||
this.fetchDeviceDetail(data.data.id)
|
||||
} else {
|
||||
// 分享权限详情
|
||||
this.fetchSharedDeviceDetail(data.data.id)
|
||||
}
|
||||
}, 10000);
|
||||
// 上报电量,在列表里面同步
|
||||
uni.$emit('deviceStatusUpdate', {
|
||||
|
Reference in New Issue
Block a user