|
|
|
@ -6,22 +6,25 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div>
|
|
|
|
|
<a-modal
|
|
|
|
|
class="ds-form-detail ds-email-modal ds-modal-small"
|
|
|
|
|
class="ds-email-modal ds-modal-small"
|
|
|
|
|
v-model:visible="visible"
|
|
|
|
|
v-if="visible"
|
|
|
|
|
title="邮件发送"
|
|
|
|
|
width="640px"
|
|
|
|
|
:maskClosable="false"
|
|
|
|
|
>
|
|
|
|
|
<a-spin :spinning="loading">
|
|
|
|
|
<a-form
|
|
|
|
|
class="mt10"
|
|
|
|
|
ref="form"
|
|
|
|
|
layout="vertical"
|
|
|
|
|
autocomplete="off"
|
|
|
|
|
class="ant-form-small"
|
|
|
|
|
:model="formData"
|
|
|
|
|
size="small"
|
|
|
|
|
:rules="rules"
|
|
|
|
|
>
|
|
|
|
|
<a-form-item
|
|
|
|
|
label="收件人"
|
|
|
|
|
name="sendTo"
|
|
|
|
|
>
|
|
|
|
|
<a-select
|
|
|
|
|
v-model:value="formData.sendTo"
|
|
|
|
@ -36,6 +39,7 @@
|
|
|
|
|
</a-form-item>
|
|
|
|
|
<a-form-item
|
|
|
|
|
label="抄送人"
|
|
|
|
|
name="ccTo"
|
|
|
|
|
>
|
|
|
|
|
<a-select
|
|
|
|
|
v-model:value="formData.ccTo"
|
|
|
|
@ -60,7 +64,7 @@
|
|
|
|
|
:maxCount="10"
|
|
|
|
|
:showUploadList="false"
|
|
|
|
|
accept=".xlsm,.xlsx,.xls,.pdf,.txt,.pms,.jpeg,.png"
|
|
|
|
|
@remove="handleRemove"
|
|
|
|
|
@change="fileChange"
|
|
|
|
|
>
|
|
|
|
|
<a-button :loading="floading" type="link" size="mini" class="pl0">
|
|
|
|
|
<span v-show="!floading" class="iconfont icon-fujian1"></span>
|
|
|
|
@ -85,7 +89,7 @@
|
|
|
|
|
</a-form>
|
|
|
|
|
</a-spin>
|
|
|
|
|
<template #footer>
|
|
|
|
|
<a-button @click="send" type="primary">发送</a-button>
|
|
|
|
|
<a-button :loading="sloading" @click="send" type="primary">发送</a-button>
|
|
|
|
|
</template>
|
|
|
|
|
</a-modal>
|
|
|
|
|
</div>
|
|
|
|
@ -110,7 +114,7 @@
|
|
|
|
|
// 业务id
|
|
|
|
|
const id = ref()
|
|
|
|
|
// 附件列表
|
|
|
|
|
const fileList = ref(['asd.jpg'])
|
|
|
|
|
const fileList = ref([])
|
|
|
|
|
// 邮件发送表单数据
|
|
|
|
|
const formData = reactive({
|
|
|
|
|
sendTo: [],
|
|
|
|
@ -118,6 +122,16 @@
|
|
|
|
|
title: '',
|
|
|
|
|
body: ''
|
|
|
|
|
})
|
|
|
|
|
// 表单校验
|
|
|
|
|
const rules = {
|
|
|
|
|
sendTo: [
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: '请选择收件人',
|
|
|
|
|
trigger: 'change'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
// 弹窗开关
|
|
|
|
|
const visible = ref(false)
|
|
|
|
|
const loading = ref(false)
|
|
|
|
@ -138,21 +152,24 @@
|
|
|
|
|
}
|
|
|
|
|
// 附件上传按钮loading
|
|
|
|
|
const floading = ref(false)
|
|
|
|
|
// 附件上传
|
|
|
|
|
function beforeUpload(file) {
|
|
|
|
|
const fileChange = (file) => {
|
|
|
|
|
const postData = new FormData()
|
|
|
|
|
postData.append('formCollection', file)
|
|
|
|
|
postData.append('formCollection', file.file)
|
|
|
|
|
postData.append('linkId', id.value)
|
|
|
|
|
floading.value = true
|
|
|
|
|
AddMultiFiles(postData).then(res => {
|
|
|
|
|
floading.value = false
|
|
|
|
|
console.log(res)
|
|
|
|
|
fileList.value.push(res.data)
|
|
|
|
|
createMessage.success('上传成功!')
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
floading.value = false
|
|
|
|
|
createMessage.error('上传失败!')
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// 阻止默认
|
|
|
|
|
function beforeUpload() {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
// 获取附件模版
|
|
|
|
|
const getTemFile = () => {
|
|
|
|
|
const userStore = useUserStore()
|
|
|
|
@ -164,30 +181,45 @@
|
|
|
|
|
jsonDataStr: ''
|
|
|
|
|
}
|
|
|
|
|
GetOpenJsonPrintInfoByTemplateCode(postData).then(res => {
|
|
|
|
|
console.log(res)
|
|
|
|
|
fileList.value.push(res.data)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// 组件初始化接口 (ids: 联系人id集合,id:公司id,cid:船公司id)
|
|
|
|
|
const init = (ids, data) => {
|
|
|
|
|
visible.value = true
|
|
|
|
|
id.value = data.id
|
|
|
|
|
getEmail(ids)
|
|
|
|
|
if (data.forwarderId) {
|
|
|
|
|
// 获取收件人信息
|
|
|
|
|
const getReceiveInfn = (clientId, cid) => {
|
|
|
|
|
if (clientId) {
|
|
|
|
|
// 获取往来单位联系人列表
|
|
|
|
|
GetClientInfoWithContact({ clientId: data.forwarderId }).then(res => {
|
|
|
|
|
loading.value = true
|
|
|
|
|
GetClientInfoWithContact({ clientId }).then(res => {
|
|
|
|
|
const { data } = res
|
|
|
|
|
loading.value = false
|
|
|
|
|
const list = data.clientContactList
|
|
|
|
|
receiveList.value = []
|
|
|
|
|
console.log(list)
|
|
|
|
|
if (list && list.length) {
|
|
|
|
|
list.forEach(item => {
|
|
|
|
|
if (item.carrierId == data.carrierId && item.email) {
|
|
|
|
|
if (item.carrierId == cid && item.email) {
|
|
|
|
|
receiveList.value.push(item)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
if (!receiveList.value.length) {
|
|
|
|
|
createMessage.warning('未获取到收件人邮箱信息,请到往来单位进行维护!')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 组件初始化接口 (ids: 联系人id集合,data:业务详情数据)
|
|
|
|
|
const init = (ids, data) => {
|
|
|
|
|
fileList.value = []
|
|
|
|
|
formData.sendTo = []
|
|
|
|
|
formData.ccTo = []
|
|
|
|
|
formData.title = ''
|
|
|
|
|
formData.body = ''
|
|
|
|
|
visible.value = true
|
|
|
|
|
id.value = data.id
|
|
|
|
|
// 获取抄送人邮箱
|
|
|
|
|
getEmail(ids)
|
|
|
|
|
// 获取收件人信息
|
|
|
|
|
getReceiveInfn(data.forwarderId, data.carrierId)
|
|
|
|
|
// 获取默认模版附件
|
|
|
|
|
getTemFile()
|
|
|
|
|
// 设置默认邮件主题
|
|
|
|
@ -196,18 +228,33 @@
|
|
|
|
|
const title = (data.loadPort ? data.loadPort + '-' : '') + (data.destination ? data.destination + ' ' : '') + (data.cntrtotal ? data.cntrtotal + ' ' : '') + day
|
|
|
|
|
formData.title = title
|
|
|
|
|
}
|
|
|
|
|
const sloading = ref(false)
|
|
|
|
|
const form = ref(null)
|
|
|
|
|
// 邮件发送
|
|
|
|
|
const send = () => {
|
|
|
|
|
const sendTo = String(formData.sendTo)
|
|
|
|
|
const ccTo = String(formData.ccTo)
|
|
|
|
|
const postData = {
|
|
|
|
|
...formData,
|
|
|
|
|
fileList
|
|
|
|
|
sendTo,
|
|
|
|
|
ccTo,
|
|
|
|
|
title: formData.title,
|
|
|
|
|
body: formData.body,
|
|
|
|
|
fileList: String(fileList.value)
|
|
|
|
|
}
|
|
|
|
|
form.value.validate().then(() => {
|
|
|
|
|
sloading.value = true
|
|
|
|
|
SendShippingOrderEmail(postData).then(res => {
|
|
|
|
|
console.log(res)
|
|
|
|
|
sloading.value = false
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
.catch(error => {
|
|
|
|
|
console.log('error', error);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// 删除附件
|
|
|
|
|
const deleteFile = (index) => {
|
|
|
|
|
fileList.value.splice(index, 1)
|
|
|
|
|
visible.value = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
defineExpose({
|
|
|
|
@ -217,8 +264,9 @@
|
|
|
|
|
<style lang="less">
|
|
|
|
|
.ds-email-modal {
|
|
|
|
|
.file-box {
|
|
|
|
|
min-height: 36px;
|
|
|
|
|
min-height: 32px;
|
|
|
|
|
align-items: center;
|
|
|
|
|
margin-bottom: 4px;
|
|
|
|
|
}
|
|
|
|
|
.file-item {
|
|
|
|
|
display: inline-block;
|
|
|
|
|