From da1c16e0230324e151c117a5f645bc6e8532c068 Mon Sep 17 00:00:00 2001 From: AN <1983933789@qq.com> Date: Tue, 10 Jun 2025 20:33:11 +0800 Subject: [PATCH] =?UTF-8?q?fix(components):=20=E4=BF=AE=E5=A4=8D=E9=83=A8?= =?UTF-8?q?=E9=97=A8=E9=80=89=E6=8B=A9=E7=BB=84=E4=BB=B6=E9=9D=9E=E6=A0=91?= =?UTF-8?q?=E7=BB=93=E6=9E=84=EF=BC=8C=E9=BB=98=E8=AE=A4=E5=B1=95=E5=BC=80?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/custom/dept-tree-select.vue | 19 ++++++++++++------- src/components/custom/menu-tree.vue | 1 - 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/components/custom/dept-tree-select.vue b/src/components/custom/dept-tree-select.vue index 8277c8eb..457c4cf1 100644 --- a/src/components/custom/dept-tree-select.vue +++ b/src/components/custom/dept-tree-select.vue @@ -2,7 +2,7 @@ import { useAttrs } from 'vue'; import type { TreeSelectProps } from 'naive-ui'; import { useLoading } from '@sa/hooks'; -import { fetchGetDeptSelect } from '@/service/api/system'; +import { fetchGetDeptTree } from '@/service/api/system'; defineOptions({ name: 'DeptTreeSelect' }); @@ -13,16 +13,21 @@ interface Props { defineProps(); const value = defineModel('value', { required: false }); -const options = defineModel('options', { required: false, default: [] }); +const options = defineModel('options', { required: false, default: [] }); +const expandedKeys = defineModel('expandedKeys', { required: false, default: [] }); const attrs: TreeSelectProps = useAttrs(); const { loading, startLoading, endLoading } = useLoading(); async function getDeptList() { startLoading(); - const { error, data } = await fetchGetDeptSelect(); + const { error, data } = await fetchGetDeptTree(); if (error) return; options.value = data; + // 设置默认展开的节点 + if (data?.length && !expandedKeys.value.length) { + expandedKeys.value = [data[0].id]; + } endLoading(); } @@ -32,13 +37,13 @@ getDeptList(); diff --git a/src/components/custom/menu-tree.vue b/src/components/custom/menu-tree.vue index 5565ce7b..4e5da0c1 100644 --- a/src/components/custom/menu-tree.vue +++ b/src/components/custom/menu-tree.vue @@ -149,7 +149,6 @@ defineExpose({ 父子联动 - {{ checkedKeys }}