@@ -1473,4 +1473,20 @@ export function deleteSystemCriterionKeyFile(systemCriterionKeyFileId) {
|
||||
url: `/SystemCriterionKeyFile/deleteSystemCriterionKeyFile/${systemCriterionKeyFileId}`,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
// 获取所有邮件模板
|
||||
export function getAllEmailNoticeConfigList(param) {
|
||||
return request({
|
||||
url: `/EmailNoticeConfig/getAllEmailNoticeConfigList`,
|
||||
method: 'post',
|
||||
data: param
|
||||
})
|
||||
}
|
||||
// 发送自定义邮件
|
||||
export function manualSendEmail(param) {
|
||||
return request({
|
||||
url: `/EmailNoticeConfig/manualSendEmail`,
|
||||
method: 'post',
|
||||
data: param
|
||||
})
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
<template>
|
||||
<div class="customEmail">
|
||||
<div class="customEmail" v-loading="loading">
|
||||
<div class="emailConfig">
|
||||
<h3>{{ $t("trials:emailManageCfg:customEmail:title:emailConfig") }}</h3>
|
||||
<el-form :inline="true" :model="emailConfig" :rules="emailConfigRule" class="demo-form-inline">
|
||||
<el-form :inline="true" :model="emailConfig" :rules="emailConfigRule" class="demo-form-inline" ref="emailConfig">
|
||||
<el-form-item :label="$t('trials:emailManageCfg:customEmail:label:consigneeEmail')" prop="EMail">
|
||||
<el-input v-model="emailConfig.EMail" placeholder=""></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('trials:emailManageCfg:customEmail:label:consigneeName')" prop="EMail">
|
||||
<el-input v-model="emailConfig.EMail" placeholder=""></el-input>
|
||||
<el-form-item :label="$t('trials:emailManageCfg:customEmail:label:consigneeName')" prop="Name">
|
||||
<el-input v-model="emailConfig.Name" placeholder=""></el-input>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item :label="$t('trials:emailManageCfg:customEmail:label:addresserEmail')" prop="EMail">
|
||||
<el-input v-model="emailConfig.EMail" placeholder=""></el-input>
|
||||
@@ -24,7 +24,8 @@
|
||||
<div style="display: flex;">
|
||||
<div style="width: 48%;margin-right: 2%;">
|
||||
<el-form-item :label="$t('trials:emailManageCfg:customEmail:label:emailTemplate')">
|
||||
<el-select v-model="emailTemplate.Id" placeholder="" style="width: 100%;" @change="handleChange">
|
||||
<el-select v-model="emailTemplate.Id" placeholder="" filterable clearable style="width: 100%;"
|
||||
@change="handleChange" @clear="reset">
|
||||
<el-option v-for="item in list" :key="item.Id" :label="isEN ? item.EmailTopic : item.EmailTopicCN"
|
||||
:value="item.Id">
|
||||
</el-option>
|
||||
@@ -44,13 +45,13 @@
|
||||
<el-input v-model="emailTemplate.EmailHtmlContentCN" placeholder="" disabled type="textarea"
|
||||
:rows="10"></el-input>
|
||||
</el-form-item>
|
||||
<el-button size=" small" type="primary" @click="sendEmail">
|
||||
<el-button size=" small" type="primary" :disabled="!isFull" @click="sendEmail">
|
||||
{{ $t('trials:emailManageCfg:customEmail:button:sendEmail') }}
|
||||
</el-button>
|
||||
<el-button size="small">
|
||||
{{ $t('trials:emailManageCfg:customEmail:button:saveTemplate') }}
|
||||
</el-button>
|
||||
<el-button size="small">
|
||||
<el-button size="small" @click="reset">
|
||||
{{ $t('trials:emailManageCfg:customEmail:button:reset') }}
|
||||
</el-button>
|
||||
</div>
|
||||
@@ -79,7 +80,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { getEmailNoticeConfigList } from '@/api/dictionary'
|
||||
import { getAllEmailNoticeConfigList, manualSendEmail } from '@/api/dictionary'
|
||||
const searchDataDefault = () => {
|
||||
return {
|
||||
IsReturnRequired: '',
|
||||
@@ -97,7 +98,8 @@ export default {
|
||||
loading: false,
|
||||
list: [],
|
||||
emailConfig: {
|
||||
EMail: ''
|
||||
EMail: '',
|
||||
Name: ''
|
||||
},
|
||||
emailHtmlContent: null,
|
||||
emailTemplate: {
|
||||
@@ -123,6 +125,13 @@ export default {
|
||||
message: this.$t('trials:site:ruleMessage:correctEmail'),
|
||||
trigger: ['blur'],
|
||||
}
|
||||
],
|
||||
Name: [
|
||||
{
|
||||
required: true,
|
||||
message: this.$t('common:ruleMessage:specify'),
|
||||
trigger: 'blur',
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -131,14 +140,29 @@ export default {
|
||||
isEN() {
|
||||
return this.$i18n.locale !== 'zh'
|
||||
},
|
||||
isFull() {
|
||||
if (!this.emailTemplate.Id) return false
|
||||
if (Object.keys(this.placeholderData).length === 0) return false
|
||||
if (Object.keys(this.placeholderData).some(key => !this.placeholderData[key])) return false
|
||||
return true
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getList()
|
||||
},
|
||||
methods: {
|
||||
reset() {
|
||||
Object.keys(this.emailTemplate).forEach(key => {
|
||||
this.emailTemplate[key] = null
|
||||
})
|
||||
this.emailHtmlContent = null
|
||||
this.emailSubject = []
|
||||
this.emailContent = []
|
||||
this.placeholderData = {}
|
||||
},
|
||||
getList() {
|
||||
this.loading = true
|
||||
getEmailNoticeConfigList(this.searchData).then(res => {
|
||||
getAllEmailNoticeConfigList(this.searchData).then(res => {
|
||||
this.loading = false
|
||||
this.list = res.Result.CurrentPageData
|
||||
}).catch(() => { this.loading = false })
|
||||
@@ -188,13 +212,41 @@ export default {
|
||||
let emailHtmlContent = this.isEN ? this.emailTemplate.EmailHtmlContent : this.emailTemplate.EmailHtmlContentCN
|
||||
this.emailContent.forEach(item => {
|
||||
if (this.placeholderData[item.key]) {
|
||||
emailHtmlContent = emailHtmlContent.replace(item.name, this.placeholderData[item.key])
|
||||
emailHtmlContent = emailHtmlContent.replaceAll(item.name, this.placeholderData[item.key])
|
||||
}
|
||||
})
|
||||
this.emailHtmlContent = emailHtmlContent
|
||||
},
|
||||
sendEmail() {
|
||||
console.log(this.placeholderData)
|
||||
async sendEmail() {
|
||||
try {
|
||||
let validate = this.$refs.emailConfig.validate()
|
||||
if (!validate) return false
|
||||
let data = {
|
||||
TrialId: this.$route.query.trialId,
|
||||
ToEmailList: [
|
||||
{
|
||||
Name: this.emailConfig.Name,
|
||||
EmailAddress: this.emailConfig.EMail,
|
||||
}
|
||||
],
|
||||
Subject: null,
|
||||
Content: this.emailHtmlContent
|
||||
}
|
||||
let Subject = this.isEN ? this.emailTemplate.EmailTopic : this.emailTemplate.EmailTopicCN
|
||||
this.emailSubject.forEach(item => {
|
||||
if (this.placeholderData[item.key]) {
|
||||
Subject = Subject.replaceAll(item.name, this.placeholderData[item.key])
|
||||
}
|
||||
})
|
||||
data.Subject = Subject
|
||||
this.loading = true
|
||||
let res = await manualSendEmail(data)
|
||||
this.loading = false
|
||||
if (res.IsSuccess) this.$message.success(this.$t('trials:emailManageCfg:message:sendEmailSuccess'))
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
this.loading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user