2024-01-09 13:49:21 +08:00
|
|
|
<template>
|
2026-03-06 09:36:42 +08:00
|
|
|
<Tree
|
|
|
|
|
ref="treRef"
|
|
|
|
|
:width="width"
|
|
|
|
|
:data="tree"
|
|
|
|
|
default-expand-all
|
|
|
|
|
@changePointType="changePointType"
|
|
|
|
|
@changeTreeType="info"
|
|
|
|
|
/>
|
2024-01-09 13:49:21 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2024-10-17 15:42:07 +08:00
|
|
|
import { ref, nextTick, onMounted, defineProps } 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'
|
2026-01-27 16:32:33 +08:00
|
|
|
import { querySysExcel } from '@/api/harmonic-boot/luckyexcel'
|
2024-10-17 15:42:07 +08:00
|
|
|
import { useDictData } from '@/stores/dictData'
|
|
|
|
|
// const props = defineProps(['template'])
|
|
|
|
|
interface Props {
|
|
|
|
|
template?: boolean
|
|
|
|
|
}
|
|
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
2025-07-08 08:44:13 +08:00
|
|
|
template: false
|
2024-10-17 15:42:07 +08:00
|
|
|
})
|
2024-01-09 13:49:21 +08:00
|
|
|
defineOptions({
|
|
|
|
|
name: 'govern/deviceTree'
|
|
|
|
|
})
|
2024-10-17 15:42:07 +08:00
|
|
|
|
|
|
|
|
const emit = defineEmits(['init', 'checkChange', 'pointTypeChange', 'Policy'])
|
2024-01-09 13:49:21 +08:00
|
|
|
const config = useConfig()
|
|
|
|
|
const tree = ref()
|
2024-10-17 15:42:07 +08:00
|
|
|
const dictData = useDictData()
|
2024-01-11 08:54:09 +08:00
|
|
|
const treRef = ref()
|
2024-08-23 08:51:36 +08:00
|
|
|
const width = ref('')
|
2024-10-17 15:42:07 +08:00
|
|
|
|
2026-03-06 09:36:42 +08:00
|
|
|
const info = (type?: string) => {
|
2025-07-08 08:44:13 +08:00
|
|
|
tree.value = []
|
|
|
|
|
let arr1: any[] = []
|
|
|
|
|
let arr2: any[] = []
|
2025-10-11 10:35:25 +08:00
|
|
|
let arr3: any[] = []
|
2026-03-06 09:36:42 +08:00
|
|
|
let arr4: any[] = []
|
|
|
|
|
getLineTree({ type: type == '2' ? 'engineering' : '' }).then(res => {
|
2024-10-17 15:42:07 +08:00
|
|
|
//治理设备
|
2026-03-06 09:36:42 +08:00
|
|
|
|
2024-10-17 15:42:07 +08:00
|
|
|
res.data.map((item: any) => {
|
2026-03-06 09:36:42 +08:00
|
|
|
if (type == '2') {
|
|
|
|
|
item.icon = 'el-icon-Menu'
|
|
|
|
|
item.color = config.getColorVal('elementUiPrimary')
|
2024-10-17 15:42:07 +08:00
|
|
|
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'
|
2026-03-06 09:36:42 +08:00
|
|
|
|
2024-10-17 15:42:07 +08:00
|
|
|
item3.color =
|
|
|
|
|
item3.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
|
2026-03-06 09:36:42 +08:00
|
|
|
arr4.push(item3)
|
|
|
|
|
// item3.children.forEach((item4: any) => {
|
|
|
|
|
// item4.icon = 'el-icon-Platform'
|
|
|
|
|
// item4.color =
|
|
|
|
|
// item4.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
|
|
|
|
|
|
|
|
|
|
// })
|
2024-06-27 09:39:53 +08:00
|
|
|
})
|
|
|
|
|
})
|
2024-01-11 08:54:09 +08:00
|
|
|
})
|
2026-03-06 09:36:42 +08:00
|
|
|
} else {
|
|
|
|
|
if (item.name == '治理设备') {
|
|
|
|
|
item.children.forEach((item: any) => {
|
|
|
|
|
item.icon = 'el-icon-HomeFilled'
|
|
|
|
|
item.level = 1
|
|
|
|
|
item.color = config.getColorVal('elementUiPrimary')
|
|
|
|
|
item.children.forEach((item2: any) => {
|
|
|
|
|
item2.icon = 'el-icon-List'
|
|
|
|
|
item2.level = 1
|
|
|
|
|
item2.color = config.getColorVal('elementUiPrimary')
|
|
|
|
|
item2.children.forEach((item3: any) => {
|
|
|
|
|
item3.icon = 'el-icon-Platform'
|
|
|
|
|
item3.level = 2
|
|
|
|
|
item3.color =
|
|
|
|
|
item3.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
|
|
|
|
|
item3.children.forEach((item4: any) => {
|
|
|
|
|
item4.icon = 'el-icon-Platform'
|
|
|
|
|
item4.color =
|
|
|
|
|
item4.comFlag === 2
|
|
|
|
|
? config.getColorVal('elementUiPrimary')
|
|
|
|
|
: '#e26257 !important'
|
|
|
|
|
// item4.color = '#e26257 !important'
|
|
|
|
|
arr1.push(item4)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
2024-10-17 15:42:07 +08:00
|
|
|
})
|
2026-03-06 09:36:42 +08:00
|
|
|
} else if (item.name == '便携式设备') {
|
|
|
|
|
item.children.forEach((item: any) => {
|
|
|
|
|
item.icon = 'el-icon-Platform'
|
|
|
|
|
item.color = config.getColorVal('elementUiPrimary')
|
|
|
|
|
item.color = item.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
|
|
|
|
|
item.children.forEach((item2: any) => {
|
|
|
|
|
item2.icon = 'el-icon-Platform'
|
|
|
|
|
item2.color =
|
|
|
|
|
item2.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
|
|
|
|
|
arr2.push(item2)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
} else if (item.name == '监测设备') {
|
|
|
|
|
item.children.forEach((item: any) => {
|
|
|
|
|
item.icon = 'el-icon-HomeFilled'
|
|
|
|
|
item.level = 1
|
|
|
|
|
item.color = config.getColorVal('elementUiPrimary')
|
|
|
|
|
item.children.forEach((item2: any) => {
|
|
|
|
|
item2.icon = 'el-icon-List'
|
|
|
|
|
item2.level = 1
|
|
|
|
|
item2.color = config.getColorVal('elementUiPrimary')
|
|
|
|
|
item2.children.forEach((item3: any) => {
|
|
|
|
|
item3.icon = 'el-icon-Platform'
|
|
|
|
|
item3.level = 1
|
|
|
|
|
item3.color =
|
|
|
|
|
item3.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
|
|
|
|
|
item3.children.forEach((item4: any) => {
|
|
|
|
|
item4.icon = 'el-icon-Platform'
|
|
|
|
|
item4.color =
|
|
|
|
|
item4.comFlag === 2
|
|
|
|
|
? config.getColorVal('elementUiPrimary')
|
|
|
|
|
: '#e26257 !important'
|
|
|
|
|
// item4.color = '#e26257 !important'
|
|
|
|
|
arr3.push(item4)
|
|
|
|
|
})
|
2025-10-11 10:35:25 +08:00
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
2026-03-06 09:36:42 +08:00
|
|
|
}
|
2024-10-17 15:42:07 +08:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
tree.value = res.data
|
2026-03-30 09:03:53 +08:00
|
|
|
|
2024-10-17 15:42:07 +08:00
|
|
|
nextTick(() => {
|
2025-12-20 23:44:46 +08:00
|
|
|
setTimeout(() => {
|
2026-03-06 09:36:42 +08:00
|
|
|
if (type == '2') {
|
|
|
|
|
//初始化选中
|
|
|
|
|
|
|
|
|
|
treRef.value?.treeRef4.setCurrentKey(arr4[0].id)
|
|
|
|
|
// 注册父组件事件
|
|
|
|
|
emit('init', {
|
|
|
|
|
level: 3,
|
|
|
|
|
...arr4[0]
|
|
|
|
|
})
|
|
|
|
|
changePointType('4', arr4[0])
|
|
|
|
|
return
|
|
|
|
|
} else if (arr1.length > 0) {
|
2025-12-20 23:44:46 +08:00
|
|
|
//初始化选中
|
2026-01-04 14:55:31 +08:00
|
|
|
treRef.value?.treeRef1.setCurrentKey(arr1[0].id)
|
2025-12-20 23:44:46 +08:00
|
|
|
// 注册父组件事件
|
|
|
|
|
emit('init', {
|
|
|
|
|
level: 2,
|
|
|
|
|
...arr1[0]
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
} else if (arr2.length > 0) {
|
|
|
|
|
//初始化选中
|
2026-01-04 14:55:31 +08:00
|
|
|
treRef.value?.treeRef2.setCurrentKey(arr2[0].id)
|
2025-12-20 23:44:46 +08:00
|
|
|
// 注册父组件事件
|
|
|
|
|
emit('init', {
|
|
|
|
|
level: 2,
|
|
|
|
|
...arr2[0]
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
} else if (arr3.length > 0) {
|
2026-01-04 14:55:31 +08:00
|
|
|
treRef.value?.treeRef3?.setCurrentKey(arr3[0].id)
|
2025-12-20 23:44:46 +08:00
|
|
|
emit('init', {
|
|
|
|
|
level: 2,
|
|
|
|
|
...arr3[0]
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
} else {
|
|
|
|
|
emit('init')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}, 500)
|
2024-10-17 15:42:07 +08:00
|
|
|
})
|
2024-01-09 13:49:21 +08:00
|
|
|
})
|
2024-10-17 15:42:07 +08:00
|
|
|
}
|
|
|
|
|
const changePointType = (val: any, obj: any) => {
|
|
|
|
|
emit('pointTypeChange', val, obj)
|
|
|
|
|
}
|
|
|
|
|
if (props.template) {
|
2026-03-30 09:03:53 +08:00
|
|
|
// id: dictData.state.area[0]?.id
|
|
|
|
|
querySysExcel({})
|
2025-07-08 08:44:13 +08:00
|
|
|
.then((res: any) => {
|
|
|
|
|
emit('Policy', res.data)
|
|
|
|
|
info()
|
|
|
|
|
})
|
|
|
|
|
.catch(err => {
|
|
|
|
|
info()
|
|
|
|
|
})
|
2024-10-17 15:42:07 +08:00
|
|
|
} else {
|
|
|
|
|
info()
|
|
|
|
|
}
|
2025-07-08 08:44:13 +08:00
|
|
|
onMounted(() => {})
|
2024-01-09 13:49:21 +08:00
|
|
|
</script>
|