From 720c822bb3a63cd7c0c970d60756f58c63f811b3 Mon Sep 17 00:00:00 2001
From: lau <1807121535@qq.com>
Date: Sun, 22 Jun 2025 21:25:05 +0800
Subject: [PATCH 1/2] =?UTF-8?q?update:=20=E4=BC=98=E5=8C=96=E8=8F=9C?=
=?UTF-8?q?=E5=8D=95=E9=A1=B5=E9=9D=A2=E6=B8=B2=E6=9F=93=E6=96=B9=E5=BC=8F?=
=?UTF-8?q?=E9=81=BF=E5=85=8D=E9=95=BF=E6=97=B6=E9=97=B4=E5=8D=A1=E4=BD=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/system/menu/index.vue | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
diff --git a/src/views/system/menu/index.vue b/src/views/system/menu/index.vue
index 67d3c193..273757fa 100644
--- a/src/views/system/menu/index.vue
+++ b/src/views/system/menu/index.vue
@@ -45,6 +45,8 @@
border
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
:default-expand-all="isExpandAll"
+ lazy
+ :load="getChildrenList"
>
@@ -299,6 +301,7 @@ const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { sys_show_hide, sys_normal_disable } = toRefs(proxy?.useDict('sys_show_hide', 'sys_normal_disable'));
const menuList = ref([]);
+const menuChildrenListMap = ref({});
const loading = ref(true);
const showSearch = ref(true);
const menuOptions = ref([]);
@@ -340,14 +343,34 @@ const data = reactive>({
const menuTableRef = ref();
const { queryParams, form, rules } = toRefs>(data);
+
+/** 获取子菜单列表 */
+const getChildrenList = async (row: any, treeNode: unknown, resolve: (data: any[]) => void) => {
+ loading.value = true;
+ resolve(menuChildrenListMap.value[row.menuId] || []);
+ loading.value = false;
+};
+
/** 查询菜单列表 */
const getList = async () => {
loading.value = true;
const res = await listMenu(queryParams.value);
- const data = proxy?.handleTree(res.data, 'menuId');
- if (data) {
- menuList.value = data;
+
+ const tempMap = {};
+ // 存储 父菜单:子菜单列表
+ for (const menu of res.data) {
+ const parentId = menu.parentId;
+ if (!tempMap[parentId]) {
+ tempMap[parentId] = [];
+ }
+ tempMap[parentId].push(menu);
+ }
+ // 设置有没有子菜单
+ for (const menu of res.data) {
+ menu['hasChildren'] = tempMap[menu.menuId]?.length > 0;
}
+ menuChildrenListMap.value = tempMap;
+ menuList.value = tempMap[0] || [];
loading.value = false;
};
/** 查询菜单下拉树结构 */
--
Gitee
From 2f35342782f8c0c83763cd0bf2d31cee0e88f507 Mon Sep 17 00:00:00 2001
From: lau <1807121535@qq.com>
Date: Mon, 23 Jun 2025 16:11:58 +0800
Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=8F=9C=E5=8D=95?=
=?UTF-8?q?=E7=AE=A1=E7=90=86=E6=94=B9=E4=B8=BA=E6=87=92=E5=8A=A0=E8=BD=BD?=
=?UTF-8?q?=E5=90=8E=E5=B1=95=E5=BC=80/=E6=8A=98=E5=8F=A0=E5=8F=AA?=
=?UTF-8?q?=E8=83=BD=E5=B1=95=E5=BC=80=E4=B8=80=E7=BA=A7=E8=8F=9C=E5=8D=95?=
=?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/system/menu/index.vue | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/views/system/menu/index.vue b/src/views/system/menu/index.vue
index 273757fa..5b50eb18 100644
--- a/src/views/system/menu/index.vue
+++ b/src/views/system/menu/index.vue
@@ -346,9 +346,7 @@ const { queryParams, form, rules } = toRefs>(data)
/** 获取子菜单列表 */
const getChildrenList = async (row: any, treeNode: unknown, resolve: (data: any[]) => void) => {
- loading.value = true;
resolve(menuChildrenListMap.value[row.menuId] || []);
- loading.value = false;
};
/** 查询菜单列表 */
@@ -416,7 +414,14 @@ const handleToggleExpandAll = () => {
};
/** 展开/折叠所有 */
const toggleExpandAll = (data: MenuVO[], status: boolean) => {
- data.forEach((item: MenuVO) => {
+ data.forEach(async (item: MenuVO) => {
+ const menuChildrenList = menuChildrenListMap.value[item.menuId];
+ // 从menuChildrenListMap中获取子菜单列表
+ if (menuChildrenList && (!item.children || item.children.length === 0)) {
+ item.children = menuChildrenList || [];
+ // 等待子菜单列表加载完成
+ await nextTick();
+ }
menuTableRef.value?.toggleRowExpansion(item, status);
if (item.children && item.children.length > 0) toggleExpandAll(item.children, status);
});
--
Gitee