reactor:【system 系统管理】sms/channel 进一步统一代码风格

This commit is contained in:
YunaiV
2025-09-06 17:18:17 +08:00
parent 965ccdbea1
commit 15359ab9a3
6 changed files with 106 additions and 153 deletions

View File

@@ -48,6 +48,14 @@ export function useFormSchema(): VbenFormSchema[] {
},
rules: z.number().default(CommonStatusEnum.ENABLE),
},
{
fieldName: 'remark',
label: '备注',
component: 'Textarea',
componentProps: {
placeholder: '请输入备注',
},
},
{
fieldName: 'apiKey',
label: '短信 API 的账号',
@@ -73,14 +81,6 @@ export function useFormSchema(): VbenFormSchema[] {
placeholder: '请输入短信发送回调 URL',
},
},
{
fieldName: 'remark',
label: '备注',
component: 'Textarea',
componentProps: {
placeholder: '请输入备注',
},
},
];
}
@@ -134,14 +134,17 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{
field: 'id',
title: '编号',
minWidth: 100,
},
{
field: 'signature',
title: '短信签名',
minWidth: 120,
},
{
field: 'code',
title: '渠道编码',
minWidth: 120,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE },
@@ -150,6 +153,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{
field: 'status',
title: '启用状态',
minWidth: 100,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.COMMON_STATUS },
@@ -158,27 +162,32 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{
field: 'apiKey',
title: '短信 API 的账号',
minWidth: 180,
},
{
field: 'apiSecret',
title: '短信 API 的密钥',
minWidth: 180,
},
{
field: 'callbackUrl',
title: '短信发送回调 URL',
minWidth: 180,
},
{
field: 'createTime',
title: '创建时间',
minWidth: 180,
formatter: 'formatDateTime',
},
{
field: 'remark',
title: '备注',
minWidth: 120,
},
{
title: '操作',
width: 130,
width: 220,
fixed: 'right',
slots: { default: 'actions' },
},

View File

@@ -4,8 +4,8 @@ import type { SystemSmsChannelApi } from '#/api/system/sms/channel';
import { ref } from 'vue';
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui';
import { isEmpty } from '@vben/utils';
import { message } from 'ant-design-vue';
@@ -13,7 +13,6 @@ import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import {
deleteSmsChannel,
deleteSmsChannelList,
exportSmsChannel,
getSmsChannelPage,
} from '#/api/system/sms/channel';
import { $t } from '#/locales';
@@ -27,16 +26,10 @@ const [FormModal, formModalApi] = useVbenModal({
});
/** 刷新表格 */
function onRefresh() {
function handleRefresh() {
gridApi.query();
}
/** 导出表格 */
async function handleExport() {
const data = await exportSmsChannel(await gridApi.formApi.getValues());
downloadFileFromBlobPart({ fileName: '短信渠道.xls', source: data });
}
/** 创建短信渠道 */
function handleCreate() {
formModalApi.setData(null).open();
@@ -51,15 +44,29 @@ function handleEdit(row: SystemSmsChannelApi.SmsChannel) {
async function handleDelete(row: SystemSmsChannelApi.SmsChannel) {
const hideLoading = message.loading({
content: $t('ui.actionMessage.deleting', [row.signature]),
key: 'action_key_msg',
duration: 0,
});
try {
await deleteSmsChannel(row.id as number);
message.success({
content: $t('ui.actionMessage.deleteSuccess', [row.signature]),
key: 'action_key_msg',
});
onRefresh();
message.success($t('ui.actionMessage.deleteSuccess', [row.signature]));
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 deleteSmsChannelList(checkedIds.value);
checkedIds.value = [];
message.success($t('ui.actionMessage.deleteSuccess'));
handleRefresh();
} finally {
hideLoading();
}
@@ -74,30 +81,6 @@ function handleRowCheckboxChange({
checkedIds.value = records.map((item) => item.id!);
}
/** 批量删除处理 */
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);
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(),
@@ -125,9 +108,6 @@ const [Grid, gridApi] = useVbenVxeGrid({
refresh: true,
search: true,
},
checkboxConfig: {
checkField: 'checked',
},
} as VxeTableGridOptions<SystemSmsChannelApi.SmsChannel>,
gridEvents: {
checkboxAll: handleRowCheckboxChange,
@@ -142,7 +122,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
<DocAlert title="短信配置" url="https://doc.iocoder.cn/sms/" />
</template>
<FormModal @success="onRefresh" />
<FormModal @success="handleRefresh" />
<Grid table-title="短信渠道列表">
<template #toolbar-tools>
<TableAction
@@ -155,18 +135,11 @@ const [Grid, gridApi] = useVbenVxeGrid({
onClick: handleCreate,
},
{
label: $t('ui.actionTitle.export'),
type: 'primary',
icon: ACTION_ICON.DOWNLOAD,
auth: ['system:sms-channel:export'],
onClick: handleExport,
},
{
label: '批量删除',
label: $t('ui.actionTitle.deleteBatch'),
type: 'primary',
danger: true,
disabled: isEmpty(checkedIds),
icon: ACTION_ICON.DELETE,
disabled: isEmpty(checkedIds),
auth: ['system:sms-channel:delete'],
onClick: handleDeleteBatch,
},

View File

@@ -82,7 +82,7 @@ const [Modal, modalApi] = useVbenModal({
</script>
<template>
<Modal class="w-2/5" :title="getTitle">
<Modal :title="getTitle">
<Form class="mx-4" />
</Modal>
</template>