diff --git a/apps/web-antd/src/views/infra/file/data.ts b/apps/web-antd/src/views/infra/file/data.ts index cc124a0f..56d58313 100644 --- a/apps/web-antd/src/views/infra/file/data.ts +++ b/apps/web-antd/src/views/infra/file/data.ts @@ -27,7 +27,7 @@ export function useGridFormSchema(): VbenFormSchema[] { component: 'Input', componentProps: { placeholder: '请输入文件路径', - allowClear: true, + clearable: true, }, }, { @@ -36,7 +36,7 @@ export function useGridFormSchema(): VbenFormSchema[] { component: 'Input', componentProps: { placeholder: '请输入文件类型', - allowClear: true, + clearable: true, }, }, { @@ -45,7 +45,7 @@ export function useGridFormSchema(): VbenFormSchema[] { component: 'RangePicker', componentProps: { ...getRangePickerDefaultProps(), - allowClear: true, + clearable: true, }, }, ]; @@ -58,22 +58,26 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'name', title: '文件名', + minWidth: 150, }, { field: 'path', title: '文件路径', + minWidth: 200, showOverflow: true, }, { field: 'url', title: 'URL', + minWidth: 200, showOverflow: true, }, { field: 'size', title: '文件大小', + minWidth: 80, formatter: ({ cellValue }) => { - // TODO @芋艿:后续优化下 + // TODO @xingyu:【优先级:中】要不要搞到一个方法里? if (!cellValue) return '0 B'; const unitArr = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; const index = Math.floor(Math.log(cellValue) / Math.log(1024)); @@ -85,15 +89,20 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'type', title: '文件类型', + minWidth: 120, }, { field: 'file-content', title: '文件内容', - slots: { default: 'file-content' }, + minWidth: 120, + slots: { + default: 'file-content', + }, }, { field: 'createTime', title: '上传时间', + minWidth: 180, formatter: 'formatDateTime', }, { diff --git a/apps/web-antd/src/views/infra/file/index.vue b/apps/web-antd/src/views/infra/file/index.vue index 8c8b9072..182282cf 100644 --- a/apps/web-antd/src/views/infra/file/index.vue +++ b/apps/web-antd/src/views/infra/file/index.vue @@ -4,7 +4,7 @@ import type { InfraFileApi } from '#/api/infra/file'; import { ref } from 'vue'; -import { Page, useVbenModal } from '@vben/common-ui'; +import { confirm, Page, useVbenModal } from '@vben/common-ui'; import { isEmpty, openWindow } from '@vben/utils'; import { useClipboard } from '@vueuse/core'; @@ -23,7 +23,7 @@ const [FormModal, formModalApi] = useVbenModal({ }); /** 刷新表格 */ -function onRefresh() { +function handleRefresh() { gridApi.query(); } @@ -53,14 +53,30 @@ async function handleDelete(row: InfraFileApi.File) { const hideLoading = message.loading({ content: $t('ui.actionMessage.deleting', [row.name || row.path]), duration: 0, - key: 'action_process_msg', }); try { await deleteFile(row.id as number); message.success( $t('ui.actionMessage.deleteSuccess', [row.name || row.path]), ); - onRefresh(); + handleRefresh(); + } finally { + hideLoading(); + } +} + +/** 批量删除文件 */ +async function handleDeleteBatch() { + await confirm($t('ui.actionMessage.deleteBatchConfirm')); + const hideLoading = message.loading({ + content: $t('ui.actionMessage.deletingBatch'), + duration: 0, + }); + try { + await deleteFileList(checkedIds.value); + checkedIds.value = []; + message.success($t('ui.actionMessage.deleteSuccess')); + handleRefresh(); } finally { hideLoading(); } @@ -75,23 +91,6 @@ function handleRowCheckboxChange({ checkedIds.value = records.map((item) => item.id!); } -/** 批量删除文件 */ -async function handleDeleteBatch() { - const hideLoading = message.loading({ - content: $t('ui.actionMessage.deleting'), - duration: 0, - key: 'action_process_msg', - }); - try { - await deleteFileList(checkedIds.value); - checkedIds.value = []; - message.success($t('ui.actionMessage.deleteSuccess')); - onRefresh(); - } finally { - hideLoading(); - } -} - const [Grid, gridApi] = useVbenVxeGrid({ formOptions: { schema: useGridFormSchema(), @@ -129,24 +128,23 @@ const [Grid, gridApi] = useVbenVxeGrid({