diff --git a/apps/web-antd/src/api/system/mail/template/index.ts b/apps/web-antd/src/api/system/mail/template/index.ts index 5f7e7525..ef08e248 100644 --- a/apps/web-antd/src/api/system/mail/template/index.ts +++ b/apps/web-antd/src/api/system/mail/template/index.ts @@ -19,7 +19,7 @@ export namespace SystemMailTemplateApi { } /** 邮件发送信息 */ - export interface MailSendReq { + export interface MailSendReqVO { toMails: string[]; ccMails?: string[]; bccMails?: string[]; @@ -66,6 +66,6 @@ export function deleteMailTemplateList(ids: number[]) { } /** 发送邮件 */ -export function sendMail(data: SystemMailTemplateApi.MailSendReq) { +export function sendMail(data: SystemMailTemplateApi.MailSendReqVO) { return requestClient.post('/system/mail-template/send-mail', data); } diff --git a/apps/web-antd/src/views/system/dept/index.vue b/apps/web-antd/src/views/system/dept/index.vue index 37486004..9e09c98c 100644 --- a/apps/web-antd/src/views/system/dept/index.vue +++ b/apps/web-antd/src/views/system/dept/index.vue @@ -23,9 +23,8 @@ const [FormModal, formModalApi] = useVbenModal({ destroyOnClose: true, }); -const userList = ref([]); - /** 获取负责人名称 */ +const userList = ref([]); function getLeaderName(userId: number) { return userList.value.find((user) => user.id === userId)?.nickname; } diff --git a/apps/web-antd/src/views/system/mail/template/data.ts b/apps/web-antd/src/views/system/mail/template/data.ts index d500a650..14191bf0 100644 --- a/apps/web-antd/src/views/system/mail/template/data.ts +++ b/apps/web-antd/src/views/system/mail/template/data.ts @@ -69,11 +69,7 @@ export function useFormSchema(): VbenFormSchema[] { { fieldName: 'content', label: '模板内容', - component: 'Textarea', - componentProps: { - placeholder: '请输入模板内容', - height: 300, - }, + component: 'RichTextarea', rules: 'required', }, { @@ -113,9 +109,11 @@ export function useSendMailFormSchema(): VbenFormSchema[] { { fieldName: 'content', label: '模板内容', - component: 'Textarea', + component: 'RichTextarea', componentProps: { - disabled: true, + options: { + readonly: true, + }, }, }, { @@ -212,31 +210,38 @@ export function useGridColumns( { field: 'id', title: '编号', + minWidth: 100, }, { field: 'code', title: '模板编码', + minWidth: 120, }, { field: 'name', title: '模板名称', + minWidth: 120, }, { field: 'title', title: '模板标题', + minWidth: 120, }, { field: 'accountId', title: '邮箱账号', + minWidth: 120, formatter: ({ cellValue }) => getAccountMail?.(cellValue) || '-', }, { field: 'nickname', title: '发送人名称', + minWidth: 120, }, { field: 'status', title: '开启状态', + minWidth: 100, cellRender: { name: 'CellDict', props: { type: DICT_TYPE.COMMON_STATUS }, @@ -245,6 +250,7 @@ export function useGridColumns( { field: 'createTime', title: '创建时间', + minWidth: 180, formatter: 'formatDateTime', }, { diff --git a/apps/web-antd/src/views/system/mail/template/index.vue b/apps/web-antd/src/views/system/mail/template/index.vue index 2aad56cf..eccabef8 100644 --- a/apps/web-antd/src/views/system/mail/template/index.vue +++ b/apps/web-antd/src/views/system/mail/template/index.vue @@ -5,7 +5,7 @@ import type { SystemMailTemplateApi } from '#/api/system/mail/template'; import { onMounted, ref } from 'vue'; -import { DocAlert, Page, useVbenModal } from '@vben/common-ui'; +import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui'; import { isEmpty } from '@vben/utils'; import { message } from 'ant-design-vue'; @@ -23,8 +23,6 @@ import { useGridColumns, useGridFormSchema } from './data'; import Form from './modules/form.vue'; import SendForm from './modules/send-form.vue'; -const accountList = ref([]); - const [FormModal, formModalApi] = useVbenModal({ connectedComponent: Form, destroyOnClose: true, @@ -35,8 +33,14 @@ const [SendModal, sendModalApi] = useVbenModal({ destroyOnClose: true, }); +/** 获取邮箱账号 */ +const accountList = ref([]); +function getAccountMail(accountId: number) { + return accountList.value.find((account) => account.id === accountId)?.mail; +} + /** 刷新表格 */ -function onRefresh() { +function handleRefresh() { gridApi.query(); } @@ -57,17 +61,34 @@ function handleSend(row: SystemMailTemplateApi.MailTemplate) { /** 删除邮件模板 */ async function handleDelete(row: SystemMailTemplateApi.MailTemplate) { - message.loading({ + const hideLoading = message.loading({ content: $t('ui.actionMessage.deleting', [row.name]), duration: 0, - key: 'action_process_msg', }); - await deleteMailTemplate(row.id as number); - message.success({ - content: $t('ui.actionMessage.deleteSuccess', [row.name]), - key: 'action_key_msg', + try { + await deleteMailTemplate(row.id as number); + message.success($t('ui.actionMessage.deleteSuccess', [row.name])); + handleRefresh(); + } finally { + hideLoading(); + } +} + +/** 批量删除邮件模板 */ +async function handleDeleteBatch() { + await confirm($t('ui.actionMessage.deleteBatchConfirm')); + const hideLoading = message.loading({ + content: $t('ui.actionMessage.deletingBatch'), + duration: 0, }); - onRefresh(); + try { + await deleteMailTemplateList(checkedIds.value); + checkedIds.value = []; + message.success($t('ui.actionMessage.deleteSuccess')); + handleRefresh(); + } finally { + hideLoading(); + } } const checkedIds = ref([]); @@ -79,28 +100,6 @@ function handleRowCheckboxChange({ checkedIds.value = records.map((item) => item.id!); } -/** 批量删除邮件模板 */ -async function handleDeleteBatch() { - const hideLoading = message.loading({ - content: $t('ui.actionMessage.deleting'), - duration: 0, - key: 'action_process_msg', - }); - try { - await deleteMailTemplateList(checkedIds.value); - checkedIds.value = []; - message.success($t('ui.actionMessage.deleteSuccess')); - onRefresh(); - } finally { - hideLoading(); - } -} - -/** 获取邮箱账号 */ -function getAccountMail(accountId: number) { - return accountList.value.find((account) => account.id === accountId)?.mail; -} - const [Grid, gridApi] = useVbenVxeGrid({ formOptions: { schema: useGridFormSchema(), @@ -146,7 +145,7 @@ onMounted(async () => { - +