|
|
|
@ -12,14 +12,13 @@ import LexicalEditor from '@/components/LexicalEditor'
|
|
|
|
|
import { v4 as uuid } from 'uuid'
|
|
|
|
|
import { cloneDeep, debounce, isEmpty, writeIndexDB, readIndexDB, deleteIndexDBbyKey } from '@/utils/commons'
|
|
|
|
|
import '@/views/Conversations/Online/Input/EmailEditor.css'
|
|
|
|
|
import { parseHTMLString, postSendEmail } from '@/actions/EmailActions'
|
|
|
|
|
import { parseHTMLString, postSendEmail, saveEmailDraftOrSendAction } from '@/actions/EmailActions'
|
|
|
|
|
import { sentMsgTypeMapped } from '@/channel/bubbleMsgUtils'
|
|
|
|
|
import { EmailBuilder, useEmailDetail, useEmailSignature } from '@/hooks/useEmail'
|
|
|
|
|
import useSnippetStore from '@/stores/SnippetStore'
|
|
|
|
|
// import { useOrderStore } from '@/stores/OrderStore'
|
|
|
|
|
import PaymentlinkBtn from '@/views/Conversations/Online/Input/PaymentlinkBtn'
|
|
|
|
|
import { TextIcon } from '@/components/Icons';
|
|
|
|
|
import GenerateAutoDocDrawer from './Conversations/Online/Components/GenerateAutoDocDrawer';
|
|
|
|
|
import { POPUP_FEATURES } from '@/config';
|
|
|
|
|
|
|
|
|
|
// 禁止上传的附件类型
|
|
|
|
@ -68,7 +67,7 @@ const generateQuoteContent = (mailData, isRichText = true) => {
|
|
|
|
|
return isRichText ? html : parseHTMLText(html)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const generateMailContent = (mailData) => `<br><br><p>${mailData.content}</p>`
|
|
|
|
|
const generateMailContent = (mailData) => `<br><p>${mailData.content}</p><br>`
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ! 无状态管理
|
|
|
|
@ -313,6 +312,7 @@ const NewEmail = () => {
|
|
|
|
|
to: info?.MAI_To || '',
|
|
|
|
|
cc: info?.MAI_CS || '',
|
|
|
|
|
subject: info?.MAI_Subject || '',
|
|
|
|
|
id: pageParam.quoteid,
|
|
|
|
|
}
|
|
|
|
|
form.setFieldsValue(thisFormValues)
|
|
|
|
|
const thisBody = generateMailContent(mailData)
|
|
|
|
@ -468,10 +468,12 @@ const NewEmail = () => {
|
|
|
|
|
|
|
|
|
|
const [sendLoading, setSendLoading] = useState(false)
|
|
|
|
|
|
|
|
|
|
const onHandleSend = async () => {
|
|
|
|
|
const onHandleSaveOrSend = async (isDraft = false) => {
|
|
|
|
|
// console.log('onSend callback', '\nisRichText', isRichText);
|
|
|
|
|
// console.log(form.getFieldsValue());
|
|
|
|
|
const body = structuredClone(form.getFieldsValue())
|
|
|
|
|
body.mailtype = ''; // todo: 邮件类型
|
|
|
|
|
// body.id = ''; // todo: 已保存的草稿
|
|
|
|
|
body.from = newFromEmail
|
|
|
|
|
body.attaList = fileList
|
|
|
|
|
body.opi_sn = emailOPI
|
|
|
|
@ -511,7 +513,8 @@ const NewEmail = () => {
|
|
|
|
|
|
|
|
|
|
// console.log('postSendEmail', body, '\n', msgObj);
|
|
|
|
|
// return;
|
|
|
|
|
const result = await postSendEmail(body)
|
|
|
|
|
// todo: 保存后不在草稿箱, 在待发目录
|
|
|
|
|
const result = await saveEmailDraftOrSendAction(body, isDraft)
|
|
|
|
|
const mailSavedId = result.id || ''
|
|
|
|
|
bubbleMsg.email.mai_sn = mailSavedId
|
|
|
|
|
// console.log('invokeEmailMessage', bubbleMsg);
|
|
|
|
@ -526,6 +529,8 @@ const NewEmail = () => {
|
|
|
|
|
// description: error.message,
|
|
|
|
|
placement: 'top',
|
|
|
|
|
duration: 2,
|
|
|
|
|
showProgress: true,
|
|
|
|
|
pauseOnHover: true,
|
|
|
|
|
onClose: () => {
|
|
|
|
|
deleteIndexDBbyKey(editorKey, 'draft', 'mailbox');
|
|
|
|
|
window.close();
|
|
|
|
@ -578,7 +583,7 @@ const NewEmail = () => {
|
|
|
|
|
<>
|
|
|
|
|
<ConfigProvider theme={{ token: { colorPrimary: '#6366f1' } }}>
|
|
|
|
|
<div className='w-full flex gap-4 justify-start items-center text-indigo-600 pb-1 mb-2 border-x-0 border-t-0 border-b border-solid border-neutral-200'>
|
|
|
|
|
<Button type='primary' onClick={onHandleSend} loading={sendLoading} icon={<SendOutlined />}>
|
|
|
|
|
<Button type='primary' onClick={onHandleSaveOrSend} loading={sendLoading} icon={<SendOutlined />}>
|
|
|
|
|
发送
|
|
|
|
|
</Button>
|
|
|
|
|
<Select labelInValue options={emailListOption} value={{ key: newFromEmail, value: newFromEmail, label: newFromEmail }} onChange={handleSwitchEmail} labelRender={item => `发件人: ${item.label || '选择'}`} variant={'borderless'} className='[&_.ant-select-selection-item]:font-bold' />
|
|
|
|
@ -594,7 +599,7 @@ const NewEmail = () => {
|
|
|
|
|
{/* <Button type='link' size='small' icon={<TextIcon />} className=' ' >纯文本</Button> */}
|
|
|
|
|
<Radio.Group options={[{label: '纯文本', value: false}, {label: '富文本', value: true}]} optionType="button" buttonStyle="solid" onChange={handlePlainTextOpenChange} value={isRichText} size='small' />
|
|
|
|
|
</Popconfirm>
|
|
|
|
|
<Button type='dashed' icon={<SaveOutlined />} size='small' className='' >存草稿</Button>
|
|
|
|
|
<Button onClick={() => onHandleSaveOrSend(true)} type='dashed' icon={<SaveOutlined />} size='small' className='' >存草稿</Button>
|
|
|
|
|
</div>
|
|
|
|
|
<Form
|
|
|
|
|
form={form}
|
|
|
|
@ -667,6 +672,9 @@ const NewEmail = () => {
|
|
|
|
|
<Form.Item name='abstract' hidden>
|
|
|
|
|
<Input />
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item name='id' hidden>
|
|
|
|
|
<Input />
|
|
|
|
|
</Form.Item>
|
|
|
|
|
</Form>
|
|
|
|
|
<LexicalEditor {...{ isRichText }} onChange={handleEditorChange} defaultValue={initialContent} />
|
|
|
|
|
{pageParam.quoteid && pageParam.action!=='edit' && !showQuoteContent && (
|
|
|
|
|