diff --git a/src/api/system/mail/account/index.ts b/src/api/system/mail/account/index.ts index 52bb8d6..3c1117b 100644 --- a/src/api/system/mail/account/index.ts +++ b/src/api/system/mail/account/index.ts @@ -14,26 +14,32 @@ export interface MailAccount { createTime?: string } +/** 获取邮箱账号分页列表 */ export function getMailAccountPage(params: PageParam) { return http.get>('/system/mail-account/page', params) } +/** 获取邮箱账号(精简)列表 */ export function getSimpleMailAccountList() { return http.get('/system/mail-account/simple-list') } +/** 获取邮箱账号详情 */ export function getMailAccount(id: number) { return http.get(`/system/mail-account/get?id=${id}`) } +/** 创建邮箱账号 */ export function createMailAccount(data: MailAccount) { return http.post('/system/mail-account/create', data) } +/** 更新邮箱账号 */ export function updateMailAccount(data: MailAccount) { return http.put('/system/mail-account/update', data) } +/** 删除邮箱账号 */ export function deleteMailAccount(id: number) { return http.delete(`/system/mail-account/delete?id=${id}`) } diff --git a/src/api/system/mail/log/index.ts b/src/api/system/mail/log/index.ts index 421d19a..dbe23da 100644 --- a/src/api/system/mail/log/index.ts +++ b/src/api/system/mail/log/index.ts @@ -23,6 +23,12 @@ export interface MailLog { createTime?: string } +/** 获取邮件日志分页列表 */ export function getMailLogPage(params: PageParam) { return http.get>('/system/mail-log/page', params) } + +/** 获取邮件日志详情 */ +export function getMailLog(id: number) { + return http.get(`/system/mail-log/get?id=${id}`) +} diff --git a/src/api/system/mail/template/index.ts b/src/api/system/mail/template/index.ts index 31141e3..70c2cb7 100644 --- a/src/api/system/mail/template/index.ts +++ b/src/api/system/mail/template/index.ts @@ -25,26 +25,32 @@ export interface MailSendReqVO { bccMails?: string[] } +/** 获取邮件模板分页列表 */ export function getMailTemplatePage(params: PageParam) { return http.get>('/system/mail-template/page', params) } +/** 获取邮件模板详情 */ export function getMailTemplate(id: number) { return http.get(`/system/mail-template/get?id=${id}`) } +/** 创建邮件模板 */ export function createMailTemplate(data: MailTemplate) { return http.post('/system/mail-template/create', data) } +/** 更新邮件模板 */ export function updateMailTemplate(data: MailTemplate) { return http.put('/system/mail-template/update', data) } +/** 删除邮件模板 */ export function deleteMailTemplate(id: number) { return http.delete(`/system/mail-template/delete?id=${id}`) } +/** 发送邮件 */ export function sendMail(data: MailSendReqVO) { return http.post('/system/mail-template/send-mail', data) } diff --git a/src/api/system/sms/log/index.ts b/src/api/system/sms/log/index.ts index c181f3f..40fa5ec 100644 --- a/src/api/system/sms/log/index.ts +++ b/src/api/system/sms/log/index.ts @@ -32,3 +32,8 @@ export interface SmsLog { export function getSmsLogPage(params: PageParam) { return http.get>('/system/sms-log/page', params) } + +/** 获取短信日志详情 */ +export function getSmsLog(id: number) { + return http.get(`/system/sms-log/get?id=${id}`) +} diff --git a/src/pages-system/mail/log/detail/index.vue b/src/pages-system/mail/log/detail/index.vue index 992014b..e503b0f 100644 --- a/src/pages-system/mail/log/detail/index.vue +++ b/src/pages-system/mail/log/detail/index.vue @@ -33,7 +33,7 @@ import type { MailLog } from '@/api/system/mail/log' import { onMounted, ref } from 'vue' import { useToast } from 'wot-design-uni' -import { getMailLogPage } from '@/api/system/mail/log' +import { getMailLog } from '@/api/system/mail/log' import { navigateBackPlus } from '@/utils' import { DICT_TYPE } from '@/utils/constants' import { formatDateTime } from '@/utils/date' @@ -75,19 +75,14 @@ function formatReceiveInfo(data?: MailLog) { return lines.length > 0 ? lines.join(';') : '-' } -/** 加载详情 - 由于没有单独的获取详情接口,通过列表接口获取 */ +/** 加载详情 */ async function getDetail() { if (!props.id) { return } try { toast.loading('加载中...') - // 通过分页接口获取单条数据 - // TODO @AI:使用 getMailLog 认为它存在!我去支持下; - const data = await getMailLogPage({ pageNo: 1, pageSize: 1, id: props.id }) - if (data.list && data.list.length > 0) { - formData.value = data.list[0] - } + formData.value = await getMailLog(Number(props.id)) } finally { toast.close() } diff --git a/src/pages-system/mail/template/detail/components/send-form.vue b/src/pages-system/mail/template/detail/components/send-form.vue index a3f1290..a42e5ec 100644 --- a/src/pages-system/mail/template/detail/components/send-form.vue +++ b/src/pages-system/mail/template/detail/components/send-form.vue @@ -61,6 +61,7 @@ import type { MailTemplate } from '@/api/system/mail/template' import { computed, ref, watch } from 'vue' import { useToast } from 'wot-design-uni' import { sendMail } from '@/api/system/mail/template' +import { isEmail } from '@/utils/validator' const props = defineProps<{ modelValue: boolean @@ -107,12 +108,17 @@ const sendFormRules = computed(() => { }) /** 格式化邮箱列表 */ -// TODO @AI:需要 isEmail 校验下,validator 里有 function normalizeMailList(text: string) { - return text + const list = text .split(/[,,;;\s]+/) .map(s => s.trim()) .filter(Boolean) + const invalid = list.find(item => !isEmail(item)) + if (invalid) { + toast.warning(`邮箱格式不正确:${invalid}`) + return null + } + return list } /** 初始化发送表单 */ @@ -146,15 +152,27 @@ async function handleSendSubmit() { if (!valid) { return } + const toMails = normalizeMailList(sendFormData.value.toMails) + if (!toMails || toMails.length === 0) { + return + } + const ccMails = normalizeMailList(sendFormData.value.ccMails) + if (ccMails === null) { + return + } + const bccMails = normalizeMailList(sendFormData.value.bccMails) + if (bccMails === null) { + return + } sendLoading.value = true try { await sendMail({ templateCode: props.template?.code || '', templateParams: sendFormData.value.templateParams, - toMails: normalizeMailList(sendFormData.value.toMails), - ccMails: normalizeMailList(sendFormData.value.ccMails), - bccMails: normalizeMailList(sendFormData.value.bccMails), + toMails, + ccMails: ccMails.length > 0 ? ccMails : undefined, + bccMails: bccMails.length > 0 ? bccMails : undefined, }) toast.success('邮件发送成功') emit('success') diff --git a/src/pages-system/mail/template/form/index.vue b/src/pages-system/mail/template/form/index.vue index 7889c96..2843e57 100644 --- a/src/pages-system/mail/template/form/index.vue +++ b/src/pages-system/mail/template/form/index.vue @@ -30,7 +30,9 @@ @@ -143,15 +145,6 @@ const formRef = ref() /** 邮箱账号列表 */ const accountList = ref([]) -/** 邮箱账号选项 */ -// TODO @AI:直接使用 accountList,参考 https://wot-ui.cn/component/picker.html ,支持通过 label-key 和 value-key; -const accountOptions = computed(() => { - return accountList.value.map(item => ({ - value: item.id, - label: item.mail, - })) -}) - /** 返回上一页 */ function handleBack() { navigateBackPlus('/pages-system/mail/index') diff --git a/src/pages-system/sms/channel/form/index.vue b/src/pages-system/sms/channel/form/index.vue index f263ab6..6124ef5 100644 --- a/src/pages-system/sms/channel/form/index.vue +++ b/src/pages-system/sms/channel/form/index.vue @@ -22,7 +22,9 @@ @@ -128,15 +130,6 @@ const formRules = { } const formRef = ref() -/** 渠道编码选项 */ -// TODO @AI:直接使用 getStrDictOptions(DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE) 在 html 里;别的模块,也是这么干的 -const channelCodeOptions = computed(() => { - return getStrDictOptions(DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE).map(item => ({ - value: item.value, - label: item.label, - })) -}) - /** 返回上一页 */ function handleBack() { navigateBackPlus('/pages-system/sms/index') diff --git a/src/pages-system/sms/log/detail/index.vue b/src/pages-system/sms/log/detail/index.vue index 24908e1..c1c5535 100644 --- a/src/pages-system/sms/log/detail/index.vue +++ b/src/pages-system/sms/log/detail/index.vue @@ -44,7 +44,7 @@ import type { SmsLog } from '@/api/system/sms/log' import { onMounted, ref } from 'vue' import { useToast } from 'wot-design-uni' -import { getSmsLogPage } from '@/api/system/sms/log' +import { getSmsLog } from '@/api/system/sms/log' import { navigateBackPlus } from '@/utils' import { DICT_TYPE } from '@/utils/constants' import { formatDateTime } from '@/utils/date' @@ -68,19 +68,14 @@ function handleBack() { navigateBackPlus('/pages-system/sms/index') } -/** 加载详情 - 由于没有单独的获取详情接口,通过列表接口获取 */ +/** 加载详情 */ async function getDetail() { if (!props.id) { return } try { toast.loading('加载中...') - // 通过分页接口获取单条数据 - // TODO @AI:使用 getMailLog 认为它存在!我去支持下; - const data = await getSmsLogPage({ pageNo: 1, pageSize: 1, id: props.id }) - if (data.list && data.list.length > 0) { - formData.value = data.list[0] - } + formData.value = await getSmsLog(Number(props.id)) } finally { toast.close() }