diff --git a/components.d.ts b/components.d.ts index 59aea42..c395e8f 100644 --- a/components.d.ts +++ b/components.d.ts @@ -16,7 +16,6 @@ declare module 'vue' { AppNewsBox: typeof import('./src/components/AppNewsBox.vue')['default'] AppPagination: typeof import('./src/components/AppPagination.vue')['default'] ElButton: typeof import('element-plus/es')['ElButton'] - ElCascader: typeof import('element-plus/es')['ElCascader'] ElCol: typeof import('element-plus/es')['ElCol'] ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider'] ElDatePicker: typeof import('element-plus/es')['ElDatePicker'] @@ -32,6 +31,7 @@ declare module 'vue' { ElInputNumber: typeof import('element-plus/es')['ElInputNumber'] ElOption: typeof import('element-plus/es')['ElOption'] ElPagination: typeof import('element-plus/es')['ElPagination'] + ElPopconfirm: typeof import('element-plus/es')['ElPopconfirm'] ElProgress: typeof import('element-plus/es')['ElProgress'] ElRadio: typeof import('element-plus/es')['ElRadio'] ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup'] diff --git a/src/views/home/database/index.vue b/src/views/home/database/index.vue index 15233c4..978e501 100644 --- a/src/views/home/database/index.vue +++ b/src/views/home/database/index.vue @@ -3,7 +3,7 @@ import { RouterView } from 'vue-router' import { useUserStore } from '@/stores/modules/user' import { treeDbList,download } from '@/api/daikin/base' import {databaseld} from "@/stores/modules/database" -import { NPopover } from 'naive-ui' +import { NPopover } from 'naive-ui' const { push } = useRouter() const store = useUserStore() @@ -11,10 +11,10 @@ const database = databaseld() const { toggle } = inject('fullscreen') const activeMenuKey = ref() let idx = ref(0) - +const onClic = ref(false) const titles = ref() function menuHandler(menu: any, index: number) { - console.log(menu) + console.log(menu,index) activeMenuKey.value = menu.id titles.value = menu.name idx.value = index; @@ -29,10 +29,10 @@ function goChild(menu: any) { console.log(menu.id) database.database.id =menu.id } -var activeItem = ref() +var activeItem = ref() const tableData = ref() async function getTree() { - const { data } = await treeDbList({}) + const { data = [] } = await treeDbList({}) tableData.value = data if(data&&data[0]){ @@ -45,13 +45,37 @@ async function getTree() { // activeMenuKey.value = data[0].childList[0].id // } } + if(activeItem.value){ + const { topLevelItem, targetItem } = findItemById(data,activeItem.value) + if(topLevelItem && targetItem){ + const index = data.findIndex((i:any) => i.id === topLevelItem.id) + nextTick(()=>{ + onClic.value = true + menuHandler(topLevelItem,index === -1 ? 0 : index) + goChild(targetItem) + }) + } + } } -onMounted(() => { - getTree() -}) +getTree() -const onClic = ref(false) + + +function findItemById(items:any, targetId:any, topLevelItem:any = null):any { + for (let i = 0; i < items.length; i++) { + const item = items[i]; + if (item.id === targetId) { + return { topLevelItem: topLevelItem || item, targetItem: item }; + } else if (item.childList?.length > 0) { + const result = findItemById(item.childList, targetId, topLevelItem || item); + if (result) { + return result; + } + } + } + return {topLevelItem: null, targetItem: null}; +}