4 changed files with 205 additions and 4 deletions
@ -0,0 +1,82 @@ |
|||
<template> |
|||
<div class='DeviceParams'> |
|||
<div class="no-data" v-if="!devicesList.length" v-loading="secondLoading">暂无设备参数</div> |
|||
|
|||
<Descriptions :list="devicesList" :data="devicesData" style="gap: 18px;" column="6"> |
|||
<template v-for="item in devicesList.slice(0, -1)" #[`content-${getSlotKey(item.key)}`]="{ data }"> |
|||
<span>{{ data.text }}</span> |
|||
</template> |
|||
</Descriptions> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import Descriptions from '@screen/components/Descriptions.vue'; |
|||
import Switcher from '@screen/pages/service/PublishingChannelManagement/components/Switcher.vue'; |
|||
import request from "@/utils/request"; |
|||
import { Message } from 'element-ui'; |
|||
import { confirm } from "@screen/utils/common"; |
|||
|
|||
|
|||
export default { |
|||
name: 'DeviceParams', |
|||
components: { |
|||
Descriptions, |
|||
Switcher |
|||
}, |
|||
props: { |
|||
dialogData: { |
|||
type: Object, |
|||
default: () => ({}) |
|||
}, |
|||
disabled: Boolean |
|||
}, |
|||
data() { |
|||
return { |
|||
secondLoading: true, |
|||
devicesList: [], |
|||
devicesData: {}, |
|||
} |
|||
}, |
|||
async created() { |
|||
this.devicesList = []; |
|||
let devs = []; |
|||
// Promise.all([this.getAc('A1'), this.getAc('A2'), this.getAc('A3'), this.getAc('A4'), this.getAc('A5'), this.getAc('A6')]).then(res => { |
|||
const iotDeviceId = this.dialogData.iotDeviceId.replace(/-502$/, '-8887'); |
|||
await |
|||
request({ |
|||
url: `/business/device/properties/latest/${iotDeviceId}`, |
|||
method: "get", |
|||
}).then(result => { |
|||
if (result.code != 200) return Message.error("操作失败"); |
|||
result.data.forEach(item => { |
|||
if (item.propertyName) { |
|||
devs.push({ |
|||
label: item.propertyName, |
|||
key: item.property, |
|||
gridColumn: 3, |
|||
}); |
|||
this.devicesData[item.property] = item.formatValue; |
|||
} |
|||
}); |
|||
this.devicesList = devs; |
|||
}) |
|||
}, |
|||
methods: { |
|||
getSlotKey(key) { |
|||
return key.includes('electricity') || key.includes('fan') ? key : '' |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style lang='scss' scoped> |
|||
.DeviceParams { |
|||
height: 100%; |
|||
} |
|||
.tips { |
|||
padding: 10px; |
|||
color: rgb(231, 237, 244); /* 文字颜色 */ |
|||
} |
|||
</style> |
|||
|
@ -0,0 +1,101 @@ |
|||
<template> |
|||
<div class='DeviceParams'> |
|||
<div class="no-data" v-if="!devicesList.length" v-loading="secondLoading">暂无设备参数</div> |
|||
|
|||
<Descriptions :list="devicesList" :data="devicesData" style="gap: 18px;" column="6"> |
|||
<template v-for="item in devicesList.slice(0, -1)" #[`content-${getSlotKey(item.key)}`]="{ data }"> |
|||
<span>{{ data.text }}</span> |
|||
</template> |
|||
</Descriptions> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import Descriptions from '@screen/components/Descriptions.vue'; |
|||
import Switcher from '@screen/pages/service/PublishingChannelManagement/components/Switcher.vue'; |
|||
import request from "@/utils/request"; |
|||
import { Message } from 'element-ui'; |
|||
import { confirm } from "@screen/utils/common"; |
|||
|
|||
|
|||
export default { |
|||
name: 'DeviceParams', |
|||
components: { |
|||
Descriptions, |
|||
Switcher |
|||
}, |
|||
props: { |
|||
dialogData: { |
|||
type: Object, |
|||
default: () => ({}) |
|||
}, |
|||
disabled: Boolean |
|||
}, |
|||
data() { |
|||
return { |
|||
secondLoading: true, |
|||
devicesList: [], |
|||
environment: [], |
|||
|
|||
devicesData: {}, |
|||
|
|||
} |
|||
}, |
|||
async created() { |
|||
this.devicesList = []; |
|||
let devs = []; |
|||
let envDevs = []; // 用于临时存储环境数据 |
|||
|
|||
// Promise.all([this.getAc('A1'), this.getAc('A2'), this.getAc('A3'), this.getAc('A4'), this.getAc('A5'), this.getAc('A6')]).then(res => { |
|||
const iotDeviceId = this.dialogData.iotDeviceId.replace(/-502$/, '-232'); |
|||
await |
|||
request({ |
|||
url: `/business/device/properties/latest/${iotDeviceId}`, |
|||
method: "get", |
|||
}).then(result => { |
|||
if (result.code != 200) return Message.error("操作失败"); |
|||
result.data.forEach(item => { |
|||
if (item.propertyName) { |
|||
if (item.propertyName === "温湿度状态-湿度" || item.propertyName === "温湿度状态-温度"|| item.propertyName === "频闪灯开关" |
|||
||item.propertyName === "环境温度"||item.propertyName === "环境光度"||item.propertyName === "环境湿度"||item.propertyName === "系统状态-环境(温湿度等)") { |
|||
// 如果是环境相关的数据,添加到environment集合 |
|||
envDevs.push({ |
|||
label: item.propertyName, |
|||
key: item.property, |
|||
gridColumn: 3, |
|||
}); |
|||
this.devicesData[item.property] = item.formatValue; |
|||
} else { |
|||
// 其他数据添加到devicesList集合 |
|||
devs.push({ |
|||
label: item.propertyName, |
|||
key: item.property, |
|||
gridColumn: 3, |
|||
}); |
|||
this.devicesData[item.property] = item.formatValue; |
|||
} |
|||
} |
|||
}); |
|||
this.devicesList = devs; |
|||
this.environment = envDevs; // 将环境数据赋值给environment |
|||
|
|||
}) |
|||
}, |
|||
methods: { |
|||
getSlotKey(key) { |
|||
return key.includes('electricity') || key.includes('fan') ? key : '' |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style lang='scss' scoped> |
|||
.DeviceParams { |
|||
height: 100%; |
|||
} |
|||
.tips { |
|||
padding: 10px; |
|||
color: rgb(231, 237, 244); /* 文字颜色 */ |
|||
} |
|||
</style> |
|||
|
Loading…
Reference in new issue