feat(menu): 添加菜单缓存刷新功能和拖拽排序支持
- 在SysMenuController中添加refreshCache和refreshCurrentUserMenuCache接口 - 实现菜单缓存的按需刷新和用户级别缓存清理功能 - 优化菜单列表查询的缓存key策略,支持更精确的缓存命中 - 为菜单树查询添加缓存注解提升性能 - 在菜单增删改操作中完善缓存清理逻辑 - 添加allocateMenuToRole方法实现菜单角色分配功能 - 在前端DictTag组件中修复标签类型验证逻辑 - 为首页配置页面添加拖拽排序功能,支持快捷功能重新排列 - 集成Sortable.js实现拖拽交互和排序保存 - 优化菜单管理页面的缓存刷新机制和数据展示 - 完善配置更新事件处理,支持实时配置同步
This commit is contained in:
@@ -54,7 +54,7 @@
|
||||
@click="toggleExpandAll"
|
||||
>展开/折叠</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="handleRefresh"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table
|
||||
@@ -95,12 +95,12 @@
|
||||
<el-table-column prop="component" label="组件路径" :show-overflow-tooltip="true"></el-table-column>
|
||||
<el-table-column prop="status" label="状态" width="80">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="sys_normal_disable" :value="scope.row.status" class="dict-tag" />
|
||||
<dict-tag :options="processedSysNormalDisable" :value="scope.row.status" class="dict-tag" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="visible" label="显示状态" width="100">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="sys_show_hide" :value="scope.row.visible" class="dict-tag" />
|
||||
<dict-tag :options="processedSysShowHide" :value="scope.row.visible" class="dict-tag" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建时间" align="center" width="160" prop="createTime">
|
||||
@@ -321,7 +321,7 @@
|
||||
</style>
|
||||
|
||||
<script setup name="Menu">
|
||||
import {addMenu, delMenu, getMenu, listMenu, updateMenu, treeselect} from "@/api/system/menu";
|
||||
import {addMenu, delMenu, getMenu, listMenu, updateMenu, treeselect, refreshMenuCache} from "@/api/system/menu";
|
||||
import SvgIcon from "@/components/SvgIcon";
|
||||
import IconSelect from "@/components/IconSelect";
|
||||
import {getNormalPath} from "@/utils/openhis";
|
||||
@@ -329,6 +329,21 @@ import {getNormalPath} from "@/utils/openhis";
|
||||
const { proxy } = getCurrentInstance();
|
||||
const { sys_show_hide, sys_normal_disable } = proxy.useDict("sys_show_hide", "sys_normal_disable");
|
||||
|
||||
// 处理字典数据,确保elTagType字段不为null
|
||||
const processedSysShowHide = computed(() => {
|
||||
return sys_show_hide.value.map(item => ({
|
||||
...item,
|
||||
elTagType: item.elTagType || '' // 如果elTagType为null或undefined,则设为空字符串
|
||||
}));
|
||||
});
|
||||
|
||||
const processedSysNormalDisable = computed(() => {
|
||||
return sys_normal_disable.value.map(item => ({
|
||||
...item,
|
||||
elTagType: item.elTagType || '' // 如果elTagType为null或undefined,则设为空字符串
|
||||
}));
|
||||
});
|
||||
|
||||
const menuList = ref([]);
|
||||
const open = ref(false);
|
||||
const loading = ref(true);
|
||||
@@ -367,6 +382,20 @@ async function getList() {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 刷新缓存并重新获取菜单列表 */
|
||||
async function handleRefresh() {
|
||||
try {
|
||||
// 首先调用后端接口刷新缓存
|
||||
await refreshMenuCache();
|
||||
// 然后重新获取菜单列表
|
||||
await getList();
|
||||
proxy.$modal.msgSuccess("菜单缓存已刷新,列表已更新");
|
||||
} catch (error) {
|
||||
console.error('刷新菜单缓存失败:', error);
|
||||
proxy.$modal.msgError("刷新菜单缓存失败");
|
||||
}
|
||||
}
|
||||
/** 查询菜单下拉树结构 */
|
||||
function getTreeselect() {
|
||||
menuOptions.value = [];
|
||||
@@ -494,7 +523,10 @@ function submitForm() {
|
||||
} else {
|
||||
proxy.$modal.msgSuccess("新增成功");
|
||||
open.value = false;
|
||||
getList();
|
||||
// 新增菜单后,刷新缓存并重新获取列表
|
||||
refreshMenuCache().finally(() => {
|
||||
getList();
|
||||
});
|
||||
}
|
||||
}).catch(() => {
|
||||
// 可以在这里添加自定义的错误处理,或者使用默认的错误提示
|
||||
|
||||
Reference in New Issue
Block a user