mirror of
https://gitee.com/JavaLionLi/plus-ui.git
synced 2025-10-13 21:30:28 +00:00
fix 修复菜单查询没有正确显示顶级菜单的问题
This commit is contained in:
@@ -28,7 +28,9 @@
|
|||||||
<el-button v-hasPermi="['system:menu:add']" type="primary" plain icon="Plus" @click="handleAdd()">新增 </el-button>
|
<el-button v-hasPermi="['system:menu:add']" type="primary" plain icon="Plus" @click="handleAdd()">新增 </el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button v-hasPermi="['system:menu:remove']" type="danger" plain icon="Delete" @click="handleCascadeDelete" :loading="deleteLoading">级联删除</el-button>
|
<el-button v-hasPermi="['system:menu:remove']" type="danger" plain icon="Delete" @click="handleCascadeDelete" :loading="deleteLoading"
|
||||||
|
>级联删除</el-button
|
||||||
|
>
|
||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar v-model:show-search="showSearch" @query-table="getList"></right-toolbar>
|
<right-toolbar v-model:show-search="showSearch" @query-table="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
@@ -388,12 +390,16 @@ const getList = async () => {
|
|||||||
}
|
}
|
||||||
tempMap[parentId].push(menu);
|
tempMap[parentId].push(menu);
|
||||||
}
|
}
|
||||||
|
// 创建一个当前所有 menuId 的 Set,用于查找父菜单是否存在于当前数据中
|
||||||
|
const menuIdSet = new Set();
|
||||||
// 设置有没有子菜单
|
// 设置有没有子菜单
|
||||||
for (const menu of res.data) {
|
for (const menu of res.data) {
|
||||||
menu['hasChildren'] = tempMap[menu.menuId]?.length > 0;
|
menu['hasChildren'] = tempMap[menu.menuId]?.length > 0;
|
||||||
|
menuIdSet.add(menu.menuId);
|
||||||
}
|
}
|
||||||
menuChildrenListMap.value = tempMap;
|
menuChildrenListMap.value = tempMap;
|
||||||
menuList.value = tempMap[0] || [];
|
// 找出所有父ID不在当前菜单ID集合中的菜单项,作为新的顶层菜单
|
||||||
|
menuList.value = res.data.filter((menu) => !menuIdSet.has(menu.parentId));
|
||||||
// 根据新数据重新加载子菜单数据
|
// 根据新数据重新加载子菜单数据
|
||||||
refreshAllExpandMenuData();
|
refreshAllExpandMenuData();
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
|
Reference in New Issue
Block a user