diff --git a/apps/web-antd/src/views/system/dict/type/index-refactor.vue b/apps/web-antd/src/views/system/dict/type/index-refactor.vue index 3f9c128c..1b1229e0 100644 --- a/apps/web-antd/src/views/system/dict/type/index-refactor.vue +++ b/apps/web-antd/src/views/system/dict/type/index-refactor.vue @@ -9,20 +9,50 @@ import { cn } from '@vben/utils'; import { DeleteOutlined, EditOutlined, + ExportOutlined, PlusOutlined, + SyncOutlined, } from '@ant-design/icons-vue'; -import { Card, Empty, Input, Popconfirm, Space } from 'ant-design-vue'; +import { + Empty, + Input, + Modal, + Popconfirm, + Space, + Spin, + Tooltip, +} from 'ant-design-vue'; -import { dictTypeList, dictTypeRemove } from '#/api/system/dict/dict-type'; +import { + dictTypeExport, + dictTypeList, + dictTypeRemove, + refreshDictTypeCache, +} from '#/api/system/dict/dict-type'; +import { commonDownloadExcel } from '#/utils/file/download'; import { emitter } from '../mitt'; import dictTypeModal from './dict-type-modal.vue'; const dictList = ref([]); -onMounted(async () => { +const loading = ref(false); + +async function loadData(reset = false) { + loading.value = true; + + if (reset) { + currentRowId.value = ''; + emitter.emit('rowClick', ''); + searchValue.value = ''; + } + const resp = await dictTypeList(); dictList.value = resp.rows; -}); + + loading.value = false; +} + +onMounted(loadData); const [DictTypeModal, modalApi] = useVbenModal({ connectedComponent: dictTypeModal, @@ -43,6 +73,24 @@ async function handleDelete(row: DictType) { // TODO: 刷新表格 } +function handleDownloadExcel() { + commonDownloadExcel(dictTypeExport, '字典类型数据'); +} + +function handleRefreshCache() { + Modal.confirm({ + title: '提示', + content: '确认刷新字典类型缓存吗?', + okButtonProps: { + danger: true, + }, + onOk: async () => { + await refreshDictTypeCache(); + // TODO: 刷新表格 + }, + }); +} + const currentRowId = ref(null); function handleRowClick(row: DictType) { currentRowId.value = row.dictId; @@ -54,63 +102,105 @@ const searchResultList = computed(() => { if (!searchValue.value) { return dictList.value; } - return dictList.value.filter((item) => + const names = dictList.value.filter((item) => item.dictName.includes(searchValue.value), ); + const types = dictList.value.filter((item) => + item.dictType.includes(searchValue.value), + ); + return [...new Set([...names, ...types])]; }); + +const emptyImage = Empty.PRESENTED_IMAGE_SIMPLE; - -