邮件管理模板添加预览功能
continuous-integration/drone/push Build is passing Details

uat_us
DESKTOP-6C3NK6N\WXS 2024-10-12 10:31:36 +08:00
parent 98c42c7b6a
commit 109470ca1a
2 changed files with 207 additions and 161 deletions

View File

@ -99,7 +99,7 @@
v-model="form.EmailUrgentEnum" v-model="form.EmailUrgentEnum"
@change=" @change="
(v) => { (v) => {
v === 1 ? (form.EmailCron = null) : null; v === 1 ? (form.EmailCron = null) : null
} }
" "
clearable clearable
@ -146,7 +146,7 @@
v-model="form.IsDistinguishCriteria" v-model="form.IsDistinguishCriteria"
@change=" @change="
() => { () => {
form.CriterionTypeEnum = null; form.CriterionTypeEnum = null
} }
" "
> >
@ -196,7 +196,7 @@
size="small" size="small"
type="primary" type="primary"
:disabled="fileListCN.length > 0" :disabled="fileListCN.length > 0"
>{{ $t("common:button:upload") }}</el-button >{{ $t('common:button:upload') }}</el-button
> >
</el-upload> </el-upload>
</el-form-item> </el-form-item>
@ -218,25 +218,49 @@
size="small" size="small"
type="primary" type="primary"
:disabled="fileListEN.length > 0" :disabled="fileListEN.length > 0"
>{{ $t("common:button:upload") }}</el-button >{{ $t('common:button:upload') }}</el-button
> >
</el-upload> </el-upload>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-form-item label="邮件内容模版CN" prop="EmailHtmlContentCN"> <el-form-item
label="邮件内容模版CN"
prop="EmailHtmlContentCN"
style="position: relative"
>
<el-input <el-input
v-model="form.EmailHtmlContentCN" v-model="form.EmailHtmlContentCN"
type="textarea" type="textarea"
:autosize="{ minRows: 8, maxRows: 8 }" :autosize="{ minRows: 8, maxRows: 8 }"
/> />
<el-button
:disabled="!form.EmailHtmlContentCN"
type="text"
@click="PreviewHTML(form.EmailHtmlContentCN)"
style="position: absolute; left: -50px; top: 30px"
>
{{ $t('common:button:preview') }}
</el-button>
</el-form-item> </el-form-item>
<el-form-item label="邮件内容模版EN" prop="EmailHtmlContent"> <el-form-item
label="邮件内容模版EN"
prop="EmailHtmlContent"
style="position: relative"
>
<el-input <el-input
v-model="form.EmailHtmlContent" v-model="form.EmailHtmlContent"
type="textarea" type="textarea"
:autosize="{ minRows: 8, maxRows: 8 }" :autosize="{ minRows: 8, maxRows: 8 }"
/> />
<el-button
:disabled="!form.EmailHtmlContent"
type="text"
@click="PreviewHTML(form.EmailHtmlContent)"
style="position: absolute; left: -50px; top: 30px"
>
{{ $t('common:button:preview') }}
</el-button>
</el-form-item> </el-form-item>
<div <div
class="base-dialog-footer" class="base-dialog-footer"
@ -259,44 +283,44 @@
</el-form> </el-form>
</template> </template>
<script> <script>
import { Upload, addOrUpdateEmailNoticeConfigList } from "@/api/dictionary"; import { Upload, addOrUpdateEmailNoticeConfigList } from '@/api/dictionary'
export default { export default {
props: { props: {
data: { data: {
type: Object, type: Object,
default() { default() {
return {}; return {}
}, },
}, },
systemLevel: { systemLevel: {
type: Number, type: Number,
default() { default() {
return 0; return 0
}, },
}, },
}, },
data() { data() {
return { return {
expression: "", expression: '',
showCron: false, showCron: false,
form: { form: {
Id: "", Id: '',
Code: "", Code: '',
EmailTopicCN: "", EmailTopicCN: '',
EmailTopic: "", EmailTopic: '',
BusinessLevelEnum: "", BusinessLevelEnum: '',
BusinessModuleEnum: "", BusinessModuleEnum: '',
ToUserTypeList: "", ToUserTypeList: '',
CopyUserTypeList: "", CopyUserTypeList: '',
EmailUrgentEnum: "", EmailUrgentEnum: '',
EmailCron: "", EmailCron: '',
BusinessScenarioEnum: null, BusinessScenarioEnum: null,
EmailHtmlContentCN: "", EmailHtmlContentCN: '',
EmailHtmlContent: "", EmailHtmlContent: '',
AttachPath: "", AttachPath: '',
AttachName: "", AttachName: '',
AttachNameCN: "", AttachNameCN: '',
AttachCNPath: "", AttachCNPath: '',
IsDistinguishCriteria: true, IsDistinguishCriteria: true,
IsReturnRequired: true, IsReturnRequired: true,
IsUrgent: true, IsUrgent: true,
@ -305,173 +329,177 @@ export default {
CriterionTypeEnum: null, CriterionTypeEnum: null,
}, },
rules: { rules: {
Code: [{ required: true, message: "Please select", trigger: ["blur"] }], Code: [{ required: true, message: 'Please select', trigger: ['blur'] }],
BusinessScenarioEnum: [ BusinessScenarioEnum: [
{ required: true, message: "Please select", trigger: ["blur"] }, { required: true, message: 'Please select', trigger: ['blur'] },
], ],
EmailTopicCN: [ EmailTopicCN: [
{ required: true, message: "Please select", trigger: ["blur"] }, { required: true, message: 'Please select', trigger: ['blur'] },
], ],
EmailTopic: [ EmailTopic: [
{ required: true, message: "Please select", trigger: ["blur"] }, { required: true, message: 'Please select', trigger: ['blur'] },
], ],
BusinessLevelEnum: [ BusinessLevelEnum: [
{ required: true, message: "Please select", trigger: ["blur"] }, { required: true, message: 'Please select', trigger: ['blur'] },
], ],
ToUserTypeList: [ ToUserTypeList: [
{ required: true, message: "Please select", trigger: ["blur"] }, { required: true, message: 'Please select', trigger: ['blur'] },
], ],
EmailCron: [ EmailCron: [
{ required: true, message: "Please select", trigger: ["blur"] }, { required: true, message: 'Please select', trigger: ['blur'] },
], ],
EmailUrgentEnum: [ EmailUrgentEnum: [
{ required: true, message: "Please select", trigger: ["blur"] }, { required: true, message: 'Please select', trigger: ['blur'] },
], ],
EmailHtmlContentCN: [ EmailHtmlContentCN: [
{ required: true, message: "Please select", trigger: ["blur"] }, { required: true, message: 'Please select', trigger: ['blur'] },
], ],
EmailHtmlContent: [ EmailHtmlContent: [
{ required: true, message: "Please select", trigger: ["blur"] }, { required: true, message: 'Please select', trigger: ['blur'] },
], ],
CriterionTypeEnum: [ CriterionTypeEnum: [
{ required: true, message: "Please select", trigger: ["blur"] }, { required: true, message: 'Please select', trigger: ['blur'] },
], ],
}, },
scenarioOption: [], scenarioOption: [],
fileListCN: [], fileListCN: [],
fileListEN: [], fileListEN: [],
loading: false, loading: false,
}; }
}, },
mounted() { mounted() {
this.initForm(); this.initForm()
if (this.systemLevel) { if (this.systemLevel) {
if (this.systemLevel === 1) { if (this.systemLevel === 1) {
this.form.ToUserTypeList = []; this.form.ToUserTypeList = []
} }
this.form.CopyUserTypeList = []; this.form.CopyUserTypeList = []
this.form.EmailUrgentEnum = "3"; this.form.EmailUrgentEnum = '3'
this.form.IsReturnRequired = false; this.form.IsReturnRequired = false
this.form.IsDistinguishCriteria = false; this.form.IsDistinguishCriteria = false
} }
}, },
methods: { methods: {
showDialog() { showDialog() {
this.expression = this.form.EmailCron; // cron UI this.expression = this.form.EmailCron // cron UI
this.showCron = true; this.showCron = true
}, },
crontabFill(value) { crontabFill(value) {
this.form.EmailCron = value; this.form.EmailCron = value
}, },
handleRemoveFileCN() { handleRemoveFileCN() {
this.form.AttachNameCN = null; this.form.AttachNameCN = null
this.form.AttachCNPath = null; this.form.AttachCNPath = null
this.fileListCN = []; this.fileListCN = []
}, },
beforeUploadCN() { beforeUploadCN() {
if (this.fileListCN.length > 0) { if (this.fileListCN.length > 0) {
this.$alert("最多只能传一个附件"); this.$alert('最多只能传一个附件')
return; return
} }
}, },
handlePreviewCN(row, r2) { handlePreviewCN(row, r2) {
if (row.fullPath) { if (row.fullPath) {
window.open(row.fullPath, "_blank"); window.open(row.fullPath, '_blank')
} }
}, },
handleUploadFileCN(param) { handleUploadFileCN(param) {
this.btnLoading = true; this.btnLoading = true
const formData = new FormData(); const formData = new FormData()
formData.append("file", param.file); formData.append('file', param.file)
this.form.AttachNameCN = param.file.name; this.form.AttachNameCN = param.file.name
Upload(formData, 3).then((res) => { Upload(formData, 3).then((res) => {
this.form.AttachCNPath = res.Result.FilePath; this.form.AttachCNPath = res.Result.FilePath
this.btnLoading = false; this.btnLoading = false
this.fileListCN.push({ this.fileListCN.push({
name: param.file.name, name: param.file.name,
path: res.Result.FilePath, path: res.Result.FilePath,
fullPath: res.Result.FullFilePath, fullPath: res.Result.FullFilePath,
url: res.Result.FilePath, url: res.Result.FilePath,
}); })
}); })
}, },
handleUploadFileEN(param) { handleUploadFileEN(param) {
this.btnLoading = true; this.btnLoading = true
const formData = new FormData(); const formData = new FormData()
formData.append("file", param.file); formData.append('file', param.file)
this.form.AttachName = param.file.name; this.form.AttachName = param.file.name
Upload(formData, 3).then((res) => { Upload(formData, 3).then((res) => {
this.form.AttachPath = res.Result.FilePath; this.form.AttachPath = res.Result.FilePath
this.btnLoading = false; this.btnLoading = false
this.fileListEN.push({ this.fileListEN.push({
name: param.file.name, name: param.file.name,
path: res.Result.FilePath, path: res.Result.FilePath,
fullPath: res.Result.FullFilePath, fullPath: res.Result.FullFilePath,
url: res.Result.FilePath, url: res.Result.FilePath,
}); })
}); })
}, },
handleRemoveFileEN() { handleRemoveFileEN() {
this.form.AttachName = null; this.form.AttachName = null
this.form.AttachPath = null; this.form.AttachPath = null
this.fileListEN = []; this.fileListEN = []
}, },
beforeUploadEN() { beforeUploadEN() {
if (this.fileListEN.length > 0) { if (this.fileListEN.length > 0) {
this.$alert("最多只能传一个附件"); this.$alert('最多只能传一个附件')
return; return
} }
}, },
handlePreviewEN(row, r2) { handlePreviewEN(row, r2) {
if (row.fullPath) { if (row.fullPath) {
window.open(row.fullPath, "_blank"); window.open(row.fullPath, '_blank')
} }
}, },
async initForm() { async initForm() {
this.loading = true; this.loading = true
// await this.getScenarios() // await this.getScenarios()
for (const k in this.form) { for (const k in this.form) {
if (this.data.hasOwnProperty(k)) { if (this.data.hasOwnProperty(k)) {
this.form[k] = this.data[k]; this.form[k] = this.data[k]
} }
if (k === "AttachPath" && this.form[k]) { if (k === 'AttachPath' && this.form[k]) {
this.fileListEN.push({ this.fileListEN.push({
name: this.data.AttachName, name: this.data.AttachName,
path: this.data.AttachPath, path: this.data.AttachPath,
fullPath: this.data.AttachPath, fullPath: this.data.AttachPath,
url: this.data.AttachPath, url: this.data.AttachPath,
}); })
} }
if (k === "AttachCNPath" && this.form[k]) { if (k === 'AttachCNPath' && this.form[k]) {
this.fileListCN.push({ this.fileListCN.push({
name: this.data.AttachNameCN, name: this.data.AttachNameCN,
path: this.data.AttachCNPath, path: this.data.AttachCNPath,
fullPath: this.data.AttachCNPath, fullPath: this.data.AttachCNPath,
url: this.data.AttachCNPath, url: this.data.AttachCNPath,
}); })
} }
} }
this.loading = false; this.loading = false
}, },
// //
handleSave() { handleSave() {
this.$refs.emailForm.validate((valid) => { this.$refs.emailForm.validate((valid) => {
if (!valid) return; if (!valid) return
this.loading = true; this.loading = true
this.form.systemLevel = this.systemLevel; this.form.systemLevel = this.systemLevel
addOrUpdateEmailNoticeConfigList(this.form) addOrUpdateEmailNoticeConfigList(this.form)
.then((res) => { .then((res) => {
this.loading = false; this.loading = false
this.$emit("closeDialog"); this.$emit('closeDialog')
this.$emit("getList"); this.$emit('getList')
this.$message.success("Saved successfully"); this.$message.success('Saved successfully')
}) })
.catch(() => { .catch(() => {
this.loading = false; this.loading = false
}); })
}); })
},
//
PreviewHTML(html) {
this.$emit('PreviewHTML', html)
}, },
}, },
}; }
</script> </script>

View File

@ -111,7 +111,7 @@
min-width="120" min-width="120"
> >
<template slot-scope="scope"> <template slot-scope="scope">
{{ $fd("CriterionType", scope.row.CriterionTypeEnum) }} {{ $fd('CriterionType', scope.row.CriterionTypeEnum) }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
@ -136,7 +136,7 @@
min-width="100" min-width="100"
> >
<template slot-scope="scope"> <template slot-scope="scope">
{{ $fd("BusinessLevel", scope.row.BusinessLevelEnum) }} {{ $fd('BusinessLevel', scope.row.BusinessLevelEnum) }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
@ -147,7 +147,7 @@
min-width="100" min-width="100"
> >
<template slot-scope="scope"> <template slot-scope="scope">
{{ $fd("BusinessModule", scope.row.BusinessModuleEnum) }} {{ $fd('BusinessModule', scope.row.BusinessModuleEnum) }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
@ -158,7 +158,7 @@
min-width="130" min-width="130"
> >
<template slot-scope="scope"> <template slot-scope="scope">
{{ $fd("Email_BusinessScenario", scope.row.BusinessScenarioEnum) }} {{ $fd('Email_BusinessScenario', scope.row.BusinessScenarioEnum) }}
</template> </template>
</el-table-column> </el-table-column>
<!-- 收件人 --> <!-- 收件人 -->
@ -172,10 +172,10 @@
<template slot-scope="scope"> <template slot-scope="scope">
{{ {{
scope.row.ToUserTypeList.length > 0 scope.row.ToUserTypeList.length > 0
? scope.row.ToUserTypeList.map((v) => $fd("UserType", v)).join( ? scope.row.ToUserTypeList.map((v) => $fd('UserType', v)).join(
"、" '、'
) )
: "" : ''
}} }}
</template> </template>
</el-table-column> </el-table-column>
@ -190,10 +190,10 @@
<template slot-scope="scope"> <template slot-scope="scope">
{{ {{
scope.row.CopyUserTypeList.length > 0 scope.row.CopyUserTypeList.length > 0
? scope.row.CopyUserTypeList.map((v) => $fd("UserType", v)).join( ? scope.row.CopyUserTypeList.map((v) => $fd('UserType', v)).join(
"、" '、'
) )
: "" : ''
}} }}
</template> </template>
</el-table-column> </el-table-column>
@ -206,7 +206,7 @@
v-if="!systemLevel" v-if="!systemLevel"
> >
<template slot-scope="scope"> <template slot-scope="scope">
{{ $fd("EmailUrgent", scope.row.EmailUrgentEnum) }} {{ $fd('EmailUrgent', scope.row.EmailUrgentEnum) }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
@ -246,10 +246,10 @@
> >
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag v-if="scope.row.IsReturnRequired" type="danger"> <el-tag v-if="scope.row.IsReturnRequired" type="danger">
{{ $fd("YesOrNo", scope.row.IsReturnRequired) }} {{ $fd('YesOrNo', scope.row.IsReturnRequired) }}
</el-tag> </el-tag>
<el-tag v-else type="primary">{{ <el-tag v-else type="primary">{{
$fd("YesOrNo", scope.row.IsReturnRequired) $fd('YesOrNo', scope.row.IsReturnRequired)
}}</el-tag> }}</el-tag>
</template> </template>
</el-table-column> </el-table-column>
@ -264,10 +264,10 @@
> >
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag v-if="scope.row.IsAutoSend" type="danger"> <el-tag v-if="scope.row.IsAutoSend" type="danger">
{{ $fd("YesOrNo", scope.row.IsAutoSend) }} {{ $fd('YesOrNo', scope.row.IsAutoSend) }}
</el-tag> </el-tag>
<el-tag v-else type="primary">{{ <el-tag v-else type="primary">{{
$fd("YesOrNo", scope.row.IsAutoSend) $fd('YesOrNo', scope.row.IsAutoSend)
}}</el-tag> }}</el-tag>
</template> </template>
</el-table-column> </el-table-column>
@ -281,10 +281,10 @@
> >
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag v-if="scope.row.IsEnable" type="danger"> <el-tag v-if="scope.row.IsEnable" type="danger">
{{ $fd("YesOrNo", scope.row.IsEnable) }} {{ $fd('YesOrNo', scope.row.IsEnable) }}
</el-tag> </el-tag>
<el-tag v-else type="primary">{{ <el-tag v-else type="primary">{{
$fd("YesOrNo", scope.row.IsEnable) $fd('YesOrNo', scope.row.IsEnable)
}}</el-tag> }}</el-tag>
</template> </template>
</el-table-column> </el-table-column>
@ -340,6 +340,7 @@
:system-level="systemLevel" :system-level="systemLevel"
@closeDialog="closeDialog" @closeDialog="closeDialog"
@getList="getList" @getList="getList"
@PreviewHTML="preview"
/> />
</el-dialog> </el-dialog>
@ -359,131 +360,148 @@
@getList="getList" @getList="getList"
/> />
</el-dialog> </el-dialog>
<!-- 预览模板 -->
<el-dialog
v-if="previewVisible"
:visible.sync="previewVisible"
:close-on-click-modal="false"
title="预览"
fullscreen
custom-class="base-dialog-wrapper"
>
<div v-html="previewHTML"></div>
</el-dialog>
</box-content> </box-content>
</template> </template>
<script> <script>
import { import {
getEmailNoticeConfigList, getEmailNoticeConfigList,
deleteEmailNoticeConfig, deleteEmailNoticeConfig,
} from "@/api/dictionary"; } from '@/api/dictionary'
import BoxContent from "@/components/BoxContent"; import BoxContent from '@/components/BoxContent'
import Pagination from "@/components/Pagination"; import Pagination from '@/components/Pagination'
import EmailForm from "./EmailForm"; import EmailForm from './EmailForm'
import AttachmentList from "./AttachmentList"; import AttachmentList from './AttachmentList'
const searchDataDefault = () => { const searchDataDefault = () => {
return { return {
IsReturnRequired: "", IsReturnRequired: '',
IsUrgent: "", IsUrgent: '',
IsEnable: "", IsEnable: '',
CriterionTypeEnum: null, CriterionTypeEnum: null,
PageIndex: 1, PageIndex: 1,
PageSize: 20, PageSize: 20,
}; }
}; }
export default { export default {
name: "EmailList", name: 'EmailList',
components: { BoxContent, Pagination, EmailForm, AttachmentList }, components: { BoxContent, Pagination, EmailForm, AttachmentList },
props: { props: {
isDistinguishCriteria: { isDistinguishCriteria: {
type: Boolean, type: Boolean,
default() { default() {
return false; return false
}, },
}, },
systemLevel: { systemLevel: {
type: Number, type: Number,
default() { default() {
return 0; return 0
}, },
}, },
}, },
data() { data() {
return { return {
activeTab: "0", activeTab: '0',
searchData: searchDataDefault(), searchData: searchDataDefault(),
loading: false, loading: false,
list: [], list: [],
total: 0, total: 0,
rowData: {}, rowData: {},
title: "", title: '',
editVisible: false, editVisible: false,
attachmentVisible: false, attachmentVisible: false,
}; previewVisible: false,
previewHTML: null,
}
}, },
mounted() { mounted() {
this.getList(); this.getList()
}, },
methods: { methods: {
// //
getList() { getList() {
this.loading = true; this.loading = true
this.searchData.IsDistinguishCriteria = this.isDistinguishCriteria; this.searchData.IsDistinguishCriteria = this.isDistinguishCriteria
this.searchData.systemLevel = this.systemLevel; this.searchData.systemLevel = this.systemLevel
getEmailNoticeConfigList(this.searchData) getEmailNoticeConfigList(this.searchData)
.then((res) => { .then((res) => {
this.loading = false; this.loading = false
this.list = res.Result.CurrentPageData; this.list = res.Result.CurrentPageData
this.total = res.Result.TotalCount; this.total = res.Result.TotalCount
}) })
.catch(() => { .catch(() => {
this.loading = false; this.loading = false
}); })
}, },
// //
handleAdd() { handleAdd() {
this.rowData = {}; this.rowData = {}
this.title = "新增"; this.title = '新增'
this.editVisible = true; this.editVisible = true
}, },
// //
handleEdit(row) { handleEdit(row) {
this.rowData = { ...row }; this.rowData = { ...row }
this.title = "编辑"; this.title = '编辑'
this.editVisible = true; this.editVisible = true
}, },
// //
handleDelete(row) { handleDelete(row) {
this.$confirm(this.$t("trials:staffResearch:message:confirmDel"), { this.$confirm(this.$t('trials:staffResearch:message:confirmDel'), {
type: "warning", type: 'warning',
distinguishCancelAndClose: true, distinguishCancelAndClose: true,
}).then(() => { }).then(() => {
deleteEmailNoticeConfig(row.Id).then((res) => { deleteEmailNoticeConfig(row.Id).then((res) => {
if (res.IsSuccess) { if (res.IsSuccess) {
this.getList(); this.getList()
this.$message.success("删除成功!"); this.$message.success('删除成功!')
} }
}); })
}); })
}, },
handleDetail(row) { handleDetail(row) {
this.rowData = { ...row }; this.rowData = { ...row }
this.attachmentVisible = true; this.attachmentVisible = true
}, },
// //
handleSearch() { handleSearch() {
this.searchData.PageIndex = 1; this.searchData.PageIndex = 1
this.getList(); this.getList()
}, },
// //
handleReset() { handleReset() {
this.searchData = searchDataDefault(); this.searchData = searchDataDefault()
this.getList(); this.getList()
}, },
// //
handleSortByColumn(column) { handleSortByColumn(column) {
if (column.order === "ascending") { if (column.order === 'ascending') {
this.searchData.Asc = true; this.searchData.Asc = true
} else { } else {
this.searchData.Asc = false; this.searchData.Asc = false
} }
this.searchData.SortField = column.prop; this.searchData.SortField = column.prop
this.searchData.PageIndex = 1; this.searchData.PageIndex = 1
this.getList(); this.getList()
}, },
// //
closeDialog() { closeDialog() {
this.editVisible = false; this.editVisible = false
},
preview(html) {
this.previewHTML = html
this.previewVisible = true
}, },
}, },
}; }
</script> </script>