feat: 保存发送邮件

2.0/email-builder
Lei OT 11 months ago
parent 42d3247a92
commit 1cc49126ee

@ -211,21 +211,24 @@ export const sentMsgTypeMapped = {
}, },
email: { email: {
type: 'email', type: 'email',
contentToSend: (msg) => ({ // contentToSend: (msg) => ({
action: 'message', // action: 'message',
actionId: msg.id, // actionId: msg.id,
renderId: msg.id, // renderId: msg.id,
to: msg.to, // to: msg.to,
msgtype: 'email', // msgtype: 'email',
msgcontent: { body: msg.text, preview_url: true, }, // msgcontent: { body: msg.text, preview_url: true, },
}), // }),
contentToRender: (msg) => ({ contentToRender: (msg) => ({
...msg, ...msg,
whatsapp_msg_type: 'email', whatsapp_msg_type: '',
actionId: msg.id, actionId: msg.id,
conversationid: msg.id.split('.')[0], conversationid: msg.id.split('.')[0],
originText: msg.text, originText: msg.text,
text: (msg.text), text: (msg.text),
msgtext: {
...msg,
},
}), }),
}, },
}; };
@ -513,7 +516,7 @@ export const whatsappMsgTypeMapped = {
}, },
}, },
email: { email: {
data: (msg) => ({ id: msg.id, subject: msg.email.subject, originText: msg.text.body, title: msg?.customerProfile?.name || '' }), data: (msg) => ({ id: msg.id, subject: msg.email.subject, title: msg?.customerProfile?.name || '' }),
}, },
}; };
/** /**

@ -49,7 +49,7 @@ const EmailDetail = ({ open, setOpen, emailMsg, ...props }) => {
const [mobile] = useStyleStore((state) => [state.mobile]) const [mobile] = useStyleStore((state) => [state.mobile])
const [mailData, setMailData] = useState({info: {}, content: {}, attachments: []}) const [mailData, setMailData] = useState({info: {}, content: '', attachments: []})
const getEmailDetail = async () => { const getEmailDetail = async () => {
const data = await getEmailDetailAction({ mai_sn: msg_id }) const data = await getEmailDetailAction({ mai_sn: msg_id })
console.log('data', data); console.log('data', data);

@ -3,9 +3,15 @@ import { Button, ConfigProvider, Dropdown, Flex } from 'antd';
import { DownOutlined } from '@ant-design/icons'; import { DownOutlined } from '@ant-design/icons';
import EmailEditorPopup from './EmailEditorPopup'; import EmailEditorPopup from './EmailEditorPopup';
import useStyleStore from '@/stores/StyleStore'; import useStyleStore from '@/stores/StyleStore';
// import { isEmpty, } from '@/utils/commons';
// import useConversationStore from '@/stores/ConversationStore';
const EmailComposer = ({ ...props }) => { const EmailComposer = ({ ...props }) => {
const [mobile] = useStyleStore((state) => [state.mobile]); const [mobile] = useStyleStore((state) => [state.mobile]);
// const websocketOpened = useConversationStore((state) => state.websocketOpened);
// const currentConversation = useConversationStore((state) => state.currentConversation);
// const talkabled = !isEmpty(currentConversation.sn) && websocketOpened;
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const [fromEmail, setFromEmail] = useState(''); const [fromEmail, setFromEmail] = useState('');
const openEditor = (email_addr, i) => { const openEditor = (email_addr, i) => {
@ -18,6 +24,7 @@ const EmailComposer = ({ ...props }) => {
<span>新邮件:</span> <span>新邮件:</span>
<ConfigProvider theme={{ token: { colorPrimary: '#6366f1' } }}> <ConfigProvider theme={{ token: { colorPrimary: '#6366f1' } }}>
<Dropdown.Button <Dropdown.Button
// disabled={!talkabled}
menu={{ menu={{
selectable: true, selectable: true,
items: [ items: [

@ -186,6 +186,8 @@ const EmailEditorPopup = ({ open, setOpen, fromEmail, reference, quote = {}, ini
sentOrReceivedNewMessage(contentToRender.conversationid, contentToRender); sentOrReceivedNewMessage(contentToRender.conversationid, contentToRender);
}; };
const [sendLoading, setSendLoading] = useState(false);
const onHandleSend = async () => { const onHandleSend = async () => {
console.log('onSend callback', '\nisRichText', isRichText); console.log('onSend callback', '\nisRichText', isRichText);
// console.log(form.getFieldsValue()); // console.log(form.getFieldsValue());
@ -195,19 +197,25 @@ const EmailEditorPopup = ({ open, setOpen, fromEmail, reference, quote = {}, ini
body.attaList = fileList; body.attaList = fileList;
body.opi_sn = 29; // debug: body.opi_sn = 29; // debug:
body.mat_sn = 278; body.mat_sn = 278;
console.log('body', body); // console.log('body', body);
const values = await form.validateFields(); const values = await form.validateFields();
const msgObj = { const msgObj = {
type: 'email', type: 'email',
id: uuid(), id: uuid(),
from: body.from,
to: values.to,
cc: values.cc,
bcc: values.bcc,
email: {
subject: values.subject,
content: body.mailcontent,
},
} }
invokeEmailMessage(msgObj); invokeEmailMessage(msgObj);
setSendLoading(true);
const result = await postSendEmail(body); const result = await postSendEmail(body);
// form.validateFields().then((values) => {
// form.resetFields();
// });
// .catch((err) => {})
setSendLoading(false);
setOpen(false); setOpen(false);
}; };
@ -225,7 +233,7 @@ const EmailEditorPopup = ({ open, setOpen, fromEmail, reference, quote = {}, ini
title={initialForm.subject || `${isEmpty(quote) ? '回复: ' : '写邮件: '} ${fromEmail || ''}`} title={initialForm.subject || `${isEmpty(quote) ? '回复: ' : '写邮件: '} ${fromEmail || ''}`}
footer={ footer={
<div className='w-full flex gap-6 justify-start items-center text-indigo-600'> <div className='w-full flex gap-6 justify-start items-center text-indigo-600'>
<Button type='primary' onClick={onHandleSend}> <Button type='primary' onClick={onHandleSend} loading={sendLoading}>
发送 发送
</Button> </Button>
<Popconfirm description='切换内容为纯文本格式将丢失信件核签名的格式, 确定使用纯文本?' onConfirm={confirmPlainText} open={openPlainTextConfirm} onCancel={() => setOpenPlainTextConfirm(false)}> <Popconfirm description='切换内容为纯文本格式将丢失信件核签名的格式, 确定使用纯文本?' onConfirm={confirmPlainText} open={openPlainTextConfirm} onCancel={() => setOpenPlainTextConfirm(false)}>

@ -142,7 +142,7 @@ const MessagesWrapper = ({ updateRead = true, forceGetMessages }) => {
const [ReferEmailMsg, setReferEmailMsg] = useState(''); const [ReferEmailMsg, setReferEmailMsg] = useState('');
const onOpenEditor = (emailMsgContent) => { const onOpenEditor = (emailMsgContent) => {
const { from } = emailMsgContent; // msgtext const { from } = emailMsgContent; // msgtext
console.log('emailMsgContent', emailMsgContent); // console.log('emailMsgContent', emailMsgContent);
setOpenEmailEditor(true); setOpenEmailEditor(true);
setFromEmail(from); setFromEmail(from);

Loading…
Cancel
Save