feat: 空调可视化列表

This commit is contained in:
huanghao1412 2024-04-19 15:19:48 +08:00
parent d96e79ffec
commit 8cb59f3d6b
4 changed files with 100 additions and 26 deletions

View File

@ -14,9 +14,9 @@ export const option = {
// 展示列
header: {
columns: [
{key: 'node_name', title: '设备名', unit: '', show: true, width: 'auto', align: 'left', ellipsis: true},
{key: '空调功率', title: '空调功率', unit: 'kW', show: true, width: 'auto', align: 'left', ellipsis: true},
{key: '用电量', title: '用电量', unit: 'kWh', show: true, width: 'auto', align: 'left', ellipsis: true},
{key: 'node_name', reg: '', title: '设备名', unit: '', show: true, width: 'auto', align: 'left', ellipsis: true},
{key: 'col1', reg: '/功率/', title: '空调功率', unit: 'kW', show: true, width: 'auto', align: 'left', ellipsis: true},
{key: 'col2', reg: '/用电量/', title: '用电量', unit: 'kWh', show: true, width: 'auto', align: 'left', ellipsis: true},
],
// value: [],
// options: [],

View File

@ -7,8 +7,8 @@
<n-switch v-model:value="it.show" size="small"/>
</n-space>
</setting-item>
<setting-item name="字段名 对应设备测点名称">
<n-input v-model:value="it.key"/>
<setting-item name="正则表达式 匹配测点名称 如/功率/" v-if="i !== 0">
<n-input v-model:value="it.reg"/>
</setting-item>
<setting-item name="列名">
<n-input v-model:value="it.title"/>

View File

@ -78,7 +78,7 @@ watch(() => props.chartConfig.option.header, v => {
deep: true
})
let originData = ref({}) as {[k: string]: any}
let originData:any = ref([])
const customData = computed(() => {
return props.chartConfig.customData as typeof cd
@ -86,26 +86,46 @@ const customData = computed(() => {
let data = computed(() => {
let arr:any = []
if(!Object.keys(originData.value).length) return arr
customData.value.ids.forEach((id: string) => {
// if(!Object.keys(originData.value).length) return arr
// customData.value.ids.forEach((id: string) => {
// let obj: any = {}
// option.header.columns.forEach((col: any, i: number) => {
// if(i === 0) {
// obj[col.key] = originData.value[id]?.[col.key]
// }
// else {
// let o = originData.value[id] ? originData.value[id] : null
// if(o) {
// let arr = [
// ...Object.values(o.aic),
// ...Object.values(o.aoc),
// ...Object.values(o.dic),
// ...Object.values(o.doc),
// ]
// let t:any = arr.find((_: any) => _.node_name === col.key) || {}
// obj[col.key] = t.value
// }
// else obj[col.key] = undefined
// }
// })
// arr.push(obj)
// })
if(!originData.value.length) return arr
customData.value.ids.forEach((id, i) => {
let target = originData.value[i]
let obj: any = {}
option.header.columns.forEach((col: any, i: number) => {
if(i === 0) {
obj[col.key] = originData.value[id]?.[col.key]
option.header.columns.forEach((col: any, ci:number) => {
if(ci === 0) {
obj[col.key] = target.node_name
}
else {
let o = originData.value[id] ? originData.value[id] : null
if(o) {
let arr = [
...Object.values(o.aic),
...Object.values(o.aoc),
...Object.values(o.dic),
...Object.values(o.doc),
]
let t:any = arr.find((_: any) => _.node_name === col.key) || {}
obj[col.key] = t.value
const pattern = col.reg.slice(1, -1); //
let t = {node_value: ''}
if(pattern) {
const regex = new RegExp(pattern);
t = target.children.find((_: any) => regex.test(_.node_name)) || {}
}
else obj[col.key] = undefined
obj[col.key] = t.node_value
}
})
arr.push(obj)
@ -153,6 +173,7 @@ if (systemConfig['active_alarm_confirm_status']) {
const getData = () => {
if(!customData.value.ids.filter((_: string) => _).length) {
originData.value = []
return
}
let params = {
@ -164,10 +185,53 @@ const getData = () => {
}
publicInterface('/dcim/dems/device_point', 'cinterface_realtime_data_get_by_uid_no_err_v2', params).then(res => {
if (res && res.data) {
originData.value = res.data
let arr = customData.value.ids.map((id: string) => {
let obj = {
node_name: res.data[id] ? res.data[id].node_name : '',
uid: id
}
return obj
})
getDataChild(arr)
}
})
}
const getDataChild = (parents: any) => {
let params = {
"condition": {
"dems_device_uid": '',
"node_name": "",
"signal_id": "",
"node_status": null,
"data_type": "",
"dems_device_template_id": null,
"is_major_paramenter": "",
"is_show": true,
"open_driver": true
},
"page": {
"page_size": 99999,
"page_number": 1
}
}
let arr = customData.value.ids.map(_ => {
let p = cloneDeep(params)
p.condition.dems_device_uid = _
return publicInterface('/dcim/dems/device_point', 'get_page', p)
})
Promise.all(arr).then(res => {
let data = res.map(item => {
if(item && item.errcode === '00000') return item.data.item || []
else return []
})
data.forEach((item, i) => {
parents[i].children = item
})
originData.value = parents
})
}
watch(() => customData.value.ids, () => {
getData()
}, {
@ -208,7 +272,7 @@ onUnmounted(() => {
</script>
<style lang="scss" scoped>
::v-deep tr{
:deep(tr) {
height: var(--lineHeight);
}
@include go('tables-basic') {

View File

@ -1,10 +1,20 @@
import {postMessageToParent} from "@/utils";
const bindEvent = (item:any) => {
let obj = {}
if(item?.customEvent?.click) {
let {linkHead, link} = item.customEvent.click
let {linkHead, link, isBlank} = item.customEvent.click
obj = {
click: () => {
if(link) window.open(`${linkHead}${link}`)
if(isBlank) postMessageToParent({
type: 'windowOpen',
url: `${linkHead}${link}`,
openNew: true
})
else postMessageToParent({
type: 'windowOpen',
url: `${linkHead}${link}`,
})
}
}
}