From e37080a7193acec7ed9b25c5fb3ae2e23066b159 Mon Sep 17 00:00:00 2001 From: liangbin <15536829364@163.com> Date: Wed, 31 Dec 2025 17:38:48 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=94=B5=E4=BC=B4=E7=83=AD):=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E7=94=B5=E4=BC=B4=E7=83=AD=E8=AE=BE=E5=A4=87=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E8=8E=B7=E5=8F=96=E5=92=8C=E6=8E=A7=E5=88=B6=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 重构电伴热设备相关功能,从获取设备列表改为获取单个设备状态 调整前端控制界面,添加发送按钮并简化状态显示 增加设备异常状态检查,防止异常设备被操作 --- src/api/index.js | 6 +++--- src/views/view/index.vue | 38 ++++++++++++++++++++++---------------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index 1957e31..bc021e0 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -341,10 +341,10 @@ export function addBroadcast(data) { }); } -// 获取电伴热设备列表 -export function getDbrIotDeviceList() { +// 获取电伴热设备状态列表 +export function getDbrIotDeviceList(dev_id) { return request({ - url: `/TestApi/devices`, + url: `/TestApi/device/${dev_id}`, method: "get", }); } diff --git a/src/views/view/index.vue b/src/views/view/index.vue index d2db594..dafd528 100644 --- a/src/views/view/index.vue +++ b/src/views/view/index.vue @@ -1007,17 +1007,19 @@ background: #2b6bb6; margin: 7px 5px 0 0; ">设备控制 - + + 发送 +

- - 电伴热设备{{ index + 1 }}: - - +
+ + 电伴热设备: + + - 设备异常 +
@@ -1723,7 +1725,7 @@ export default { data() { return { // 电伴热设备列表 - iotDBRLis: [], + iotDBRInfo: {}, nowTime: '', searchForm: { area: '2', @@ -1955,11 +1957,15 @@ export default { }, methods: { // 改变电伴热设备状态 - async ChangeDBRdevocte(item) { - console.log(item.online, '开关状态'); + async ChangeDBRdevocte() { + if (this.iotDBRInfo.status == '异常' || !this.iotDBRInfo.device_id) { + this.$message.warning('设备异常,不能操作') + return + } + console.log(this.iotDBRInfo.online, '开关状态'); let res = await changeDbrIotDeviceStatus({ - device_id: item.device_id, - action: item.online ? 'open' : 'close', + device_id: this.iotDBRInfo.device_id, + action: this.iotDBRInfo.online ? 'open' : 'close', }) if (res?.data?.message) { this.$message.success(res.data.message) @@ -3469,12 +3475,12 @@ export default { that.$set(that.dataForm, 'iotKeys', []) console.log("电伴热", that.dataForm) // 获取电伴热设备状态 - let res = await getDbrIotDeviceList(that.dataForm.deviceId) + let dev_id = that.dataForm.iotKey.split(':')[1] + let res = await getDbrIotDeviceList(dev_id) console.log("电伴热2", res) if (res?.status == 200) { - let all_data = Object.values(res.data); - console.log("电伴热3", all_data) - this.iotDBRLis = all_data + console.log("电伴热3", res.data) + this.iotDBRInfo = res.data } }