feat(system): 添加字典和菜单缓存清除功能

- 在字典管理页面添加清除缓存按钮,用于清除单个字典的缓存
- 在菜单管理页面添加清除缓存按钮,用于清除全部菜单缓存
- 新增清除字典缓存和菜单缓存的 API 接口
- 优化字典树组件,增加选中字典的信息传递
This commit is contained in:
2025-03-12 22:12:30 +08:00
parent 9f5845e3b3
commit 13a7262172
5 changed files with 81 additions and 23 deletions

View File

@@ -1,10 +1,5 @@
<template>
<div class="gi_page">
<!-- <a-row justify="space-between" align="center" class="header page_header">
<a-space wrap>
<div class="title">字典管理</div>
</a-space>
</a-row> -->
<SplitPanel>
<template #left>
<DictTree @node-click="handleSelectDict" />
@@ -35,6 +30,10 @@
<template #icon><icon-plus /></template>
<template #default>新增</template>
</a-button>
<a-button v-permission="['system:dict:item:clearCache']" type="outline" status="warning" @click="onClearCache">
<template #icon><icon-delete /></template>
<template #default>清除缓存</template>
</a-button>
</template>
<template #label="{ record }">
<a-tag :color="record.color">{{ record.label }}</a-tag>
@@ -66,9 +65,10 @@
</template>
<script setup lang="ts">
import { Message, Modal } from '@arco-design/web-vue'
import DictTree from './tree/index.vue'
import DictItemAddModal from './DictItemAddModal.vue'
import { type DictItemQuery, type DictItemResp, deleteDictItem, listDictItem } from '@/apis/system/dict'
import { type DictItemQuery, type DictItemResp, clearDictCache, deleteDictItem, listDictItem } from '@/apis/system/dict'
import type { TableInstanceColumns } from '@/components/GiTable/type'
import { useTable } from '@/hooks'
import { isMobile } from '@/utils'
@@ -137,9 +137,30 @@ const onDelete = (record: DictItemResp) => {
})
}
const dictName = ref()
const dictCode = ref()
// 清除缓存
const onClearCache = () => {
if (!dictCode.value) {
return Message.warning('请先选择字典')
}
Modal.warning({
title: '提示',
content: `是否确定清除字典「${dictName.value}(${dictCode.value})」缓存?`,
hideCancel: false,
maskClosable: false,
onOk: async () => {
await clearDictCache(dictCode.value)
Message.success('清除成功')
},
})
}
// 根据选中字典查询
const handleSelectDict = (keys: Array<any>) => {
queryForm.dictId = keys.length === 1 ? keys[0] : undefined
const handleSelectDict = (dict: { dictId: string, dictName: string, dictCode: string }) => {
queryForm.dictId = dict.dictId
dictName.value = dict.dictName
dictCode.value = dict.dictCode
search()
}