2024-02-21 16:41:40 +08:00
|
|
|
<template>
|
2024-02-26 10:43:33 +08:00
|
|
|
<div class='point-tree' style='height: 100%; width: 100%; display: flex; flex-direction: column'>
|
2024-02-22 14:51:05 +08:00
|
|
|
<el-select
|
2024-02-26 10:43:33 +08:00
|
|
|
v-model='formData.statisticalType'
|
|
|
|
|
placeholder='请选择'
|
|
|
|
|
style='min-width: unset; padding: 10px 10px 0'
|
|
|
|
|
@change='loadData'
|
2024-02-22 14:51:05 +08:00
|
|
|
>
|
|
|
|
|
<el-option
|
2024-02-26 10:43:33 +08:00
|
|
|
v-for='item in classificationData'
|
|
|
|
|
:key='item.id'
|
|
|
|
|
:label='item.name'
|
|
|
|
|
:value='item.id'
|
2024-02-22 14:51:05 +08:00
|
|
|
></el-option>
|
2024-02-21 16:41:40 +08:00
|
|
|
</el-select>
|
2024-02-26 10:43:33 +08:00
|
|
|
<div style='flex: 1; overflow: hidden'>
|
|
|
|
|
<Tree ref='treRef' :data='tree' style='width: 100%; height: 100%' :canExpand='false' v-bind='$attrs' />
|
2024-02-21 16:41:40 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
2024-02-26 10:43:33 +08:00
|
|
|
<script lang='ts' setup>
|
|
|
|
|
import { nextTick, onMounted, ref, useAttrs } from 'vue'
|
2024-02-21 16:41:40 +08:00
|
|
|
import Tree from '../index.vue'
|
|
|
|
|
import { useAdminInfo } from '@/stores/adminInfo'
|
|
|
|
|
import { useDictData } from '@/stores/dictData'
|
|
|
|
|
import { getTerminalTreeForFive } from '@/api/device-boot/terminalTree'
|
|
|
|
|
import { useConfig } from '@/stores/config'
|
|
|
|
|
|
|
|
|
|
defineOptions({
|
|
|
|
|
name: 'pms/pointTree'
|
|
|
|
|
})
|
|
|
|
|
const emit = defineEmits(['init'])
|
2024-02-26 10:43:33 +08:00
|
|
|
const attrs = useAttrs()
|
2024-02-21 16:41:40 +08:00
|
|
|
const adminInfo = useAdminInfo()
|
|
|
|
|
const dictData = useDictData()
|
|
|
|
|
const config = useConfig()
|
|
|
|
|
const classificationData = dictData.getBasicData('Statistical_Type', ['Report_Type'])
|
|
|
|
|
const tree = ref()
|
|
|
|
|
const treRef = ref()
|
|
|
|
|
const formData = ref({
|
|
|
|
|
deptIndex: adminInfo.$state.deptIndex,
|
|
|
|
|
monitorFlag: 2,
|
|
|
|
|
powerFlag: 2,
|
|
|
|
|
loadType: null,
|
|
|
|
|
manufacturer: null,
|
|
|
|
|
serverName: 'event-boot',
|
|
|
|
|
statisticalType: classificationData[0].id,
|
|
|
|
|
scale: null
|
|
|
|
|
})
|
|
|
|
|
const loadData = () => {
|
|
|
|
|
let form = JSON.parse(JSON.stringify(formData.value))
|
|
|
|
|
form.statisticalType = classificationData.find((item: any) => item.id == form.statisticalType)
|
2024-02-26 10:43:33 +08:00
|
|
|
let nodeKey = ''
|
2024-02-21 16:41:40 +08:00
|
|
|
getTerminalTreeForFive(form).then(res => {
|
|
|
|
|
console.log(res)
|
|
|
|
|
res.data.forEach((item: any) => {
|
|
|
|
|
item.icon = 'fa-solid fa-synagogue'
|
|
|
|
|
item.color = config.getColorVal('elementUiPrimary')
|
|
|
|
|
item.children.forEach((item2: any) => {
|
|
|
|
|
item2.icon = 'fa-solid fa-city'
|
|
|
|
|
item.color = config.getColorVal('elementUiPrimary')
|
|
|
|
|
item2.children.forEach((item3: any) => {
|
|
|
|
|
item3.icon = 'fa-solid fa-building'
|
|
|
|
|
item3.color = config.getColorVal('elementUiPrimary')
|
|
|
|
|
item3.children.forEach((item4: any) => {
|
|
|
|
|
item4.icon = 'fa-solid fa-tower-observation'
|
|
|
|
|
item4.color = config.getColorVal('elementUiPrimary')
|
2024-02-26 10:43:33 +08:00
|
|
|
item4.children.forEach((item5: anyObj) => {
|
|
|
|
|
if ((!attrs['current-node-key']) && !nodeKey) {
|
|
|
|
|
nodeKey = item5.id
|
|
|
|
|
emit('init', item5)
|
|
|
|
|
}
|
2024-02-21 16:41:40 +08:00
|
|
|
item5.icon = 'fa-solid fa-location-dot'
|
|
|
|
|
item5.color = config.getColorVal('elementUiPrimary')
|
|
|
|
|
if (item5.comFlag === 0) {
|
|
|
|
|
item5.color = 'red !important'
|
|
|
|
|
} else if (item5.comFlag === 1) {
|
|
|
|
|
item5.color = '#00f93b !important'
|
|
|
|
|
} else if (item5.comFlag === 2) {
|
|
|
|
|
item5.color = '#8c8c8c !important'
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
tree.value = res.data
|
2024-02-26 10:43:33 +08:00
|
|
|
if (nodeKey) {
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
treRef.value.treeRef.setCurrentKey(nodeKey)
|
|
|
|
|
treRef.value.treeRef.setExpandedKeys(nodeKey)
|
|
|
|
|
})
|
|
|
|
|
}
|
2024-02-21 16:41:40 +08:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
loadData()
|
|
|
|
|
</script>
|