feat:【system】邮箱管理的开发:100%

feat:【system】短信管理的开发:修复 todo
This commit is contained in:
YunaiV
2025-12-20 20:37:49 +08:00
parent 0357425ac7
commit 6c3b86666d
9 changed files with 58 additions and 41 deletions

View File

@@ -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()
}

View File

@@ -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')

View File

@@ -30,7 +30,9 @@
<wd-cell title="邮箱账号" title-width="200rpx" prop="accountId" center>
<wd-picker
v-model="formData.accountId"
:columns="accountOptions"
:columns="accountList"
label-key="mail"
value-key="id"
placeholder="请选择邮箱账号"
/>
</wd-cell>
@@ -143,15 +145,6 @@ const formRef = ref()
/** 邮箱账号列表 */
const accountList = ref<MailAccount[]>([])
/** 邮箱账号选项 */
// 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')

View File

@@ -22,7 +22,9 @@
<wd-cell title="渠道编码" title-width="200rpx" prop="code" center>
<wd-picker
v-model="formData.code"
:columns="channelCodeOptions"
:columns="getStrDictOptions(DICT_TYPE.SYSTEM_SMS_CHANNEL_CODE)"
label-key="label"
value-key="value"
placeholder="请选择渠道编码"
/>
</wd-cell>
@@ -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')

View File

@@ -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()
}