feat(电伴热): 修改电伴热设备状态获取和控制逻辑
重构电伴热设备相关功能,从获取设备列表改为获取单个设备状态 调整前端控制界面,添加发送按钮并简化状态显示 增加设备异常状态检查,防止异常设备被操作
This commit is contained in:
parent
db08b3b81d
commit
e37080a719
|
|
@ -341,10 +341,10 @@ export function addBroadcast(data) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取电伴热设备列表
|
// 获取电伴热设备状态列表
|
||||||
export function getDbrIotDeviceList() {
|
export function getDbrIotDeviceList(dev_id) {
|
||||||
return request({
|
return request({
|
||||||
url: `/TestApi/devices`,
|
url: `/TestApi/device/${dev_id}`,
|
||||||
method: "get",
|
method: "get",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1007,17 +1007,19 @@
|
||||||
background: #2b6bb6;
|
background: #2b6bb6;
|
||||||
margin: 7px 5px 0 0;
|
margin: 7px 5px 0 0;
|
||||||
"></span>设备控制
|
"></span>设备控制
|
||||||
|
<el-button type="primary" style="float: right; margin-right: 20px" size="mini" @click="ChangeDBRdevocte()">
|
||||||
|
发送
|
||||||
|
</el-button>
|
||||||
</p>
|
</p>
|
||||||
<div style="padding-left: 20px">
|
<div style="padding-left: 20px">
|
||||||
<el-row v-for="(item, index) in iotDBRLis" :key="index" style="margin-bottom: 10px;">
|
<div v-if="iotDBRInfo.status !== '异常'"></div>
|
||||||
<el-col :span="4">电伴热设备{{ index + 1 }}:</el-col>
|
<el-row style="margin-bottom: 10px;">
|
||||||
<el-col :span="8" v-if="item.status !== '异常'">
|
<el-col :span="4">电伴热设备:</el-col>
|
||||||
<el-switch v-model="item.online" active-color="#20488F" active-text="开" inactive-text="关"
|
<el-col :span="8" >
|
||||||
size="mini" @change="ChangeDBRdevocte(item)">
|
<el-switch v-model="iotDBRInfo.online" active-color="#20488F" active-text="开" inactive-text="关">
|
||||||
</el-switch>
|
</el-switch>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8" v-else>设备异常</el-col>
|
|
||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -1723,7 +1725,7 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 电伴热设备列表
|
// 电伴热设备列表
|
||||||
iotDBRLis: [],
|
iotDBRInfo: {},
|
||||||
nowTime: '',
|
nowTime: '',
|
||||||
searchForm: {
|
searchForm: {
|
||||||
area: '2',
|
area: '2',
|
||||||
|
|
@ -1955,11 +1957,15 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 改变电伴热设备状态
|
// 改变电伴热设备状态
|
||||||
async ChangeDBRdevocte(item) {
|
async ChangeDBRdevocte() {
|
||||||
console.log(item.online, '开关状态');
|
if (this.iotDBRInfo.status == '异常' || !this.iotDBRInfo.device_id) {
|
||||||
|
this.$message.warning('设备异常,不能操作')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
console.log(this.iotDBRInfo.online, '开关状态');
|
||||||
let res = await changeDbrIotDeviceStatus({
|
let res = await changeDbrIotDeviceStatus({
|
||||||
device_id: item.device_id,
|
device_id: this.iotDBRInfo.device_id,
|
||||||
action: item.online ? 'open' : 'close',
|
action: this.iotDBRInfo.online ? 'open' : 'close',
|
||||||
})
|
})
|
||||||
if (res?.data?.message) {
|
if (res?.data?.message) {
|
||||||
this.$message.success(res.data.message)
|
this.$message.success(res.data.message)
|
||||||
|
|
@ -3469,12 +3475,12 @@ export default {
|
||||||
that.$set(that.dataForm, 'iotKeys', [])
|
that.$set(that.dataForm, 'iotKeys', [])
|
||||||
console.log("电伴热", that.dataForm)
|
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)
|
console.log("电伴热2", res)
|
||||||
if (res?.status == 200) {
|
if (res?.status == 200) {
|
||||||
let all_data = Object.values(res.data);
|
console.log("电伴热3", res.data)
|
||||||
console.log("电伴热3", all_data)
|
this.iotDBRInfo = res.data
|
||||||
this.iotDBRLis = all_data
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue