From 2939c2e4f592969dcf3c269ba38f0714165e699d Mon Sep 17 00:00:00 2001 From: puhui999 Date: Sun, 15 Jun 2025 17:52:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E3=80=90antd=E3=80=91=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=89=B9=E9=87=8F=E5=88=A0=E9=99=A4=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/system/sms/channel/data.ts | 1 + .../src/views/system/sms/channel/index.vue | 57 ++++++++++++++++++- 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/apps/web-antd/src/views/system/sms/channel/data.ts b/apps/web-antd/src/views/system/sms/channel/data.ts index 18efe62f0..f00ea26d5 100644 --- a/apps/web-antd/src/views/system/sms/channel/data.ts +++ b/apps/web-antd/src/views/system/sms/channel/data.ts @@ -132,6 +132,7 @@ export function useGridFormSchema(): VbenFormSchema[] { /** 列表的字段 */ export function useGridColumns(): VxeTableGridOptions['columns'] { return [ + { type: 'checkbox', width: 40 }, { field: 'id', title: '编号', diff --git a/apps/web-antd/src/views/system/sms/channel/index.vue b/apps/web-antd/src/views/system/sms/channel/index.vue index bb9cbcfcf..f172f155f 100644 --- a/apps/web-antd/src/views/system/sms/channel/index.vue +++ b/apps/web-antd/src/views/system/sms/channel/index.vue @@ -2,14 +2,17 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import type { SystemSmsChannelApi } from '#/api/system/sms/channel'; +import { ref } from 'vue'; + import { DocAlert, Page, useVbenModal } from '@vben/common-ui'; -import { downloadFileFromBlobPart } from '@vben/utils'; +import { downloadFileFromBlobPart, isEmpty } from '@vben/utils'; import { message } from 'ant-design-vue'; import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; import { deleteSmsChannel, + deleteSmsChannelList, exportSmsChannel, getSmsChannelPage, } from '#/api/system/sms/channel'; @@ -62,6 +65,39 @@ async function handleDelete(row: SystemSmsChannelApi.SmsChannel) { } } +// 选中的短信渠道ID +const checkedIds = ref([]); +function handleRowCheckboxChange({ + records, +}: { + records: SystemSmsChannelApi.SmsChannel[]; +}) { + checkedIds.value = records.map((item) => item.id as number); +} + +/** 批量删除处理 */ +async function handleDeleteBatch() { + if (checkedIds.value.length === 0) { + message.warning('请至少选择一条数据'); + return; + } + const hideLoading = message.loading({ + content: $t('ui.actionMessage.deleting', ['短信渠道']), + key: 'action_key_msg', + }); + try { + await deleteSmsChannelList(checkedIds.value); + message.success({ + content: $t('ui.actionMessage.deleteSuccess', ['短信渠道']), + key: 'action_key_msg', + }); + checkedIds.value = []; + onRefresh(); + } finally { + hideLoading(); + } +} + const [Grid, gridApi] = useVbenVxeGrid({ formOptions: { schema: useGridFormSchema(), @@ -83,12 +119,20 @@ const [Grid, gridApi] = useVbenVxeGrid({ }, rowConfig: { keyField: 'id', + isHover: true, }, toolbarConfig: { refresh: { code: 'query' }, search: true, }, + checkboxConfig: { + checkField: 'checked', + }, } as VxeTableGridOptions, + gridEvents: { + checkboxAll: handleRowCheckboxChange, + checkboxChange: handleRowCheckboxChange, + }, }); @@ -117,6 +161,15 @@ const [Grid, gridApi] = useVbenVxeGrid({ auth: ['system:sms-channel:export'], onClick: handleExport, }, + { + label: '批量删除', + type: 'primary', + danger: true, + disabled: isEmpty(checkedIds), + icon: ACTION_ICON.DELETE, + auth: ['system:sms-channel:delete'], + onClick: handleDeleteBatch, + }, ]" /> @@ -137,7 +190,7 @@ const [Grid, gridApi] = useVbenVxeGrid({ icon: ACTION_ICON.DELETE, auth: ['system:sms-channel:delete'], popConfirm: { - title: $t('ui.actionMessage.deleteConfirm', [row.name]), + title: $t('ui.actionMessage.deleteConfirm', [row.signature]), confirm: handleDelete.bind(null, row), }, },