|
|
@ -1,8 +1,7 @@
|
|
|
|
import { useEffect, useState, useRef, useCallback, useMemo } from 'react'
|
|
|
|
import { useEffect, useState, useRef, useCallback, useMemo } from 'react'
|
|
|
|
import { useParams, useNavigate, useLocation } from 'react-router-dom';
|
|
|
|
import { useParams, useNavigate, useLocation } from 'react-router-dom';
|
|
|
|
import { App, ConfigProvider, Button, Form, Input, Flex, Checkbox, Popconfirm, Select, Space, Upload, Divider, Modal, Tabs, Radio, Typography } from 'antd'
|
|
|
|
import { App, ConfigProvider, Button, Form, Input, Flex, Checkbox, Popconfirm, Select, Space, Upload, Divider, Modal, Tabs, Radio, Typography, } from 'antd'
|
|
|
|
import { UploadOutlined, LoadingOutlined, SaveOutlined, SendOutlined, CheckCircleOutlined } from '@ant-design/icons'
|
|
|
|
import { UploadOutlined, LoadingOutlined, SaveOutlined, SendOutlined, CheckCircleOutlined, ExclamationCircleFilled } from '@ant-design/icons'
|
|
|
|
import '@dckj/react-better-modal/dist/index.css'
|
|
|
|
|
|
|
|
import useStyleStore from '@/stores/StyleStore'
|
|
|
|
import useStyleStore from '@/stores/StyleStore'
|
|
|
|
// import useConversationStore from '@/stores/ConversationStore'
|
|
|
|
// import useConversationStore from '@/stores/ConversationStore'
|
|
|
|
import useAuthStore from '@/stores/AuthStore'
|
|
|
|
import useAuthStore from '@/stores/AuthStore'
|
|
|
@ -23,6 +22,7 @@ import PaymentlinkBtn from '@/views/Conversations/Online/Input/PaymentlinkBtn'
|
|
|
|
import { TextIcon } from '@/components/Icons';
|
|
|
|
import { TextIcon } from '@/components/Icons';
|
|
|
|
import { EMAIL_ATTA_HOST, POPUP_FEATURES } from '@/config';
|
|
|
|
import { EMAIL_ATTA_HOST, POPUP_FEATURES } from '@/config';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const {confirm} = Modal;
|
|
|
|
// 禁止上传的附件类型
|
|
|
|
// 禁止上传的附件类型
|
|
|
|
// .application, .exe, .app
|
|
|
|
// .application, .exe, .app
|
|
|
|
const disallowedAttachmentTypes = [
|
|
|
|
const disallowedAttachmentTypes = [
|
|
|
@ -69,7 +69,7 @@ const generateQuoteContent = (mailData, isRichText = true) => {
|
|
|
|
return isRichText ? html : parseHTMLText(html)
|
|
|
|
return isRichText ? html : parseHTMLText(html)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const generateMailContent = (mailData) => `<p>${mailData.content}</p><br>`
|
|
|
|
const generateMailContent = (mailData) => `${mailData.content}<br>`
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 独立窗口编辑器
|
|
|
|
* 独立窗口编辑器
|
|
|
@ -93,10 +93,14 @@ const NewEmail = () => {
|
|
|
|
const emailListMatMapped = useMemo(() => emailListOption?.reduce((r, v) => ({ ...r, [v.mat_sn]: v }), {}), [emailListOption])
|
|
|
|
const emailListMatMapped = useMemo(() => emailListOption?.reduce((r, v) => ({ ...r, [v.mat_sn]: v }), {}), [emailListOption])
|
|
|
|
// console.log('emailListMapped', emailListOption, emailListAddrMapped);
|
|
|
|
// console.log('emailListMapped', emailListOption, emailListAddrMapped);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const [emailAccount, setEmailAccount] = useState({});
|
|
|
|
|
|
|
|
const [emailAccountOPI, setEmailAccountOPI] = useState(0);
|
|
|
|
|
|
|
|
|
|
|
|
const mai_sn = pageParam.quoteid // activeEdit.quoteid
|
|
|
|
const mai_sn = pageParam.quoteid // activeEdit.quoteid
|
|
|
|
const { loading: quoteLoading, mailData, orderDetail, postEmailSaveOrSend } = useEmailDetail(mai_sn, null, pageParam.oid)
|
|
|
|
const { loading: quoteLoading, mailData, orderDetail, postEmailSaveOrSend } = useEmailDetail(mai_sn, null, pageParam.oid)
|
|
|
|
const { loading: loadingTamplate, templateContent } = useEmailTemplate(templateKey, {coli_sn: pageParam.oid, opi_sn: orderDetail.opi_sn || mailData.info?.MAI_OPI_SN || 0, lgc: 1});
|
|
|
|
const { loading: loadingTamplate, templateContent } = useEmailTemplate(templateKey, {coli_sn: pageParam.oid, opi_sn: orderDetail.opi_sn || mailData.info?.MAI_OPI_SN || 0, lgc: 1});
|
|
|
|
const { signature } = useEmailSignature(orderDetail.opi_sn || mailData.info?.MAI_OPI_SN || 0)
|
|
|
|
const initOPI = useMemo(() => emailAccountOPI || orderDetail.opi_sn || mailData.info?.MAI_OPI_SN || 0, [emailAccountOPI, mailData, orderDetail])
|
|
|
|
|
|
|
|
const { signature } = useEmailSignature(initOPI)
|
|
|
|
|
|
|
|
|
|
|
|
const [initialContent, setInitialContent] = useState('')
|
|
|
|
const [initialContent, setInitialContent] = useState('')
|
|
|
|
const [showQuoteContent, setShowQuoteContent] = useState(false)
|
|
|
|
const [showQuoteContent, setShowQuoteContent] = useState(false)
|
|
|
@ -166,7 +170,7 @@ const NewEmail = () => {
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
// console.log('useEffect 1---- \nform.setFieldsValue ');
|
|
|
|
// console.log('useEffect 1---- \nform.setFieldsValue ');
|
|
|
|
if (isEmpty(mailData.content) && isEmpty(orderDetail.order_no)) {
|
|
|
|
if (isEmpty(mailData.content) && isEmpty(orderDetail.order_no)) {
|
|
|
|
return () => {}
|
|
|
|
// return () => {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const docTitle = mailData.info?.MAI_Subject || 'New Email-';
|
|
|
|
const docTitle = mailData.info?.MAI_Subject || 'New Email-';
|
|
|
|
document.title = docTitle
|
|
|
|
document.title = docTitle
|
|
|
@ -187,13 +191,13 @@ const NewEmail = () => {
|
|
|
|
const quotedMailSender = _findMatOldE?.email || ''
|
|
|
|
const quotedMailSender = _findMatOldE?.email || ''
|
|
|
|
|
|
|
|
|
|
|
|
const sender = quotedMailSender || orderSender
|
|
|
|
const sender = quotedMailSender || orderSender
|
|
|
|
const quotedMailSenderObj = sender; // { key: sender, label: sender, value: sender }
|
|
|
|
const quotedMailSenderObj = emailAccount?.email || sender; // { key: sender, label: sender, value: sender }
|
|
|
|
const defaultMAT = emailListAddrMapped?.[sender]?.mat_sn || ''
|
|
|
|
const defaultMAT = emailListAddrMapped?.[sender]?.mat_sn || ''
|
|
|
|
|
|
|
|
|
|
|
|
const _form2 = {
|
|
|
|
const _form2 = {
|
|
|
|
coli_sn: Number(pageParam.oid) || info?.MAI_COLI_SN || '',
|
|
|
|
coli_sn: Number(pageParam.oid) || info?.MAI_COLI_SN || '',
|
|
|
|
mat_sn: info?.MAI_MAT_SN || defaultMAT,
|
|
|
|
mat_sn: emailAccount?.mat_sn || info?.MAI_MAT_SN || defaultMAT,
|
|
|
|
opi_sn: info?.MAI_OPI_SN || orderDetail.opi_sn || '',
|
|
|
|
opi_sn: emailAccount?.opi_sn || info?.MAI_OPI_SN || orderDetail.opi_sn || '',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let readyToInitialContent = '';
|
|
|
|
let readyToInitialContent = '';
|
|
|
@ -207,6 +211,7 @@ const NewEmail = () => {
|
|
|
|
|
|
|
|
|
|
|
|
// const _initialContent = isEmpty(mailData.info) ? signatureBody : signatureBody+preQuoteBody
|
|
|
|
// const _initialContent = isEmpty(mailData.info) ? signatureBody : signatureBody+preQuoteBody
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 排除草稿: `编辑`有id 的邮件
|
|
|
|
if (!isEmpty(mailData.info) && !['edit'].includes(pageParam.action)) {
|
|
|
|
if (!isEmpty(mailData.info) && !['edit'].includes(pageParam.action)) {
|
|
|
|
readyToInitialContent = orderPrefix + signatureBody
|
|
|
|
readyToInitialContent = orderPrefix + signatureBody
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -260,7 +265,7 @@ const NewEmail = () => {
|
|
|
|
subject: `${info.MAI_Subject || templateFormValues.subject || ''}`,
|
|
|
|
subject: `${info.MAI_Subject || templateFormValues.subject || ''}`,
|
|
|
|
..._form2,
|
|
|
|
..._form2,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
readyToInitialContent = generateMailContent({ content: templateContent.bodycontent || readyToInitialContent || '' })
|
|
|
|
readyToInitialContent = generateMailContent({ content: templateContent.bodycontent || readyToInitialContent || `<br>${signatureBody}` || '' })
|
|
|
|
setFileList(mailData.attachments.map(ele => ({ uid: ele.ATI_SN, name: ele.ATI_Name, url: ele.ATI_ServerFile, fullPath: `${EMAIL_ATTA_HOST}${ele.ATI_ServerFile}` })))
|
|
|
|
setFileList(mailData.attachments.map(ele => ({ uid: ele.ATI_SN, name: ele.ATI_Name, url: ele.ATI_ServerFile, fullPath: `${EMAIL_ATTA_HOST}${ele.ATI_ServerFile}` })))
|
|
|
|
break
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
@ -272,7 +277,7 @@ const NewEmail = () => {
|
|
|
|
setInitialContent(readyToInitialContent);
|
|
|
|
setInitialContent(readyToInitialContent);
|
|
|
|
|
|
|
|
|
|
|
|
return () => {}
|
|
|
|
return () => {}
|
|
|
|
}, [orderDetail.order_no, quoteLoading, loadingTamplate, signature])
|
|
|
|
}, [orderDetail.order_no, quoteLoading, loadingTamplate, emailAccount, signature])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// const readFromTemplate = () => {
|
|
|
|
// const readFromTemplate = () => {
|
|
|
@ -316,6 +321,9 @@ const NewEmail = () => {
|
|
|
|
// setNewFromEmail(value)
|
|
|
|
// setNewFromEmail(value)
|
|
|
|
const _findMat = emailListAddrMapped?.[value]
|
|
|
|
const _findMat = emailListAddrMapped?.[value]
|
|
|
|
form.setFieldsValue({ mat_sn: _findMat?.mat_sn, opi_sn: _findMat?.opi_sn })
|
|
|
|
form.setFieldsValue({ mat_sn: _findMat?.mat_sn, opi_sn: _findMat?.opi_sn })
|
|
|
|
|
|
|
|
// console.log(_findMat, 'handleSwitchEmail')
|
|
|
|
|
|
|
|
setEmailAccount(_findMat)
|
|
|
|
|
|
|
|
setEmailAccountOPI(_findMat?.opi_sn)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const [isRichText, setIsRichText] = useState(mobile === false)
|
|
|
|
const [isRichText, setIsRichText] = useState(mobile === false)
|
|
|
@ -508,7 +516,7 @@ const NewEmail = () => {
|
|
|
|
body.contenttype = isRichText ? 'text/html' : 'text/plain'
|
|
|
|
body.contenttype = isRichText ? 'text/html' : 'text/plain'
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
// console.log('postSendEmail', body, '\n', msgObj);
|
|
|
|
// console.log('postSendEmail', body, '\n');
|
|
|
|
// return;
|
|
|
|
// return;
|
|
|
|
const mailSavedId = await postEmailSaveOrSend(body, isDraft)
|
|
|
|
const mailSavedId = await postEmailSaveOrSend(body, isDraft)
|
|
|
|
form.setFieldsValue({
|
|
|
|
form.setFieldsValue({
|
|
|
|