feat: 保存发送邮件

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

@ -211,21 +211,24 @@ export const sentMsgTypeMapped = {
},
email: {
type: 'email',
contentToSend: (msg) => ({
action: 'message',
actionId: msg.id,
renderId: msg.id,
to: msg.to,
msgtype: 'email',
msgcontent: { body: msg.text, preview_url: true, },
}),
// contentToSend: (msg) => ({
// action: 'message',
// actionId: msg.id,
// renderId: msg.id,
// to: msg.to,
// msgtype: 'email',
// msgcontent: { body: msg.text, preview_url: true, },
// }),
contentToRender: (msg) => ({
...msg,
whatsapp_msg_type: 'email',
whatsapp_msg_type: '',
actionId: msg.id,
conversationid: msg.id.split('.')[0],
originText: msg.text,
text: (msg.text),
msgtext: {
...msg,
},
}),
},
};
@ -513,7 +516,7 @@ export const whatsappMsgTypeMapped = {
},
},
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 [mailData, setMailData] = useState({info: {}, content: {}, attachments: []})
const [mailData, setMailData] = useState({info: {}, content: '', attachments: []})
const getEmailDetail = async () => {
const data = await getEmailDetailAction({ mai_sn: msg_id })
console.log('data', data);

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

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

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

Loading…
Cancel
Save