2024-03-06 20:37:36 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="point-tree">
|
|
|
|
|
<div style="flex: 1; overflow: hidden">
|
|
|
|
|
<Tree ref="treeRef" :data="tree" style="width: 100%; height: 100%" :canExpand="false" v-bind="$attrs" />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import { nextTick, onMounted, ref, useAttrs } from 'vue'
|
|
|
|
|
import Tree from '../index.vue'
|
|
|
|
|
|
|
|
|
|
import { useDictData } from '@/stores/dictData'
|
|
|
|
|
import { carryCapacityTree } from '@/api/advance-boot/bearingCapacity'
|
|
|
|
|
import { useConfig } from '@/stores/config'
|
|
|
|
|
|
|
|
|
|
defineOptions({
|
|
|
|
|
name: 'pms/pointTree'
|
|
|
|
|
})
|
|
|
|
|
const emit = defineEmits(['init'])
|
|
|
|
|
const attrs = useAttrs()
|
|
|
|
|
|
|
|
|
|
const dictData = useDictData()
|
|
|
|
|
const config = useConfig()
|
|
|
|
|
const tree = ref()
|
|
|
|
|
const treeRef = ref()
|
|
|
|
|
|
|
|
|
|
const loadData = () => {
|
|
|
|
|
let nodeKey = ''
|
|
|
|
|
carryCapacityTree().then(res => {
|
|
|
|
|
nodeKey = res.data[0].children[0].children[0].children[0].children[0].children[0].id
|
|
|
|
|
emit('init', res.data[0].children[0].children[0].children[0].children[0].children[0])
|
2024-03-21 20:13:25 +08:00
|
|
|
tree.value = res.data[0].children[0].children
|
2024-03-06 20:37:36 +08:00
|
|
|
if (nodeKey) {
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
treeRef.value.treeRef.setCurrentKey(nodeKey)
|
|
|
|
|
// treeRef.value.treeRef.setExpandedKeys(nodeKey)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
loadData()
|
2024-03-21 20:13:25 +08:00
|
|
|
const setKey = (key: string) => {
|
|
|
|
|
treeRef.value.treeRef.setCurrentKey(key)
|
|
|
|
|
}
|
|
|
|
|
defineExpose({ setKey })
|
2024-03-06 20:37:36 +08:00
|
|
|
</script>
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
.point-tree {
|
|
|
|
|
height: 100%;
|
|
|
|
|
width: 100%;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
background: #fff;
|
|
|
|
|
border: 1px solid var(--el-border-color);
|
|
|
|
|
}
|
|
|
|
|
</style>
|