reactor:【SYSTEM 系统管理】邮件模版,重构成 element-plus 标准界面
parent
2773b0ec24
commit
e380994dc2
|
|
@ -1,12 +1,52 @@
|
||||||
<template>
|
<template>
|
||||||
<Dialog
|
<Dialog v-model="dialogVisible" :title="dialogTitle" :width="800">
|
||||||
v-model="dialogVisible"
|
<el-form
|
||||||
:max-height="500"
|
ref="formRef"
|
||||||
:scroll="true"
|
v-loading="formLoading"
|
||||||
:title="dialogTitle"
|
:model="formData"
|
||||||
:width="800"
|
:rules="formRules"
|
||||||
>
|
label-width="140px"
|
||||||
<Form ref="formRef" v-loading="formLoading" :rules="rules" :schema="allSchemas.formSchema" />
|
>
|
||||||
|
<el-form-item label="邮箱账号" prop="accountId">
|
||||||
|
<el-select v-model="formData.accountId" placeholder="请选择邮箱账号">
|
||||||
|
<el-option
|
||||||
|
v-for="account in accountList"
|
||||||
|
:key="account.id"
|
||||||
|
:label="account.mail"
|
||||||
|
:value="account.id"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="模板编码" prop="code">
|
||||||
|
<el-input v-model="formData.code" placeholder="请输入模板编码" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="模板名称" prop="name">
|
||||||
|
<el-input v-model="formData.name" placeholder="请输入模板名称" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="发送人名称" prop="nickname">
|
||||||
|
<el-input v-model="formData.nickname" placeholder="请输入发送人名称" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="模板标题" prop="title">
|
||||||
|
<el-input v-model="formData.title" placeholder="请输入模板标题" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="模板内容" prop="content">
|
||||||
|
<Editor v-model="formData.content" height="200px" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="开启状态" prop="status">
|
||||||
|
<el-radio-group v-model="formData.status">
|
||||||
|
<el-radio
|
||||||
|
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
|
||||||
|
:key="dict.value"
|
||||||
|
:value="dict.value"
|
||||||
|
>
|
||||||
|
{{ dict.label }}
|
||||||
|
</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input v-model="formData.remark" placeholder="请输入备注" type="textarea" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
|
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||||
|
|
@ -14,8 +54,10 @@
|
||||||
</Dialog>
|
</Dialog>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||||
import * as MailTemplateApi from '@/api/system/mail/template'
|
import * as MailTemplateApi from '@/api/system/mail/template'
|
||||||
import { allSchemas, rules } from './template.data'
|
import * as MailAccountApi from '@/api/system/mail/account'
|
||||||
|
import { CommonStatusEnum } from '@/utils/constants'
|
||||||
|
|
||||||
defineOptions({ name: 'SystemMailTemplateForm' })
|
defineOptions({ name: 'SystemMailTemplateForm' })
|
||||||
|
|
||||||
|
|
@ -26,23 +68,44 @@ const dialogVisible = ref(false) // 弹窗的是否展示
|
||||||
const dialogTitle = ref('') // 弹窗的标题
|
const dialogTitle = ref('') // 弹窗的标题
|
||||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||||
|
const formData = ref({
|
||||||
|
id: undefined,
|
||||||
|
name: '',
|
||||||
|
code: '',
|
||||||
|
accountId: undefined,
|
||||||
|
nickname: '',
|
||||||
|
title: '',
|
||||||
|
content: '',
|
||||||
|
status: CommonStatusEnum.ENABLE,
|
||||||
|
remark: ''
|
||||||
|
})
|
||||||
|
const formRules = reactive({
|
||||||
|
accountId: [{ required: true, message: '邮箱账号不能为空', trigger: 'change' }],
|
||||||
|
code: [{ required: true, message: '模板编码不能为空', trigger: 'blur' }],
|
||||||
|
name: [{ required: true, message: '模板名称不能为空', trigger: 'blur' }],
|
||||||
|
title: [{ required: true, message: '模板标题不能为空', trigger: 'blur' }],
|
||||||
|
content: [{ required: true, message: '模板内容不能为空', trigger: 'blur' }],
|
||||||
|
status: [{ required: true, message: '开启状态不能为空', trigger: 'blur' }]
|
||||||
|
})
|
||||||
const formRef = ref() // 表单 Ref
|
const formRef = ref() // 表单 Ref
|
||||||
|
const accountList = ref<MailAccountApi.MailAccountVO[]>([]) // 邮箱账号列表
|
||||||
|
|
||||||
/** 打开弹窗 */
|
|
||||||
const open = async (type: string, id?: number) => {
|
const open = async (type: string, id?: number) => {
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
dialogTitle.value = t('action.' + type)
|
dialogTitle.value = t('action.' + type)
|
||||||
formType.value = type
|
formType.value = type
|
||||||
|
resetForm()
|
||||||
// 修改时,设置数据
|
// 修改时,设置数据
|
||||||
if (id) {
|
if (id) {
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
try {
|
try {
|
||||||
const data = await MailTemplateApi.getMailTemplate(id)
|
formData.value = await MailTemplateApi.getMailTemplate(id)
|
||||||
formRef.value.setValues(data)
|
|
||||||
} finally {
|
} finally {
|
||||||
formLoading.value = false
|
formLoading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 加载邮箱账号列表
|
||||||
|
accountList.value = await MailAccountApi.getSimpleMailAccountList()
|
||||||
}
|
}
|
||||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
|
|
@ -51,12 +114,11 @@ const emit = defineEmits(['success']) // 定义 success 事件,用于操作成
|
||||||
const submitForm = async () => {
|
const submitForm = async () => {
|
||||||
// 校验表单
|
// 校验表单
|
||||||
if (!formRef) return
|
if (!formRef) return
|
||||||
const valid = await formRef.value.getElFormRef().validate()
|
const valid = await formRef.value.validate()
|
||||||
if (!valid) return
|
if (!valid) return
|
||||||
// 提交请求
|
|
||||||
formLoading.value = true
|
formLoading.value = true
|
||||||
try {
|
try {
|
||||||
const data = formRef.value.formModel as MailTemplateApi.MailTemplateVO
|
const data = formData.value as MailTemplateApi.MailTemplateVO
|
||||||
if (formType.value === 'create') {
|
if (formType.value === 'create') {
|
||||||
await MailTemplateApi.createMailTemplate(data)
|
await MailTemplateApi.createMailTemplate(data)
|
||||||
message.success(t('common.createSuccess'))
|
message.success(t('common.createSuccess'))
|
||||||
|
|
@ -71,4 +133,20 @@ const submitForm = async () => {
|
||||||
formLoading.value = false
|
formLoading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 重置表单 */
|
||||||
|
const resetForm = () => {
|
||||||
|
formData.value = {
|
||||||
|
id: undefined,
|
||||||
|
name: '',
|
||||||
|
code: '',
|
||||||
|
accountId: undefined,
|
||||||
|
nickname: '',
|
||||||
|
title: '',
|
||||||
|
content: '',
|
||||||
|
status: CommonStatusEnum.ENABLE,
|
||||||
|
remark: ''
|
||||||
|
}
|
||||||
|
formRef.value?.resetFields()
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
v-loading="formLoading"
|
v-loading="formLoading"
|
||||||
:model="formData"
|
:model="formData"
|
||||||
:rules="formRules"
|
:rules="formRules"
|
||||||
label-width="120px"
|
label-width="140px"
|
||||||
>
|
>
|
||||||
<el-form-item label="模板内容" prop="content">
|
<el-form-item label="模板内容" prop="content">
|
||||||
<Editor :model-value="formData.content" height="150px" readonly />
|
<Editor :model-value="formData.content" height="150px" readonly />
|
||||||
|
|
|
||||||
|
|
@ -1,97 +1,259 @@
|
||||||
<template>
|
<template>
|
||||||
<doc-alert title="邮件配置" url="https://doc.iocoder.cn/mail" />
|
<doc-alert title="邮件配置" url="https://doc.iocoder.cn/mail" />
|
||||||
|
|
||||||
<!-- 搜索工作栏 -->
|
|
||||||
<ContentWrap>
|
<ContentWrap>
|
||||||
<Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams">
|
<!-- 搜索工作栏 -->
|
||||||
<!-- 新增等操作按钮 -->
|
<el-form
|
||||||
<template #actionMore>
|
class="-mb-15px"
|
||||||
|
:model="queryParams"
|
||||||
|
ref="queryFormRef"
|
||||||
|
:inline="true"
|
||||||
|
label-width="150px"
|
||||||
|
>
|
||||||
|
<el-form-item label="模板编码" prop="code">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.code"
|
||||||
|
placeholder="请输入模板编码"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="模板名称" prop="name">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.name"
|
||||||
|
placeholder="请输入模板名称"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="邮箱账号" prop="accountId">
|
||||||
|
<el-select
|
||||||
|
v-model="queryParams.accountId"
|
||||||
|
placeholder="请选择邮箱账号"
|
||||||
|
clearable
|
||||||
|
class="!w-240px"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="account in accountList"
|
||||||
|
:key="account.id"
|
||||||
|
:value="account.id"
|
||||||
|
:label="account.mail"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="开启状态" prop="status">
|
||||||
|
<el-select
|
||||||
|
v-model="queryParams.status"
|
||||||
|
placeholder="请选择开启状态"
|
||||||
|
clearable
|
||||||
|
class="!w-240px"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="创建时间" prop="createTime">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="queryParams.createTime"
|
||||||
|
style="width: 240px"
|
||||||
|
type="daterange"
|
||||||
|
value-format="YYYY-MM-DD HH:mm:ss"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
class="!w-240px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||||
|
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
plain
|
plain
|
||||||
@click="openForm('create')"
|
@click="openForm('create')"
|
||||||
v-hasPermi="['system:mail-template:create']"
|
v-hasPermi="['system:mail-template:create']"
|
||||||
>
|
>
|
||||||
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
<Icon icon="ep:plus" class="mr-5px" />新增
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
type="danger"
|
type="danger"
|
||||||
plain
|
plain
|
||||||
|
:disabled="checkedIds.length === 0"
|
||||||
@click="handleDeleteBatch"
|
@click="handleDeleteBatch"
|
||||||
:disabled="!isSelected"
|
|
||||||
v-hasPermi="['system:mail-template:delete']"
|
v-hasPermi="['system:mail-template:delete']"
|
||||||
>
|
>
|
||||||
<Icon icon="ep:delete" class="mr-5px" /> 批量删除
|
<Icon icon="ep:delete" class="mr-5px" />批量删除
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
<el-button
|
||||||
</Search>
|
type="success"
|
||||||
|
plain
|
||||||
|
@click="handleExport"
|
||||||
|
:loading="exportLoading"
|
||||||
|
v-hasPermi="['system:mail-template:export']"
|
||||||
|
>
|
||||||
|
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||||
|
</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
</ContentWrap>
|
</ContentWrap>
|
||||||
|
|
||||||
<!-- 列表 -->
|
<!-- 列表 -->
|
||||||
<ContentWrap>
|
<ContentWrap>
|
||||||
<Table
|
<el-table v-loading="loading" :data="list" @selection-change="handleRowCheckboxChange">
|
||||||
:columns="allSchemas.tableColumns"
|
<el-table-column type="selection" width="55" />
|
||||||
:data="tableObject.tableList"
|
<el-table-column
|
||||||
:loading="tableObject.loading"
|
label="模板编码"
|
||||||
:pagination="{
|
align="center"
|
||||||
total: tableObject.total
|
prop="code"
|
||||||
}"
|
width="120"
|
||||||
v-model:pageSize="tableObject.pageSize"
|
:show-overflow-tooltip="true"
|
||||||
v-model:currentPage="tableObject.currentPage"
|
/>
|
||||||
:selection="true"
|
<el-table-column
|
||||||
>
|
label="模板名称"
|
||||||
<template #action="{ row }">
|
align="center"
|
||||||
<el-button
|
prop="name"
|
||||||
link
|
width="120"
|
||||||
type="primary"
|
:show-overflow-tooltip="true"
|
||||||
@click="openSendForm(row.id)"
|
/>
|
||||||
v-hasPermi="['system:mail-template:send-mail']"
|
<el-table-column
|
||||||
>
|
label="模板标题"
|
||||||
测试
|
align="center"
|
||||||
</el-button>
|
prop="title"
|
||||||
<el-button
|
width="150"
|
||||||
link
|
:show-overflow-tooltip="true"
|
||||||
type="primary"
|
/>
|
||||||
@click="openForm('update', row.id)"
|
<el-table-column
|
||||||
v-hasPermi="['system:mail-template:update']"
|
label="模板内容"
|
||||||
>
|
align="center"
|
||||||
编辑
|
prop="content"
|
||||||
</el-button>
|
width="200"
|
||||||
<el-button
|
:show-overflow-tooltip="true"
|
||||||
link
|
/>
|
||||||
type="danger"
|
<el-table-column label="邮箱账号" align="center" prop="accountId" width="200">
|
||||||
v-hasPermi="['system:mail-template:delete']"
|
<template #default="scope">
|
||||||
@click="handleDelete(row.id)"
|
{{ getAccountMail(scope.row.accountId) }}
|
||||||
>
|
</template>
|
||||||
删除
|
</el-table-column>
|
||||||
</el-button>
|
<el-table-column
|
||||||
</template>
|
label="发送人名称"
|
||||||
</Table>
|
align="center"
|
||||||
|
prop="nickname"
|
||||||
|
width="120"
|
||||||
|
:show-overflow-tooltip="true"
|
||||||
|
/>
|
||||||
|
<el-table-column label="开启状态" align="center" prop="status" width="80">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="创建时间"
|
||||||
|
align="center"
|
||||||
|
prop="createTime"
|
||||||
|
width="180"
|
||||||
|
:formatter="dateFormatter"
|
||||||
|
/>
|
||||||
|
<el-table-column label="操作" align="center" width="210" fixed="right">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
@click="openForm('update', scope.row.id)"
|
||||||
|
v-hasPermi="['system:mail-template:update']"
|
||||||
|
>
|
||||||
|
修改
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
@click="openSendForm(scope.row.id)"
|
||||||
|
v-hasPermi="['system:mail-template:send-mail']"
|
||||||
|
>
|
||||||
|
测试
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="danger"
|
||||||
|
@click="handleDelete(scope.row.id)"
|
||||||
|
v-hasPermi="['system:mail-template:delete']"
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<!-- 分页 -->
|
||||||
|
<Pagination
|
||||||
|
:total="total"
|
||||||
|
v-model:page="queryParams.pageNo"
|
||||||
|
v-model:limit="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
</ContentWrap>
|
</ContentWrap>
|
||||||
|
|
||||||
<!-- 表单弹窗:添加/修改 -->
|
<!-- 表单弹窗:添加/修改 -->
|
||||||
<MailTemplateForm ref="formRef" @success="getList" />
|
<MailTemplateForm ref="formRef" @success="getList" />
|
||||||
|
<!-- 表单弹窗:测试发送 -->
|
||||||
<!-- 表单弹窗:发送测试 -->
|
|
||||||
<MailTemplateSendForm ref="sendFormRef" />
|
<MailTemplateSendForm ref="sendFormRef" />
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { allSchemas } from './template.data'
|
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||||
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
import * as MailTemplateApi from '@/api/system/mail/template'
|
import * as MailTemplateApi from '@/api/system/mail/template'
|
||||||
|
import * as MailAccountApi from '@/api/system/mail/account'
|
||||||
|
import download from '@/utils/download'
|
||||||
import MailTemplateForm from './MailTemplateForm.vue'
|
import MailTemplateForm from './MailTemplateForm.vue'
|
||||||
import MailTemplateSendForm from './MailTemplateSendForm.vue'
|
import MailTemplateSendForm from './MailTemplateSendForm.vue'
|
||||||
|
|
||||||
defineOptions({ name: 'SystemMailTemplate' })
|
defineOptions({ name: 'SystemMailTemplate' })
|
||||||
|
|
||||||
// tableObject:表格的属性对象,可获得分页大小、条数等属性
|
const message = useMessage() // 消息弹窗
|
||||||
// tableMethods:表格的操作对象,可进行获得分页、删除记录等操作
|
const { t } = useI18n() // 国际化
|
||||||
// 详细可见:https://doc.iocoder.cn/vue3/crud-schema/
|
|
||||||
const { tableObject, tableMethods } = useTable({
|
const loading = ref(false) // 列表的加载中
|
||||||
getListApi: MailTemplateApi.getMailTemplatePage, // 分页接口
|
const total = ref(0) // 列表的总页数
|
||||||
delListApi: MailTemplateApi.deleteMailTemplate // 删除接口
|
const list = ref([]) // 列表的数据
|
||||||
|
const queryFormRef = ref() // 搜索的表单
|
||||||
|
const queryParams = reactive({
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
code: '',
|
||||||
|
name: '',
|
||||||
|
accountId: undefined,
|
||||||
|
status: undefined,
|
||||||
|
createTime: []
|
||||||
})
|
})
|
||||||
// 获得表格的各种操作
|
const exportLoading = ref(false) // 导出的加载中
|
||||||
const { getList, setSearchParams } = tableMethods
|
const accountList = ref<MailAccountApi.MailAccountVO[]>([]) // 邮箱账号列表
|
||||||
|
|
||||||
|
/** 查询列表 */
|
||||||
|
const getList = async () => {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const data = await MailTemplateApi.getMailTemplatePage(queryParams)
|
||||||
|
list.value = data.list
|
||||||
|
total.value = data.total
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
const handleQuery = () => {
|
||||||
|
queryParams.pageNo = 1
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
const resetQuery = () => {
|
||||||
|
queryFormRef.value.resetFields()
|
||||||
|
handleQuery()
|
||||||
|
}
|
||||||
|
|
||||||
/** 添加/修改操作 */
|
/** 添加/修改操作 */
|
||||||
const formRef = ref()
|
const formRef = ref()
|
||||||
|
|
@ -99,32 +261,68 @@ const openForm = (type: string, id?: number) => {
|
||||||
formRef.value.open(type, id)
|
formRef.value.open(type, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 删除按钮操作 */
|
/** 发送邮件按钮 */
|
||||||
const handleDelete = (id: number) => {
|
|
||||||
tableMethods.delList(id, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 是否有选中行 */
|
|
||||||
const isSelected = computed(() => {
|
|
||||||
return tableObject.selections && tableObject.selections.length > 0
|
|
||||||
})
|
|
||||||
|
|
||||||
/** 批量删除按钮操作 */
|
|
||||||
const handleDeleteBatch = async () => {
|
|
||||||
const ids = tableObject.selections.map(item => item.id)
|
|
||||||
if (ids.length === 0) return
|
|
||||||
await MailTemplateApi.deleteMailTemplateList(ids)
|
|
||||||
tableMethods.getList()
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 发送测试操作 */
|
|
||||||
const sendFormRef = ref()
|
const sendFormRef = ref()
|
||||||
const openSendForm = (id: number) => {
|
const openSendForm = (id: number) => {
|
||||||
sendFormRef.value.open(id)
|
sendFormRef.value.open(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
const handleDelete = async (id: number) => {
|
||||||
|
try {
|
||||||
|
// 删除的二次确认
|
||||||
|
await message.delConfirm()
|
||||||
|
// 发起删除
|
||||||
|
await MailTemplateApi.deleteMailTemplate(id)
|
||||||
|
message.success(t('common.delSuccess'))
|
||||||
|
// 刷新列表
|
||||||
|
await getList()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 批量删除按钮操作 */
|
||||||
|
const checkedIds = ref<number[]>([])
|
||||||
|
const handleRowCheckboxChange = (rows: MailTemplateApi.MailTemplateVO[]) => {
|
||||||
|
checkedIds.value = rows.map((row) => row.id!)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleDeleteBatch = async () => {
|
||||||
|
try {
|
||||||
|
// 删除的二次确认
|
||||||
|
await message.delConfirm()
|
||||||
|
// 发起批量删除
|
||||||
|
await MailTemplateApi.deleteMailTemplateList(checkedIds.value)
|
||||||
|
message.success(t('common.delSuccess'))
|
||||||
|
// 刷新列表
|
||||||
|
await getList()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
const handleExport = async () => {
|
||||||
|
try {
|
||||||
|
// 导出的二次确认
|
||||||
|
await message.exportConfirm()
|
||||||
|
// 发起导出
|
||||||
|
exportLoading.value = true
|
||||||
|
const data = await MailTemplateApi.exportMailTemplate(queryParams)
|
||||||
|
download.excel(data, '邮件模板.xls')
|
||||||
|
} catch {
|
||||||
|
} finally {
|
||||||
|
exportLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取邮箱账号名称 */
|
||||||
|
const getAccountMail = (accountId: number) => {
|
||||||
|
const account = accountList.value.find((account) => account.id === accountId)
|
||||||
|
return account?.mail || ''
|
||||||
|
}
|
||||||
|
|
||||||
/** 初始化 **/
|
/** 初始化 **/
|
||||||
onMounted(() => {
|
onMounted(async () => {
|
||||||
getList()
|
await getList()
|
||||||
|
// 加载邮箱账号列表
|
||||||
|
accountList.value = await MailAccountApi.getSimpleMailAccountList()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -1,140 +0,0 @@
|
||||||
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
|
|
||||||
import { dateFormatter } from '@/utils/formatTime'
|
|
||||||
import { TableColumn } from '@/types/table'
|
|
||||||
import * as MailAccountApi from '@/api/system/mail/account'
|
|
||||||
|
|
||||||
// 邮箱账号的列表
|
|
||||||
const accountList = await MailAccountApi.getSimpleMailAccountList()
|
|
||||||
|
|
||||||
// 表单校验
|
|
||||||
export const rules = reactive({
|
|
||||||
name: [required],
|
|
||||||
code: [required],
|
|
||||||
accountId: [required],
|
|
||||||
label: [required],
|
|
||||||
content: [required],
|
|
||||||
params: [required],
|
|
||||||
status: [required]
|
|
||||||
})
|
|
||||||
|
|
||||||
// CrudSchema:https://doc.iocoder.cn/vue3/crud-schema/
|
|
||||||
const crudSchemas = reactive<CrudSchema[]>([
|
|
||||||
{
|
|
||||||
label: '模板编码',
|
|
||||||
field: 'code',
|
|
||||||
isSearch: true,
|
|
||||||
search: {
|
|
||||||
componentProps: {
|
|
||||||
style: {
|
|
||||||
width: '240px'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '模板名称',
|
|
||||||
field: 'name',
|
|
||||||
isSearch: true,
|
|
||||||
search: {
|
|
||||||
componentProps: {
|
|
||||||
style: {
|
|
||||||
width: '240px'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '模板标题',
|
|
||||||
field: 'title'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '模板内容',
|
|
||||||
field: 'content',
|
|
||||||
form: {
|
|
||||||
component: 'Editor',
|
|
||||||
componentProps: {
|
|
||||||
valueHtml: '',
|
|
||||||
height: 200
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '邮箱账号',
|
|
||||||
field: 'accountId',
|
|
||||||
width: '200px',
|
|
||||||
formatter: (_: Recordable, __: TableColumn, cellValue: number) => {
|
|
||||||
return accountList.find((account) => account.id === cellValue)?.mail
|
|
||||||
},
|
|
||||||
search: {
|
|
||||||
show: true,
|
|
||||||
component: 'Select',
|
|
||||||
api: () => accountList,
|
|
||||||
componentProps: {
|
|
||||||
optionsAlias: {
|
|
||||||
labelField: 'mail',
|
|
||||||
valueField: 'id'
|
|
||||||
},
|
|
||||||
style: {
|
|
||||||
width: '240px'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
form: {
|
|
||||||
component: 'Select',
|
|
||||||
api: () => accountList,
|
|
||||||
componentProps: {
|
|
||||||
optionsAlias: {
|
|
||||||
labelField: 'mail',
|
|
||||||
valueField: 'id'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '发送人名称',
|
|
||||||
field: 'nickname'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '开启状态',
|
|
||||||
field: 'status',
|
|
||||||
isSearch: true,
|
|
||||||
dictType: DICT_TYPE.COMMON_STATUS,
|
|
||||||
dictClass: 'number',
|
|
||||||
search: {
|
|
||||||
componentProps: {
|
|
||||||
style: {
|
|
||||||
width: '240px'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '备注',
|
|
||||||
field: 'remark',
|
|
||||||
isTable: false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '创建时间',
|
|
||||||
field: 'createTime',
|
|
||||||
isForm: false,
|
|
||||||
formatter: dateFormatter,
|
|
||||||
search: {
|
|
||||||
show: true,
|
|
||||||
component: 'DatePicker',
|
|
||||||
componentProps: {
|
|
||||||
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
|
||||||
type: 'daterange',
|
|
||||||
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')],
|
|
||||||
style: {
|
|
||||||
width: '240px'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '操作',
|
|
||||||
field: 'action',
|
|
||||||
isForm: false
|
|
||||||
}
|
|
||||||
])
|
|
||||||
export const { allSchemas } = useCrudSchemas(crudSchemas)
|
|
||||||
Loading…
Reference in New Issue