2025-10-11 10:35:25 +08:00
|
|
|
<template>
|
2026-04-02 09:08:57 +08:00
|
|
|
<Tree
|
|
|
|
|
ref="treRef"
|
2026-06-16 08:34:45 +08:00
|
|
|
|
2026-04-02 09:08:57 +08:00
|
|
|
:width="width"
|
|
|
|
|
:showPush="props.showPush"
|
|
|
|
|
:expand-on-click-node="false"
|
|
|
|
|
:data="tree"
|
|
|
|
|
@changePointType="changePointType"
|
|
|
|
|
@onAdd="onAdd"
|
|
|
|
|
/>
|
2025-10-11 10:35:25 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2026-06-04 09:08:37 +08:00
|
|
|
import { ref } from 'vue'
|
2025-10-11 10:35:25 +08:00
|
|
|
import Tree from '../index.vue'
|
2026-06-04 09:08:37 +08:00
|
|
|
import { getCldTree } from '@/api/cs-device-boot/csLedger'
|
2025-10-11 10:35:25 +08:00
|
|
|
import { useConfig } from '@/stores/config'
|
2026-01-27 16:32:33 +08:00
|
|
|
import { querySysExcel } from '@/api/harmonic-boot/luckyexcel'
|
2025-10-11 10:35:25 +08:00
|
|
|
import { useDictData } from '@/stores/dictData'
|
2026-06-04 09:08:37 +08:00
|
|
|
import { createLineTreeDecorators } from './lineTreeUtils'
|
|
|
|
|
import { decorateCloudTree } from './deviceTreeUtils'
|
|
|
|
|
import { bootstrapWithTemplate, selectTreeNode } from './treeCommonUtils'
|
2025-10-11 10:35:25 +08:00
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
template?: boolean
|
2025-12-09 13:58:37 +08:00
|
|
|
showPush?: boolean
|
2025-10-11 10:35:25 +08:00
|
|
|
}
|
2026-06-04 09:08:37 +08:00
|
|
|
|
2025-10-11 10:35:25 +08:00
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
2025-12-09 13:58:37 +08:00
|
|
|
template: false,
|
|
|
|
|
showPush: false
|
2025-10-11 10:35:25 +08:00
|
|
|
})
|
2026-06-04 09:08:37 +08:00
|
|
|
|
|
|
|
|
defineOptions({ name: 'govern/cloudDeviceEntryTree' })
|
2025-10-11 10:35:25 +08:00
|
|
|
|
2026-04-02 09:08:57 +08:00
|
|
|
const emit = defineEmits(['init', 'checkChange', 'pointTypeChange', 'Policy', 'onAdd'])
|
2026-06-04 09:08:37 +08:00
|
|
|
|
2025-10-11 10:35:25 +08:00
|
|
|
const config = useConfig()
|
|
|
|
|
const dictData = useDictData()
|
2026-06-04 09:08:37 +08:00
|
|
|
const tree = ref<any[]>([])
|
|
|
|
|
const treRef = ref<InstanceType<typeof Tree>>()
|
2025-10-11 10:35:25 +08:00
|
|
|
const width = ref('')
|
|
|
|
|
|
2026-06-04 09:08:37 +08:00
|
|
|
const decorators = createLineTreeDecorators(() => config.getColorVal('elementUiPrimary'))
|
2026-04-02 09:08:57 +08:00
|
|
|
|
2026-06-04 09:08:37 +08:00
|
|
|
const changePointType = (_val: any, obj: any) => {
|
|
|
|
|
emit('pointTypeChange', _val, obj)
|
2025-10-11 10:35:25 +08:00
|
|
|
}
|
|
|
|
|
|
2026-06-04 09:08:37 +08:00
|
|
|
const onAdd = () => emit('onAdd')
|
2025-10-17 14:37:31 +08:00
|
|
|
|
2026-06-04 09:08:37 +08:00
|
|
|
async function loadTree() {
|
|
|
|
|
tree.value = []
|
|
|
|
|
const res = await getCldTree()
|
|
|
|
|
const leaves = decorateCloudTree(res.data, decorators)
|
|
|
|
|
tree.value = [res.data]
|
|
|
|
|
|
|
|
|
|
const node = leaves[0]
|
|
|
|
|
if (!node) {
|
|
|
|
|
emit('init')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await selectTreeNode(treRef.value, node, {
|
|
|
|
|
onSelect: selected => {
|
2026-06-08 18:34:49 +08:00
|
|
|
emit('init', { ...selected, level: selected.level ?? 3 })
|
2026-06-04 09:08:37 +08:00
|
|
|
changePointType('4', selected)
|
|
|
|
|
}
|
|
|
|
|
})
|
2025-10-11 10:35:25 +08:00
|
|
|
}
|
|
|
|
|
|
2026-06-04 09:08:37 +08:00
|
|
|
bootstrapWithTemplate(
|
|
|
|
|
props.template,
|
|
|
|
|
loadTree,
|
|
|
|
|
() => querySysExcel({ id: dictData.state.area[0]?.id }),
|
|
|
|
|
data => emit('Policy', data)
|
|
|
|
|
)
|
2025-10-11 10:35:25 +08:00
|
|
|
|
2026-06-04 09:08:37 +08:00
|
|
|
defineExpose({ info: loadTree })
|
2025-10-11 10:35:25 +08:00
|
|
|
</script>
|