2024-12-09 06:44:52 +00:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import type { TreeOption } from 'naive-ui'
|
|
|
|
import Tree from '@/components/Tree/index.vue'
|
|
|
|
import { useBase } from './hooks/base'
|
|
|
|
import { useEarth } from '../Earth/hooks/earth'
|
|
|
|
import { parseWKT } from '@/utils/parseWKT'
|
|
|
|
|
2025-01-13 08:45:08 +00:00
|
|
|
const { isLoading, treeData, allKeys, addBaseFacilities } = useBase()
|
2024-12-09 06:44:52 +00:00
|
|
|
|
|
|
|
watch(allKeys, val => {
|
|
|
|
nextTick(() => {
|
|
|
|
checkedKeys.value = val
|
|
|
|
})
|
|
|
|
})
|
|
|
|
// onMounted(() => {
|
|
|
|
// nextTick(() => {
|
|
|
|
// console.log(allKeys, 'val---')
|
|
|
|
// checkedKeys.value = allKeys.value
|
|
|
|
// })
|
|
|
|
// })
|
|
|
|
const checkedKeys = ref<Array<string | number>>([])
|
|
|
|
|
|
|
|
watch(checkedKeys, val => {
|
|
|
|
addBaseFacilities(val)
|
|
|
|
})
|
|
|
|
|
|
|
|
const { flyTo } = useEarth()
|
|
|
|
const nodeProps = ({ option }: { option: TreeOption }) => {
|
2025-03-03 09:31:58 +00:00
|
|
|
// console.log(option, 'option')
|
2024-12-09 06:44:52 +00:00
|
|
|
return {
|
|
|
|
onclick: () => {
|
|
|
|
if (option.children) {
|
|
|
|
return
|
|
|
|
}
|
2025-03-03 09:31:58 +00:00
|
|
|
|
2024-12-09 06:44:52 +00:00
|
|
|
const {
|
|
|
|
dataId,
|
|
|
|
data: { geom },
|
|
|
|
} = option
|
|
|
|
const [lon, lat] = parseWKT(geom).coordinates
|
|
|
|
if (checkedKeys.value.includes(dataId as string)) {
|
|
|
|
flyTo({ lon, lat })
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2025-01-20 01:42:19 +00:00
|
|
|
|
2025-03-03 09:31:58 +00:00
|
|
|
const renderSuffix = ({ option }: { option: TreeOption }) => {}
|
2024-12-09 06:44:52 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2025-01-13 08:45:08 +00:00
|
|
|
<div class="w-h-full" v-loading="isLoading">
|
2024-12-09 06:44:52 +00:00
|
|
|
<tree
|
|
|
|
:data="treeData"
|
|
|
|
:key-field="'dataId'"
|
|
|
|
:label-field="'nodeName'"
|
|
|
|
v-model:checked="checkedKeys"
|
|
|
|
:defaultCheckedKeys="allKeys"
|
|
|
|
showSearch
|
|
|
|
:nodeProps="nodeProps"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style lang="scss" scoped></style>
|