Files
admin-govern/src/components/tree/govern/pointTree.vue

84 lines
3.0 KiB
Vue
Raw Normal View History

2024-01-09 13:49:21 +08:00
<template>
2024-07-22 10:35:01 +08:00
<Tree ref="treRef" :width="width" :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'
2024-06-27 09:39:53 +08:00
import Tree from '../point.vue'
2024-01-11 08:54:09 +08:00
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-06-27 09:39:53 +08:00
const emit = defineEmits(['init', 'checkChange'])
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()
2024-07-22 10:35:01 +08:00
const width=ref('')
2024-01-11 08:54:09 +08:00
getLineTree().then(res => {
2024-06-27 09:39:53 +08:00
console.log(res.data, '设备监控666')
let arr1: any[] = []
let arr2: any[] = []
//治理设备
res.data.map((item: any) => {
if (item.name == '治理设备') {
item.children.forEach((item: any) => {
item.icon = 'el-icon-HomeFilled'
item.color = config.getColorVal('elementUiPrimary')
item.children.forEach((item2: any) => {
item2.icon = 'el-icon-List'
item2.color = config.getColorVal('elementUiPrimary')
item2.children.forEach((item3: any) => {
item3.icon = 'el-icon-Platform'
item3.color = config.getColorVal('elementUiPrimary')
item3.children.forEach((item4: any) => {
item4.icon = 'el-icon-Platform'
item4.color = config.getColorVal('elementUiPrimary')
item4.color = '#e26257 !important'
arr1.push(item4)
})
})
2024-01-11 08:54:09 +08:00
})
2024-01-09 13:49:21 +08:00
})
2024-06-27 09:39:53 +08:00
} else if (item.name == '便携式设备') {
item.children.forEach((item: any) => {
item.icon = 'el-icon-Platform'
item.color = config.getColorVal('elementUiPrimary')
2024-07-12 16:55:10 +08:00
console.log(item.comFlag,"88888");
item.color = item.comFlag === 3 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
2024-06-27 09:39:53 +08:00
item.children.forEach((item2: any) => {
2024-07-12 16:55:10 +08:00
item2.icon = 'el-icon-Platform'
console.log(item2.comFlag,"88888");
item2.color = item2.comFlag === 3 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
2024-06-27 09:39:53 +08:00
arr2.push(item2)
})
})
}
2024-01-09 13:49:21 +08:00
})
tree.value = res.data
2024-01-11 08:54:09 +08:00
nextTick(() => {
2024-06-27 09:39:53 +08:00
if (arr1.length) {
//初始化选中
treRef.value.treeRef1.setCurrentKey(arr1[0].id)
2024-01-29 14:57:49 +08:00
// 注册父组件事件
emit('init', {
level: 2,
2024-06-27 09:39:53 +08:00
...arr1[0]
2024-01-29 14:57:49 +08:00
})
2024-06-27 09:39:53 +08:00
}
// if (arr2.length) {
// //初始化选中
// treRef.value.treeRef2.setCurrentKey(arr2[0].id)
// // 注册父组件事件
// emit('init', {
// level: 2,
// ...arr2[0]
// })
// }
else {
2024-01-29 14:57:49 +08:00
emit('init')
}
2024-01-11 08:54:09 +08:00
})
2024-01-09 13:49:21 +08:00
})
</script>