From a153a861427e361cfb552a17b62abe1a8f26be99 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 4 Sep 2025 21:31:24 +0800 Subject: [PATCH 1/2] =?UTF-8?q?reactor=EF=BC=9A=E3=80=90system=20=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E7=AE=A1=E7=90=86=E3=80=91notice=20=E5=9C=A8=20ele=20?= =?UTF-8?q?=E5=92=8C=20antd=20=E7=9A=84=E4=BB=A3=E7=A0=81=E4=B8=80?= =?UTF-8?q?=E8=87=B4=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/src/views/system/notice/data.ts | 5 + .../src/views/system/notice/index.vue | 27 ++--- apps/web-ele/src/views/system/notice/data.ts | 44 +------- .../web-ele/src/views/system/notice/index.vue | 105 ++++++++++-------- packages/locales/src/langs/en-US/ui.json | 2 + packages/locales/src/langs/zh-CN/ui.json | 2 + 6 files changed, 82 insertions(+), 103 deletions(-) diff --git a/apps/web-antd/src/views/system/notice/data.ts b/apps/web-antd/src/views/system/notice/data.ts index c00fb0d55..0bc86bb86 100644 --- a/apps/web-antd/src/views/system/notice/data.ts +++ b/apps/web-antd/src/views/system/notice/data.ts @@ -92,14 +92,17 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'id', title: '公告编号', + minWidth: 100, }, { field: 'title', title: '公告标题', + minWidth: 200, }, { field: 'type', title: '公告类型', + minWidth: 100, cellRender: { name: 'CellDict', props: { type: DICT_TYPE.SYSTEM_NOTICE_TYPE }, @@ -108,6 +111,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'status', title: '公告状态', + minWidth: 100, cellRender: { name: 'CellDict', props: { type: DICT_TYPE.COMMON_STATUS }, @@ -116,6 +120,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'createTime', title: '创建时间', + minWidth: 180, formatter: 'formatDateTime', }, { diff --git a/apps/web-antd/src/views/system/notice/index.vue b/apps/web-antd/src/views/system/notice/index.vue index 7e4ec29d7..472dd190f 100644 --- a/apps/web-antd/src/views/system/notice/index.vue +++ b/apps/web-antd/src/views/system/notice/index.vue @@ -4,7 +4,7 @@ import type { SystemNoticeApi } from '#/api/system/notice'; import { ref } from 'vue'; -import { Page, useVbenModal } from '@vben/common-ui'; +import { confirm, Page, useVbenModal } from '@vben/common-ui'; import { isEmpty } from '@vben/utils'; import { message } from 'ant-design-vue'; @@ -45,14 +45,11 @@ function handleEdit(row: SystemNoticeApi.Notice) { async function handleDelete(row: SystemNoticeApi.Notice) { const hideLoading = message.loading({ content: $t('ui.actionMessage.deleting', [row.title]), - key: 'action_key_msg', + duration: 0, }); try { await deleteNotice(row.id as number); - message.success({ - content: $t('ui.actionMessage.deleteSuccess', [row.title]), - key: 'action_key_msg', - }); + message.success($t('ui.actionMessage.deleteSuccess', [row.title])); onRefresh(); } finally { hideLoading(); @@ -61,10 +58,10 @@ async function handleDelete(row: SystemNoticeApi.Notice) { /** 批量删除公告 */ async function handleDeleteBatch() { + await confirm($t('ui.actionMessage.deleteBatchConfirm')); const hideLoading = message.loading({ - content: $t('ui.actionMessage.deleting'), + content: $t('ui.actionMessage.deletingBatch'), duration: 0, - key: 'action_process_msg', }); try { await deleteNoticeList(checkedIds.value); @@ -82,21 +79,17 @@ function handleRowCheckboxChange({ }: { records: SystemNoticeApi.Notice[]; }) { - checkedIds.value = records.map((item) => item.id as number); + checkedIds.value = records.map((item) => item.id!); } /** 推送公告 */ async function handlePush(row: SystemNoticeApi.Notice) { const hideLoading = message.loading({ - content: '正在推送中', - key: 'action_process_msg', + content: '正在推送中...', }); try { await pushNotice(row.id as number); - message.success({ - content: $t('ui.actionMessage.operationSuccess'), - key: 'action_key_msg', - }); + message.success($t('ui.actionMessage.operationSuccess')); } finally { hideLoading(); } @@ -152,12 +145,12 @@ const [Grid, gridApi] = useVbenVxeGrid({ onClick: handleCreate, }, { - label: '批量删除', + label: $t('ui.actionTitle.deleteBatch'), type: 'primary', danger: true, - disabled: isEmpty(checkedIds), icon: ACTION_ICON.DELETE, auth: ['system:notice:delete'], + disabled: isEmpty(checkedIds), onClick: handleDeleteBatch, }, ]" diff --git a/apps/web-ele/src/views/system/notice/data.ts b/apps/web-ele/src/views/system/notice/data.ts index 8b74f2380..0bc86bb86 100644 --- a/apps/web-ele/src/views/system/notice/data.ts +++ b/apps/web-ele/src/views/system/notice/data.ts @@ -1,14 +1,9 @@ import type { VbenFormSchema } from '#/adapter/form'; -import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table'; -import type { SystemNoticeApi } from '#/api/system/notice'; - -import { useAccess } from '@vben/access'; +import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import { z } from '#/adapter/form'; import { CommonStatusEnum, DICT_TYPE, getDictOptions } from '#/utils'; -const { hasAccessByCodes } = useAccess(); - /** 新增/修改的表单 */ export function useFormSchema(): VbenFormSchema[] { return [ @@ -91,14 +86,9 @@ export function useGridFormSchema(): VbenFormSchema[] { } /** 列表的字段 */ -export function useGridColumns( - onActionClick: OnActionClickFn, -): VxeTableGridOptions['columns'] { +export function useGridColumns(): VxeTableGridOptions['columns'] { return [ - { - type: 'checkbox', - width: 40, - }, + { type: 'checkbox', width: 40 }, { field: 'id', title: '公告编号', @@ -134,34 +124,10 @@ export function useGridColumns( formatter: 'formatDateTime', }, { - field: 'operation', title: '操作', - minWidth: 180, - align: 'center', + width: 220, fixed: 'right', - cellRender: { - attrs: { - nameField: 'title', - nameTitle: '公告', - onClick: onActionClick, - }, - name: 'CellOperation', - options: [ - { - code: 'edit', - show: hasAccessByCodes(['system:notice:update']), - }, - { - code: 'push', - text: '推送', - show: hasAccessByCodes(['system:notice:update']), - }, - { - code: 'delete', - show: hasAccessByCodes(['system:notice:delete']), - }, - ], - }, + slots: { default: 'actions' }, }, ]; } diff --git a/apps/web-ele/src/views/system/notice/index.vue b/apps/web-ele/src/views/system/notice/index.vue index c34e8f757..fd8fa21a4 100644 --- a/apps/web-ele/src/views/system/notice/index.vue +++ b/apps/web-ele/src/views/system/notice/index.vue @@ -1,8 +1,5 @@