diff --git a/apps/web-antd/src/api/system/sms/smsChannel/index.ts b/apps/web-antd/src/api/system/sms/smsChannel/index.ts new file mode 100644 index 000000000..fb9e8d53f --- /dev/null +++ b/apps/web-antd/src/api/system/sms/smsChannel/index.ts @@ -0,0 +1,60 @@ +import type { PageParam } from '@vben/request'; + +import { requestClient } from '#/api/request'; + +export namespace SystemSmsChannelApi { + /** 短信渠道信息 */ + export interface SmsChannelVO { + id?: number; + code: string; + status: number; + signature: string; + remark: string; + apiKey: string; + apiSecret: string; + callbackUrl: string; + createTime?: Date; + } +} + +/** 查询短信渠道列表 */ +export function getSmsChannelPage(params: PageParam) { + return requestClient.get<{ + list: SystemSmsChannelApi.SmsChannelVO[]; + total: number; + }>('/system/sms-channel/page', { params }); +} + +/** 获得短信渠道精简列表 */ +export function getSimpleSmsChannelList() { + return requestClient.get( + '/system/sms-channel/simple-list', + ); +} + +/** 查询短信渠道详情 */ +export function getSmsChannel(id: number) { + return requestClient.get( + `/system/sms-channel/get?id=${id}`, + ); +} + +/** 新增短信渠道 */ +export function createSmsChannel(data: SystemSmsChannelApi.SmsChannelVO) { + return requestClient.post({ url: '/system/sms-channel/create', data }); +} + +/** 修改短信渠道 */ +export function updateSmsChannel(data: SystemSmsChannelApi.SmsChannelVO) { + return requestClient.put({ url: '/system/sms-channel/update', data }); +} + +/** 删除短信渠道 */ +export function deleteSmsChannel(id: number) { + return requestClient.delete({ url: `/system/sms-channel/delete?id=${id}` }); +} + +/** 导出短信渠道 */ +export function exportSmsChannel(params: SystemSmsChannelApi.SmsChannelVO) { + return requestClient.download('/system/sms-channel/export', { params }); +} diff --git a/apps/web-antd/src/api/system/user/index.ts b/apps/web-antd/src/api/system/user/index.ts index e69610626..2ef22f292 100644 --- a/apps/web-antd/src/api/system/user/index.ts +++ b/apps/web-antd/src/api/system/user/index.ts @@ -1,6 +1,7 @@ -import { requestClient } from '#/api/request'; import type { PageParam } from '@vben/request'; +import { requestClient } from '#/api/request'; + export namespace SystemUserApi { /** 用户信息 */ export interface SystemUser { diff --git a/apps/web-antd/src/views/system/sms/channel/data.ts b/apps/web-antd/src/views/system/sms/channel/data.ts new file mode 100644 index 000000000..7c021e3fd --- /dev/null +++ b/apps/web-antd/src/views/system/sms/channel/data.ts @@ -0,0 +1,184 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { SystemSmsChannelApi } from '#/api/system/sms/smsChannel'; + +import { z } from '#/adapter/form'; +import { CommonStatusEnum } from '#/utils/constants'; +import { DICT_TYPE, getDictOptions } from '#/utils/dict'; + +/** 新增/修改的表单 */ +export function useFormSchema(): VbenFormSchema[] { + return [ + { + component: 'Input', + fieldName: 'id', + label: 'id', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + component: 'Input', + fieldName: 'signature', + label: '短信签名', + rules: 'required', + }, + { + fieldName: 'code', + label: '渠道编码', + component: 'Select', + componentProps: { + class: 'w-full', + options: getDictOptions(DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE, 'string'), + }, + rules: 'required', + }, + { + fieldName: 'status', + label: '启用状态', + component: 'RadioGroup', + componentProps: { + options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + buttonStyle: 'solid', + optionType: 'button', + }, + rules: z.number().default(CommonStatusEnum.ENABLE), + }, + { + fieldName: 'remark', + label: '备注', + component: 'Textarea', + }, + { + fieldName: 'apiKey', + label: '短信 API 的账号', + component: 'Input', + rules: 'required', + }, + { + fieldName: 'apiSecret', + label: '短信 API 的密钥', + component: 'Input', + }, + { + fieldName: 'callbackUrl', + label: '短信发送回调 URL', + component: 'Input', + }, + ]; +} + +/** 列表的搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'signature', + label: '短信签名', + component: 'Input', + }, + { + fieldName: 'code', + label: '渠道编码', + component: 'Select', + componentProps: { + allowClear: true, + options: getDictOptions(DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE, 'string'), + }, + }, + { + fieldName: 'status', + label: '状态', + component: 'Select', + componentProps: { + allowClear: true, + options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + }, + }, + { + fieldName: 'createTime', + label: '创建时间', + component: 'RangePicker', + componentProps: { + allowClear: true, + }, + }, + ]; +} + +/** 列表的字段 */ +export function useGridColumns( + onActionClick: OnActionClickFn, +): VxeTableGridOptions['columns'] { + return [ + { + 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 }, + }, + }, + { + field: 'status', + title: '启用状态', + minWidth: 100, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.COMMON_STATUS }, + }, + }, + { + field: 'remark', + title: '备注', + minWidth: 120, + }, + { + 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: 'operation', + title: '操作', + minWidth: 180, + align: 'center', + fixed: 'right', + cellRender: { + attrs: { + nameField: 'signature', + nameTitle: '短信渠道', + onClick: onActionClick, + }, + name: 'CellOperation', + }, + }, + ]; +} diff --git a/apps/web-antd/src/views/system/sms/channel/index.vue b/apps/web-antd/src/views/system/sms/channel/index.vue new file mode 100644 index 000000000..e7c9e6517 --- /dev/null +++ b/apps/web-antd/src/views/system/sms/channel/index.vue @@ -0,0 +1,133 @@ + + + diff --git a/apps/web-antd/src/views/system/sms/channel/modules/form.vue b/apps/web-antd/src/views/system/sms/channel/modules/form.vue new file mode 100644 index 000000000..095c5fd31 --- /dev/null +++ b/apps/web-antd/src/views/system/sms/channel/modules/form.vue @@ -0,0 +1,84 @@ + + +