From 2569e1da0d67683176d186dcedfa3c0968d5c3e4 Mon Sep 17 00:00:00 2001 From: dap <15891557205@163.com> Date: Tue, 27 May 2025 14:27:01 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=AD=97=E5=85=B8=E9=A1=B9?= =?UTF-8?q?=E5=B8=83=E5=B1=80=E9=87=8D=E6=9E=84(=E6=9C=AA=E5=AE=8C?= =?UTF-8?q?=E6=88=90)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/system/dict/type/index-refactor.vue | 196 +++++++++++++----- 1 file changed, 143 insertions(+), 53 deletions(-) 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; - -