2024-01-09 13:49:21 +08:00
|
|
|
<template>
|
2024-01-11 08:54:09 +08:00
|
|
|
<Tree ref="treRef" :data="tree" />
|
2024-01-09 13:49:21 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2024-01-11 08:54:09 +08:00
|
|
|
import { ref, nextTick } from 'vue'
|
|
|
|
|
import Tree from '../index.vue'
|
|
|
|
|
import { getLineTree } from '@/api/cs-device-boot/csLedger'
|
2024-01-09 13:49:21 +08:00
|
|
|
import { useConfig } from '@/stores/config'
|
|
|
|
|
defineOptions({
|
|
|
|
|
name: 'govern/deviceTree'
|
|
|
|
|
})
|
2024-01-11 08:54:09 +08:00
|
|
|
const emit = defineEmits(['init'])
|
2024-01-09 13:49:21 +08:00
|
|
|
const config = useConfig()
|
|
|
|
|
const tree = ref()
|
2024-01-11 08:54:09 +08:00
|
|
|
const treRef = ref()
|
|
|
|
|
getLineTree().then(res => {
|
2024-01-09 13:49:21 +08:00
|
|
|
let arr: any[] = []
|
2024-01-09 16:45:29 +08:00
|
|
|
res.data.forEach((item: any) => {
|
2024-01-09 13:49:21 +08:00
|
|
|
item.icon = 'el-icon-HomeFilled'
|
|
|
|
|
item.color = config.getColorVal('elementUiPrimary')
|
2024-01-09 16:45:29 +08:00
|
|
|
item.children.forEach((item2: any) => {
|
2024-01-09 13:49:21 +08:00
|
|
|
item2.icon = 'el-icon-List'
|
|
|
|
|
item.color = config.getColorVal('elementUiPrimary')
|
2024-01-09 16:45:29 +08:00
|
|
|
item2.children.forEach((item3: any) => {
|
2024-01-09 13:49:21 +08:00
|
|
|
item3.icon = 'el-icon-Platform'
|
|
|
|
|
item3.color = config.getColorVal('elementUiPrimary')
|
|
|
|
|
if (item3.comFlag === 1) {
|
|
|
|
|
item3.color = '#e26257 !important'
|
|
|
|
|
}
|
2024-01-11 08:54:09 +08:00
|
|
|
item3.children.forEach((item4: any) => {
|
|
|
|
|
item4.icon = 'el-icon-LocationFilled'
|
|
|
|
|
arr.push(item4)
|
|
|
|
|
})
|
2024-01-09 13:49:21 +08:00
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
tree.value = res.data
|
2024-01-11 08:54:09 +08:00
|
|
|
nextTick(() => {
|
2024-01-29 14:57:49 +08:00
|
|
|
if (arr.length) {
|
|
|
|
|
treRef.value.treeRef.setCurrentKey(arr[0].id)
|
|
|
|
|
// 注册父组件事件
|
|
|
|
|
emit('init', {
|
|
|
|
|
level: 2,
|
|
|
|
|
...arr[0]
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
emit('init')
|
|
|
|
|
}
|
2024-01-11 08:54:09 +08:00
|
|
|
})
|
2024-01-09 13:49:21 +08:00
|
|
|
})
|
|
|
|
|
</script>
|