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 } }