reactor:【system 系统管理】mail/template 进一步统一代码风格
This commit is contained in:
@@ -19,7 +19,7 @@ export namespace SystemMailTemplateApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 邮件发送信息 */
|
/** 邮件发送信息 */
|
||||||
export interface MailSendReq {
|
export interface MailSendReqVO {
|
||||||
toMails: string[];
|
toMails: string[];
|
||||||
ccMails?: string[];
|
ccMails?: string[];
|
||||||
bccMails?: 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);
|
return requestClient.post('/system/mail-template/send-mail', data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,9 +23,8 @@ const [FormModal, formModalApi] = useVbenModal({
|
|||||||
destroyOnClose: true,
|
destroyOnClose: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const userList = ref<SystemUserApi.User[]>([]);
|
|
||||||
|
|
||||||
/** 获取负责人名称 */
|
/** 获取负责人名称 */
|
||||||
|
const userList = ref<SystemUserApi.User[]>([]);
|
||||||
function getLeaderName(userId: number) {
|
function getLeaderName(userId: number) {
|
||||||
return userList.value.find((user) => user.id === userId)?.nickname;
|
return userList.value.find((user) => user.id === userId)?.nickname;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,11 +69,7 @@ export function useFormSchema(): VbenFormSchema[] {
|
|||||||
{
|
{
|
||||||
fieldName: 'content',
|
fieldName: 'content',
|
||||||
label: '模板内容',
|
label: '模板内容',
|
||||||
component: 'Textarea',
|
component: 'RichTextarea',
|
||||||
componentProps: {
|
|
||||||
placeholder: '请输入模板内容',
|
|
||||||
height: 300,
|
|
||||||
},
|
|
||||||
rules: 'required',
|
rules: 'required',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -113,9 +109,11 @@ export function useSendMailFormSchema(): VbenFormSchema[] {
|
|||||||
{
|
{
|
||||||
fieldName: 'content',
|
fieldName: 'content',
|
||||||
label: '模板内容',
|
label: '模板内容',
|
||||||
component: 'Textarea',
|
component: 'RichTextarea',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
disabled: true,
|
options: {
|
||||||
|
readonly: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -212,31 +210,38 @@ export function useGridColumns(
|
|||||||
{
|
{
|
||||||
field: 'id',
|
field: 'id',
|
||||||
title: '编号',
|
title: '编号',
|
||||||
|
minWidth: 100,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'code',
|
field: 'code',
|
||||||
title: '模板编码',
|
title: '模板编码',
|
||||||
|
minWidth: 120,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'name',
|
field: 'name',
|
||||||
title: '模板名称',
|
title: '模板名称',
|
||||||
|
minWidth: 120,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'title',
|
field: 'title',
|
||||||
title: '模板标题',
|
title: '模板标题',
|
||||||
|
minWidth: 120,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'accountId',
|
field: 'accountId',
|
||||||
title: '邮箱账号',
|
title: '邮箱账号',
|
||||||
|
minWidth: 120,
|
||||||
formatter: ({ cellValue }) => getAccountMail?.(cellValue) || '-',
|
formatter: ({ cellValue }) => getAccountMail?.(cellValue) || '-',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'nickname',
|
field: 'nickname',
|
||||||
title: '发送人名称',
|
title: '发送人名称',
|
||||||
|
minWidth: 120,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'status',
|
field: 'status',
|
||||||
title: '开启状态',
|
title: '开启状态',
|
||||||
|
minWidth: 100,
|
||||||
cellRender: {
|
cellRender: {
|
||||||
name: 'CellDict',
|
name: 'CellDict',
|
||||||
props: { type: DICT_TYPE.COMMON_STATUS },
|
props: { type: DICT_TYPE.COMMON_STATUS },
|
||||||
@@ -245,6 +250,7 @@ export function useGridColumns(
|
|||||||
{
|
{
|
||||||
field: 'createTime',
|
field: 'createTime',
|
||||||
title: '创建时间',
|
title: '创建时间',
|
||||||
|
minWidth: 180,
|
||||||
formatter: 'formatDateTime',
|
formatter: 'formatDateTime',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import type { SystemMailTemplateApi } from '#/api/system/mail/template';
|
|||||||
|
|
||||||
import { onMounted, ref } from 'vue';
|
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 { isEmpty } from '@vben/utils';
|
||||||
|
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
@@ -23,8 +23,6 @@ import { useGridColumns, useGridFormSchema } from './data';
|
|||||||
import Form from './modules/form.vue';
|
import Form from './modules/form.vue';
|
||||||
import SendForm from './modules/send-form.vue';
|
import SendForm from './modules/send-form.vue';
|
||||||
|
|
||||||
const accountList = ref<SystemMailAccountApi.MailAccount[]>([]);
|
|
||||||
|
|
||||||
const [FormModal, formModalApi] = useVbenModal({
|
const [FormModal, formModalApi] = useVbenModal({
|
||||||
connectedComponent: Form,
|
connectedComponent: Form,
|
||||||
destroyOnClose: true,
|
destroyOnClose: true,
|
||||||
@@ -35,8 +33,14 @@ const [SendModal, sendModalApi] = useVbenModal({
|
|||||||
destroyOnClose: true,
|
destroyOnClose: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** 获取邮箱账号 */
|
||||||
|
const accountList = ref<SystemMailAccountApi.MailAccount[]>([]);
|
||||||
|
function getAccountMail(accountId: number) {
|
||||||
|
return accountList.value.find((account) => account.id === accountId)?.mail;
|
||||||
|
}
|
||||||
|
|
||||||
/** 刷新表格 */
|
/** 刷新表格 */
|
||||||
function onRefresh() {
|
function handleRefresh() {
|
||||||
gridApi.query();
|
gridApi.query();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,17 +61,34 @@ function handleSend(row: SystemMailTemplateApi.MailTemplate) {
|
|||||||
|
|
||||||
/** 删除邮件模板 */
|
/** 删除邮件模板 */
|
||||||
async function handleDelete(row: SystemMailTemplateApi.MailTemplate) {
|
async function handleDelete(row: SystemMailTemplateApi.MailTemplate) {
|
||||||
message.loading({
|
const hideLoading = message.loading({
|
||||||
content: $t('ui.actionMessage.deleting', [row.name]),
|
content: $t('ui.actionMessage.deleting', [row.name]),
|
||||||
duration: 0,
|
duration: 0,
|
||||||
key: 'action_process_msg',
|
|
||||||
});
|
});
|
||||||
await deleteMailTemplate(row.id as number);
|
try {
|
||||||
message.success({
|
await deleteMailTemplate(row.id as number);
|
||||||
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
message.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||||
key: 'action_key_msg',
|
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<number[]>([]);
|
const checkedIds = ref<number[]>([]);
|
||||||
@@ -79,28 +100,6 @@ function handleRowCheckboxChange({
|
|||||||
checkedIds.value = records.map((item) => item.id!);
|
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({
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
formOptions: {
|
formOptions: {
|
||||||
schema: useGridFormSchema(),
|
schema: useGridFormSchema(),
|
||||||
@@ -146,7 +145,7 @@ onMounted(async () => {
|
|||||||
<DocAlert title="邮件配置" url="https://doc.iocoder.cn/mail" />
|
<DocAlert title="邮件配置" url="https://doc.iocoder.cn/mail" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<FormModal @success="onRefresh" />
|
<FormModal @success="handleRefresh" />
|
||||||
<SendModal />
|
<SendModal />
|
||||||
<Grid table-title="邮件模板列表">
|
<Grid table-title="邮件模板列表">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
@@ -160,12 +159,12 @@ onMounted(async () => {
|
|||||||
onClick: handleCreate,
|
onClick: handleCreate,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '批量删除',
|
label: $t('ui.actionTitle.deleteBatch'),
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
danger: true,
|
danger: true,
|
||||||
disabled: isEmpty(checkedIds),
|
|
||||||
icon: ACTION_ICON.DELETE,
|
icon: ACTION_ICON.DELETE,
|
||||||
auth: ['system:mail-template:delete'],
|
auth: ['system:mail-template:delete'],
|
||||||
|
disabled: isEmpty(checkedIds),
|
||||||
onClick: handleDeleteBatch,
|
onClick: handleDeleteBatch,
|
||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
@@ -184,7 +183,7 @@ onMounted(async () => {
|
|||||||
{
|
{
|
||||||
label: '测试',
|
label: '测试',
|
||||||
type: 'link',
|
type: 'link',
|
||||||
icon: ACTION_ICON.EDIT,
|
icon: ACTION_ICON.VIEW,
|
||||||
auth: ['system:mail-template:send-mail'],
|
auth: ['system:mail-template:send-mail'],
|
||||||
onClick: handleSend.bind(null, row),
|
onClick: handleSend.bind(null, row),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
.map((email) => email.trim())
|
.map((email) => email.trim())
|
||||||
.filter((email) => email.length > 0);
|
.filter((email) => email.length > 0);
|
||||||
};
|
};
|
||||||
const data: SystemMailTemplateApi.MailSendReq = {
|
const data: SystemMailTemplateApi.MailSendReqVO = {
|
||||||
toMails: parseEmails(values.toMails || ''),
|
toMails: parseEmails(values.toMails || ''),
|
||||||
ccMails: parseEmails(values.ccMails || ''),
|
ccMails: parseEmails(values.ccMails || ''),
|
||||||
bccMails: parseEmails(values.bccMails || ''),
|
bccMails: parseEmails(values.bccMails || ''),
|
||||||
@@ -112,7 +112,7 @@ function buildFormSchema() {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Modal title="测试发送邮件">
|
<Modal title="测试发送邮件" class="w-1/3">
|
||||||
<Form class="mx-4" />
|
<Form class="mx-4" />
|
||||||
</Modal>
|
</Modal>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -23,9 +23,8 @@ const [FormModal, formModalApi] = useVbenModal({
|
|||||||
destroyOnClose: true,
|
destroyOnClose: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const userList = ref<SystemUserApi.User[]>([]);
|
|
||||||
|
|
||||||
/** 获取负责人名称 */
|
/** 获取负责人名称 */
|
||||||
|
const userList = ref<SystemUserApi.User[]>([]);
|
||||||
function getLeaderName(userId: number) {
|
function getLeaderName(userId: number) {
|
||||||
return userList.value.find((user) => user.id === userId)?.nickname;
|
return userList.value.find((user) => user.id === userId)?.nickname;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import type { VbenFormSchema } from '#/adapter/form';
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { SystemMailTemplateApi } from '#/api/system/mail/template';
|
|
||||||
|
|
||||||
import { useAccess } from '@vben/access';
|
|
||||||
import { CommonStatusEnum, DICT_TYPE } from '@vben/constants';
|
import { CommonStatusEnum, DICT_TYPE } from '@vben/constants';
|
||||||
import { getDictOptions } from '@vben/hooks';
|
import { getDictOptions } from '@vben/hooks';
|
||||||
|
|
||||||
@@ -10,8 +8,6 @@ import { z } from '#/adapter/form';
|
|||||||
import { getSimpleMailAccountList } from '#/api/system/mail/account';
|
import { getSimpleMailAccountList } from '#/api/system/mail/account';
|
||||||
import { getRangePickerDefaultProps } from '#/utils';
|
import { getRangePickerDefaultProps } from '#/utils';
|
||||||
|
|
||||||
const { hasAccessByCodes } = useAccess();
|
|
||||||
|
|
||||||
/** 新增/修改的表单 */
|
/** 新增/修改的表单 */
|
||||||
export function useFormSchema(): VbenFormSchema[] {
|
export function useFormSchema(): VbenFormSchema[] {
|
||||||
return [
|
return [
|
||||||
@@ -73,11 +69,7 @@ export function useFormSchema(): VbenFormSchema[] {
|
|||||||
{
|
{
|
||||||
fieldName: 'content',
|
fieldName: 'content',
|
||||||
label: '模板内容',
|
label: '模板内容',
|
||||||
component: 'Textarea',
|
component: 'RichTextarea',
|
||||||
componentProps: {
|
|
||||||
placeholder: '请输入模板内容',
|
|
||||||
height: 300,
|
|
||||||
},
|
|
||||||
rules: 'required',
|
rules: 'required',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -117,9 +109,11 @@ export function useSendMailFormSchema(): VbenFormSchema[] {
|
|||||||
{
|
{
|
||||||
fieldName: 'content',
|
fieldName: 'content',
|
||||||
label: '模板内容',
|
label: '模板内容',
|
||||||
component: 'Textarea',
|
component: 'RichTextarea',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
disabled: true,
|
options: {
|
||||||
|
readonly: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -208,15 +202,11 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 列表的字段 */
|
/** 列表的字段 */
|
||||||
export function useGridColumns<T = SystemMailTemplateApi.MailTemplate>(
|
export function useGridColumns(
|
||||||
onActionClick: OnActionClickFn<T>,
|
|
||||||
getAccountMail?: (accountId: number) => string | undefined,
|
getAccountMail?: (accountId: number) => string | undefined,
|
||||||
): VxeTableGridOptions['columns'] {
|
): VxeTableGridOptions['columns'] {
|
||||||
return [
|
return [
|
||||||
{
|
{ type: 'checkbox', width: 40 },
|
||||||
type: 'checkbox',
|
|
||||||
width: 40,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
field: 'id',
|
field: 'id',
|
||||||
title: '编号',
|
title: '编号',
|
||||||
@@ -241,7 +231,7 @@ export function useGridColumns<T = SystemMailTemplateApi.MailTemplate>(
|
|||||||
field: 'accountId',
|
field: 'accountId',
|
||||||
title: '邮箱账号',
|
title: '邮箱账号',
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
formatter: (row) => getAccountMail?.(row.cellValue) || '-',
|
formatter: ({ cellValue }) => getAccountMail?.(cellValue) || '-',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'nickname',
|
field: 'nickname',
|
||||||
@@ -264,34 +254,10 @@ export function useGridColumns<T = SystemMailTemplateApi.MailTemplate>(
|
|||||||
formatter: 'formatDateTime',
|
formatter: 'formatDateTime',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'operation',
|
|
||||||
title: '操作',
|
title: '操作',
|
||||||
minWidth: 150,
|
width: 220,
|
||||||
align: 'center',
|
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
cellRender: {
|
slots: { default: 'actions' },
|
||||||
attrs: {
|
|
||||||
nameField: 'name',
|
|
||||||
nameTitle: '邮件模板',
|
|
||||||
onClick: onActionClick,
|
|
||||||
},
|
|
||||||
name: 'CellOperation',
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
code: 'edit',
|
|
||||||
show: hasAccessByCodes(['system:mail-template:update']),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
code: 'delete',
|
|
||||||
show: hasAccessByCodes(['system:mail-template:delete']),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
code: 'send',
|
|
||||||
text: '测试',
|
|
||||||
show: hasAccessByCodes(['system:mail-template:send-mail']),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type {
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
OnActionClickParams,
|
|
||||||
VxeTableGridOptions,
|
|
||||||
} from '#/adapter/vxe-table';
|
|
||||||
import type { SystemMailAccountApi } from '#/api/system/mail/account';
|
import type { SystemMailAccountApi } from '#/api/system/mail/account';
|
||||||
import type { SystemMailTemplateApi } from '#/api/system/mail/template';
|
import type { SystemMailTemplateApi } from '#/api/system/mail/template';
|
||||||
|
|
||||||
@@ -26,13 +23,6 @@ import { useGridColumns, useGridFormSchema } from './data';
|
|||||||
import Form from './modules/form.vue';
|
import Form from './modules/form.vue';
|
||||||
import SendForm from './modules/send-form.vue';
|
import SendForm from './modules/send-form.vue';
|
||||||
|
|
||||||
const accountList = ref<SystemMailAccountApi.MailAccount[]>([]);
|
|
||||||
|
|
||||||
/** 获取邮箱账号 */
|
|
||||||
const getAccountMail = (accountId: number) => {
|
|
||||||
return accountList.value.find((account) => account.id === accountId)?.mail;
|
|
||||||
};
|
|
||||||
|
|
||||||
const [FormModal, formModalApi] = useVbenModal({
|
const [FormModal, formModalApi] = useVbenModal({
|
||||||
connectedComponent: Form,
|
connectedComponent: Form,
|
||||||
destroyOnClose: true,
|
destroyOnClose: true,
|
||||||
@@ -43,47 +33,60 @@ const [SendModal, sendModalApi] = useVbenModal({
|
|||||||
destroyOnClose: true,
|
destroyOnClose: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** 获取邮箱账号 */
|
||||||
|
const accountList = ref<SystemMailAccountApi.MailAccount[]>([]);
|
||||||
|
function getAccountMail(accountId: number) {
|
||||||
|
return accountList.value.find((account) => account.id === accountId)?.mail;
|
||||||
|
}
|
||||||
|
|
||||||
/** 刷新表格 */
|
/** 刷新表格 */
|
||||||
function onRefresh() {
|
function handleRefresh() {
|
||||||
gridApi.query();
|
gridApi.query();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 创建邮件模板 */
|
/** 创建邮件模板 */
|
||||||
function onCreate() {
|
function handleCreate() {
|
||||||
formModalApi.setData(null).open();
|
formModalApi.setData(null).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 编辑邮件模板 */
|
/** 编辑邮件模板 */
|
||||||
function onEdit(row: SystemMailTemplateApi.MailTemplate) {
|
function handleEdit(row: SystemMailTemplateApi.MailTemplate) {
|
||||||
formModalApi.setData(row).open();
|
formModalApi.setData(row).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 发送测试邮件 */
|
/** 发送测试邮件 */
|
||||||
function onSend(row: SystemMailTemplateApi.MailTemplate) {
|
function handleSend(row: SystemMailTemplateApi.MailTemplate) {
|
||||||
sendModalApi.setData(row).open();
|
sendModalApi.setData(row).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 删除邮件模板 */
|
/** 删除邮件模板 */
|
||||||
async function onDelete(row: SystemMailTemplateApi.MailTemplate) {
|
async function handleDelete(row: SystemMailTemplateApi.MailTemplate) {
|
||||||
const loadingInstance = ElLoading.service({
|
const loadingInstance = ElLoading.service({
|
||||||
text: $t('ui.actionMessage.deleting', [row.name]),
|
text: $t('ui.actionMessage.deleting', [row.name]),
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await deleteMailTemplate(row.id as number);
|
await deleteMailTemplate(row.id as number);
|
||||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||||
onRefresh();
|
handleRefresh();
|
||||||
} finally {
|
} finally {
|
||||||
loadingInstance.close();
|
loadingInstance.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 批量删除邮件模板 */
|
/** 批量删除邮件模板 */
|
||||||
async function onDeleteBatch() {
|
async function handleDeleteBatch() {
|
||||||
await confirm('确定要批量删除该邮件模板吗?');
|
await confirm($t('ui.actionMessage.deleteBatchConfirm'));
|
||||||
await deleteMailTemplateList(checkedIds.value);
|
const loadingInstance = ElLoading.service({
|
||||||
checkedIds.value = [];
|
text: $t('ui.actionMessage.deletingBatch'),
|
||||||
ElMessage.success($t('ui.actionMessage.deleteSuccess'));
|
});
|
||||||
onRefresh();
|
try {
|
||||||
|
await deleteMailTemplateList(checkedIds.value);
|
||||||
|
checkedIds.value = [];
|
||||||
|
ElMessage.success($t('ui.actionMessage.deleteSuccess'));
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
loadingInstance.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const checkedIds = ref<number[]>([]);
|
const checkedIds = ref<number[]>([]);
|
||||||
@@ -95,33 +98,12 @@ function handleRowCheckboxChange({
|
|||||||
checkedIds.value = records.map((item) => item.id!);
|
checkedIds.value = records.map((item) => item.id!);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 表格操作按钮的回调函数 */
|
|
||||||
function onActionClick({
|
|
||||||
code,
|
|
||||||
row,
|
|
||||||
}: OnActionClickParams<SystemMailTemplateApi.MailTemplate>) {
|
|
||||||
switch (code) {
|
|
||||||
case 'delete': {
|
|
||||||
onDelete(row);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'edit': {
|
|
||||||
onEdit(row);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'send': {
|
|
||||||
onSend(row);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const [Grid, gridApi] = useVbenVxeGrid({
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
formOptions: {
|
formOptions: {
|
||||||
schema: useGridFormSchema(),
|
schema: useGridFormSchema(),
|
||||||
},
|
},
|
||||||
gridOptions: {
|
gridOptions: {
|
||||||
columns: useGridColumns(onActionClick, getAccountMail),
|
columns: useGridColumns(getAccountMail),
|
||||||
height: 'auto',
|
height: 'auto',
|
||||||
keepSource: true,
|
keepSource: true,
|
||||||
proxyConfig: {
|
proxyConfig: {
|
||||||
@@ -137,6 +119,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
},
|
},
|
||||||
rowConfig: {
|
rowConfig: {
|
||||||
keyField: 'id',
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
},
|
},
|
||||||
toolbarConfig: {
|
toolbarConfig: {
|
||||||
refresh: true,
|
refresh: true,
|
||||||
@@ -160,7 +143,7 @@ onMounted(async () => {
|
|||||||
<DocAlert title="邮件配置" url="https://doc.iocoder.cn/mail" />
|
<DocAlert title="邮件配置" url="https://doc.iocoder.cn/mail" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<FormModal @success="onRefresh" />
|
<FormModal @success="handleRefresh" />
|
||||||
<SendModal />
|
<SendModal />
|
||||||
<Grid table-title="邮件模板列表">
|
<Grid table-title="邮件模板列表">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
@@ -171,7 +154,7 @@ onMounted(async () => {
|
|||||||
type: 'primary',
|
type: 'primary',
|
||||||
icon: ACTION_ICON.ADD,
|
icon: ACTION_ICON.ADD,
|
||||||
auth: ['system:mail-template:create'],
|
auth: ['system:mail-template:create'],
|
||||||
onClick: onCreate,
|
onClick: handleCreate,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('ui.actionTitle.deleteBatch'),
|
label: $t('ui.actionTitle.deleteBatch'),
|
||||||
@@ -179,7 +162,40 @@ onMounted(async () => {
|
|||||||
icon: ACTION_ICON.DELETE,
|
icon: ACTION_ICON.DELETE,
|
||||||
disabled: isEmpty(checkedIds),
|
disabled: isEmpty(checkedIds),
|
||||||
auth: ['system:mail-template:delete'],
|
auth: ['system:mail-template:delete'],
|
||||||
onClick: onDeleteBatch,
|
onClick: handleDeleteBatch,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('common.edit'),
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.EDIT,
|
||||||
|
auth: ['system:mail-template:update'],
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '测试',
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.VIEW,
|
||||||
|
auth: ['system:mail-template:send-mail'],
|
||||||
|
onClick: handleSend.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.delete'),
|
||||||
|
type: 'danger',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
|
auth: ['system:mail-template:delete'],
|
||||||
|
popConfirm: {
|
||||||
|
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
|
||||||
|
confirm: handleDelete.bind(null, row),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Modal :title="getTitle">
|
<Modal :title="getTitle" class="w-1/3">
|
||||||
<Form class="mx-4" />
|
<Form class="mx-4" />
|
||||||
</Modal>
|
</Modal>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
});
|
});
|
||||||
|
|
||||||
/** 动态构建表单 schema */
|
/** 动态构建表单 schema */
|
||||||
const buildFormSchema = () => {
|
function buildFormSchema() {
|
||||||
const schema = useSendMailFormSchema();
|
const schema = useSendMailFormSchema();
|
||||||
if (formData.value?.params) {
|
if (formData.value?.params) {
|
||||||
formData.value.params?.forEach((param: string) => {
|
formData.value.params?.forEach((param: string) => {
|
||||||
@@ -108,11 +108,11 @@ const buildFormSchema = () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
return schema;
|
return schema;
|
||||||
};
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Modal title="测试发送邮件">
|
<Modal title="测试发送邮件" class="w-1/3">
|
||||||
<Form class="mx-4" />
|
<Form class="mx-4" />
|
||||||
</Modal>
|
</Modal>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user