From cf250cf564e2b46b231ee065976a934550ef118b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BA=84=E9=94=90=E6=B3=A2?= <10549902+zhuangruibo@user.noreply.gitee.com> Date: Fri, 3 Apr 2026 22:52:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/system/dept/index.vue | 53 +++++++++++++------ .../src/views/system/dict/index-manager.vue | 4 +- .../src/views/system/post/index.vue | 45 +++++++++++----- 3 files changed, 71 insertions(+), 31 deletions(-) diff --git a/zdxt-web-client/zdxt-admin-plus-ui/src/views/system/dept/index.vue b/zdxt-web-client/zdxt-admin-plus-ui/src/views/system/dept/index.vue index 6339df9..b039f46 100644 --- a/zdxt-web-client/zdxt-admin-plus-ui/src/views/system/dept/index.vue +++ b/zdxt-web-client/zdxt-admin-plus-ui/src/views/system/dept/index.vue @@ -38,13 +38,15 @@ @@ -160,8 +162,10 @@ const deptList = ref([]); const loading = ref(true); const showSearch = ref(true); const deptOptions = ref([]); -const isExpandAll = ref(true); +const isExpandAll = ref(false); const deptUserList = ref([]); +const childrenMap = ref>(new Map()); +const tableKey = ref(0); const dialog = reactive({ visible: false, @@ -204,17 +208,41 @@ const data = reactive>(initData); const { queryParams, form, rules } = toRefs>(data); -/** 查询菜单列表 */ +/** 查询部门列表 */ const getList = async () => { loading.value = true; const res = await listDept(queryParams.value); - const data = proxy?.handleTree(res.data, 'deptId'); - if (data) { - deptList.value = data; - } + tableKey.value++; + await nextTick(); + buildLazyData(res.data); loading.value = false; }; +/** 构建懒加载数据(客户端缓存,按需渲染) */ +const buildLazyData = (data: DeptVO[]) => { + const map = new Map(); + const allIds = new Set(data.map((d) => String(d.deptId))); + + for (const item of data) { + const pid = String(item.parentId); + if (!map.has(pid)) map.set(pid, []); + map.get(pid)!.push(item); + } + + for (const item of data) { + (item as any).hasChildren = map.has(String(item.deptId)); + } + + childrenMap.value = map; + deptList.value = data.filter((d) => !allIds.has(String(d.parentId))); +}; + +/** 懒加载子节点 */ +const loadChildren = (row: DeptVO, _treeNode: any, resolve: (data: DeptVO[]) => void) => { + const children = childrenMap.value.get(String(row.deptId)) || []; + resolve(children); +}; + /** 查询当前部门的所有用户 */ async function getDeptAllUser(deptId: any) { if (deptId !== null && deptId !== '' && deptId !== undefined) { @@ -244,16 +272,11 @@ const resetQuery = () => { handleQuery(); }; -/** 展开/折叠操作 */ +/** 展开/折叠操作(仅切换根节点) */ const handleToggleExpandAll = () => { isExpandAll.value = !isExpandAll.value; - toggleExpandAll(deptList.value, isExpandAll.value); -}; -/** 展开/折叠所有 */ -const toggleExpandAll = (data: DeptVO[], status: boolean) => { - data.forEach((item) => { - deptTableRef.value?.toggleRowExpansion(item, status); - if (item.children && item.children.length > 0) toggleExpandAll(item.children, status); + deptList.value.forEach((item) => { + deptTableRef.value?.toggleRowExpansion(item, isExpandAll.value); }); }; diff --git a/zdxt-web-client/zdxt-admin-plus-ui/src/views/system/dict/index-manager.vue b/zdxt-web-client/zdxt-admin-plus-ui/src/views/system/dict/index-manager.vue index 33b652f..e9310da 100644 --- a/zdxt-web-client/zdxt-admin-plus-ui/src/views/system/dict/index-manager.vue +++ b/zdxt-web-client/zdxt-admin-plus-ui/src/views/system/dict/index-manager.vue @@ -234,7 +234,7 @@ const initTypeForm: DictTypeForm = { const typeQueryParams = reactive({ pageNum: 1, - pageSize: 20, + pageSize: 18, dictName: '', dictType: '' }); @@ -366,7 +366,7 @@ const initDataForm: DictDataForm = { const dataQueryParams = reactive({ pageNum: 1, - pageSize: 20, + pageSize: 18, dictName: '', dictType: '', dictLabel: '' diff --git a/zdxt-web-client/zdxt-admin-plus-ui/src/views/system/post/index.vue b/zdxt-web-client/zdxt-admin-plus-ui/src/views/system/post/index.vue index 803cf05..d6427d6 100644 --- a/zdxt-web-client/zdxt-admin-plus-ui/src/views/system/post/index.vue +++ b/zdxt-web-client/zdxt-admin-plus-ui/src/views/system/post/index.vue @@ -3,20 +3,22 @@ - + - +
+ +
@@ -170,9 +172,10 @@