菜单管理:添加刷新菜单缓存按钮,提高易用性

This commit is contained in:
puhui999 2023-04-20 14:17:21 +08:00
parent 917a2441ef
commit ab52f8b18f

View File

@ -5,27 +5,27 @@
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<ContentWrap> <ContentWrap>
<el-form <el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef" ref="queryFormRef"
:inline="true" :inline="true"
:model="queryParams"
class="-mb-15px"
label-width="68px" label-width="68px"
> >
<el-form-item label="菜单名称" prop="name"> <el-form-item label="菜单名称" prop="name">
<el-input <el-input
v-model="queryParams.name" v-model="queryParams.name"
placeholder="请输入菜单名称"
clearable
@keyup.enter="handleQuery"
class="!w-240px" class="!w-240px"
clearable
placeholder="请输入菜单名称"
@keyup.enter="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="状态" prop="status"> <el-form-item label="状态" prop="status">
<el-select <el-select
v-model="queryParams.status" v-model="queryParams.status"
placeholder="请选择菜单状态"
clearable
class="!w-240px" class="!w-240px"
clearable
placeholder="请选择菜单状态"
> >
<el-option <el-option
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)" v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
@ -36,18 +36,30 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button> <el-button @click="handleQuery">
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button> <Icon class="mr-5px" icon="ep:search" />
<el-button 搜索
type="primary"
plain
@click="openForm('create')"
v-hasPermi="['system:menu:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button> </el-button>
<el-button type="danger" plain @click="toggleExpandAll"> <el-button @click="resetQuery">
<Icon icon="ep:sort" class="mr-5px" /> 展开/折叠 <Icon class="mr-5px" icon="ep:refresh" />
重置
</el-button>
<el-button
v-hasPermi="['system:menu:create']"
plain
type="primary"
@click="openForm('create')"
>
<Icon class="mr-5px" icon="ep:plus" />
新增
</el-button>
<el-button plain type="danger" @click="toggleExpandAll">
<Icon class="mr-5px" icon="ep:sort" />
展开/折叠
</el-button>
<el-button plain @click="refreshMenu">
<Icon class="mr-5px" icon="ep:refresh" />
刷新菜单缓存
</el-button> </el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -56,50 +68,50 @@
<!-- 列表 --> <!-- 列表 -->
<ContentWrap> <ContentWrap>
<el-table <el-table
v-if="refreshTable"
v-loading="loading" v-loading="loading"
:data="list" :data="list"
row-key="id"
v-if="refreshTable"
:default-expand-all="isExpandAll" :default-expand-all="isExpandAll"
row-key="id"
> >
<el-table-column prop="name" label="菜单名称" :show-overflow-tooltip="true" width="250" /> <el-table-column :show-overflow-tooltip="true" label="菜单名称" prop="name" width="250" />
<el-table-column prop="icon" label="图标" align="center" width="100"> <el-table-column align="center" label="图标" prop="icon" width="100">
<template #default="scope"> <template #default="scope">
<Icon :icon="scope.row.icon" /> <Icon :icon="scope.row.icon" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="sort" label="排序" width="60" /> <el-table-column label="排序" prop="sort" width="60" />
<el-table-column prop="permission" label="权限标识" :show-overflow-tooltip="true" /> <el-table-column :show-overflow-tooltip="true" label="权限标识" prop="permission" />
<el-table-column prop="component" label="组件路径" :show-overflow-tooltip="true" /> <el-table-column :show-overflow-tooltip="true" label="组件路径" prop="component" />
<el-table-column prop="componentName" label="组件名称" :show-overflow-tooltip="true" /> <el-table-column :show-overflow-tooltip="true" label="组件名称" prop="componentName" />
<el-table-column prop="status" label="状态" width="80"> <el-table-column label="状态" prop="status" width="80">
<template #default="scope"> <template #default="scope">
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" /> <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center"> <el-table-column align="center" label="操作">
<template #default="scope"> <template #default="scope">
<el-button <el-button
v-hasPermi="['system:menu:update']"
link link
type="primary" type="primary"
@click="openForm('update', scope.row.id)" @click="openForm('update', scope.row.id)"
v-hasPermi="['system:menu:update']"
> >
修改 修改
</el-button> </el-button>
<el-button <el-button
v-hasPermi="['system:menu:create']"
link link
type="primary" type="primary"
@click="openForm('create', undefined, scope.row.id)" @click="openForm('create', undefined, scope.row.id)"
v-hasPermi="['system:menu:create']"
> >
新增 新增
</el-button> </el-button>
<el-button <el-button
v-hasPermi="['system:menu:delete']"
link link
type="danger" type="danger"
@click="handleDelete(scope.row.id)" @click="handleDelete(scope.row.id)"
v-hasPermi="['system:menu:delete']"
> >
删除 删除
</el-button> </el-button>
@ -111,11 +123,14 @@
<!-- 表单弹窗添加/修改 --> <!-- 表单弹窗添加/修改 -->
<MenuForm ref="formRef" @success="getList" /> <MenuForm ref="formRef" @success="getList" />
</template> </template>
<script setup lang="ts" name="SystemMenu"> <script lang="ts" name="SystemMenu" setup>
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { handleTree } from '@/utils/tree' import { handleTree } from '@/utils/tree'
import * as MenuApi from '@/api/system/menu' import * as MenuApi from '@/api/system/menu'
import MenuForm from './MenuForm.vue' import MenuForm from './MenuForm.vue'
import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
const { wsCache } = useCache()
const { t } = useI18n() // const { t } = useI18n() //
const message = useMessage() // const message = useMessage() //
@ -165,7 +180,19 @@ const toggleExpandAll = () => {
refreshTable.value = true refreshTable.value = true
}) })
} }
/** 刷新菜单缓存按钮操作 */
const refreshMenu = () => {
ElMessageBox.confirm('即将更新缓存刷新浏览器!', '刷新菜单缓存', {
confirmButtonText: t('common.ok'),
cancelButtonText: t('common.cancel'),
type: 'warning'
}).then(() => {
//
wsCache.delete(CACHE_KEY.ROLE_ROUTERS)
//
location.reload()
})
}
/** 删除按钮操作 */ /** 删除按钮操作 */
const handleDelete = async (id: number) => { const handleDelete = async (id: number) => {
try { try {