|
|
|
@ -64,13 +64,46 @@ const EmailEditorPopup = ({ open, setOpen, fromEmail, fromUser, conversationid,
|
|
|
|
|
const [mobile] = useStyleStore((state) => [state.mobile]);
|
|
|
|
|
const [userId, username, emailList] = useAuthStore((state) => [state.loginUser.userId, state.loginUser.username, state.loginUser.emailList]);
|
|
|
|
|
const emailListOption = emailList?.map(ele => ({ ...ele, label: ele.email, key: ele.email, value: ele.email })) || [];
|
|
|
|
|
const emailListMapped = emailList?.reduce((r, v) => ({ ...r, [v.opi_sn]: v }));
|
|
|
|
|
const emailListMapped = emailListOption?.reduce((r, v) => ({ ...r, [v.opi_sn]: v }), {});
|
|
|
|
|
const emailListAddrMapped = emailListOption?.reduce((r, v) => ({ ...r, [v.email]: v }), {});
|
|
|
|
|
// console.log('emailListMapped', emailListOption, emailListAddrMapped);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const mai_sn = quoteid;
|
|
|
|
|
const {mailData} = useEmailDetail(mai_sn, _mailData);
|
|
|
|
|
const { mailData } = useEmailDetail(mai_sn, _mailData)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const [newFromEmail, setNewFromEmail] = useState(fromEmail);
|
|
|
|
|
const [emailOPI, setEmailOPI] = useState(fromUser);
|
|
|
|
|
const [emailMat, setEmailMat] = useState('');
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const emailUser = mailData.info?.MAI_OPI_SN || fromUser // quote.order_opi
|
|
|
|
|
const emailUserMat = mailData.info?.MAI_MAT_SN
|
|
|
|
|
|
|
|
|
|
// const _default =
|
|
|
|
|
// emailListOption?.find((ele) => ele.opi_sn === emailUser && ele.default === true) ||
|
|
|
|
|
// emailListOption?.find((ele) => ele.opi_sn === emailUser && ele.backup === true) ||
|
|
|
|
|
// emailListOption?.find((ele) => ele.opi_sn === emailUser) ||
|
|
|
|
|
// emailListOption?.find((ele) => ele.default === true) ||
|
|
|
|
|
// emailListOption?.find((ele) => ele.backup === true)
|
|
|
|
|
|
|
|
|
|
setNewFromEmail(fromEmail);
|
|
|
|
|
setEmailOPI(emailUser);
|
|
|
|
|
|
|
|
|
|
const _findMat = emailListAddrMapped?.[fromEmail]?.mat_sn
|
|
|
|
|
setEmailMat(emailUserMat || _findMat)
|
|
|
|
|
|
|
|
|
|
return () => {}
|
|
|
|
|
}, [fromEmail, fromUser, mailData])
|
|
|
|
|
|
|
|
|
|
const handleSwitchEmail = (labelValue) => {
|
|
|
|
|
const { value } = labelValue
|
|
|
|
|
setNewFromEmail(value)
|
|
|
|
|
const _findMat = emailListAddrMapped?.[value]
|
|
|
|
|
setEmailMat(_findMat?.mat_sn)
|
|
|
|
|
setEmailOPI(_findMat?.opi_sn)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const emailUser = mailData.info?.MAI_OPI_SN || fromUser // quote.order_opi
|
|
|
|
|
const emailUserMat = mailData.info?.MAI_MAT_SN || emailListMapped?.[emailUser]?.mat_sn
|
|
|
|
|
|
|
|
|
|
const { notification, message } = App.useApp();
|
|
|
|
|
const [form] = Form.useForm();
|
|
|
|
@ -109,7 +142,6 @@ const EmailEditorPopup = ({ open, setOpen, fromEmail, fromUser, conversationid,
|
|
|
|
|
form.setFieldValue('abstract', getAbstract(textContent));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const [newFromEmail, setNewFromEmail] = useState();
|
|
|
|
|
const [initialForm, setInitialForm] = useState({});
|
|
|
|
|
const [initialContent, setInitialContent] = useState('');
|
|
|
|
|
|
|
|
|
@ -248,8 +280,8 @@ const EmailEditorPopup = ({ open, setOpen, fromEmail, fromUser, conversationid,
|
|
|
|
|
body.from = newFromEmail || fromEmail;
|
|
|
|
|
// body.to = 'lyt@hainatravel.com'; // debug: 0
|
|
|
|
|
body.attaList = fileList;
|
|
|
|
|
body.opi_sn = emailUser || fromUser;
|
|
|
|
|
body.mat_sn = emailUserMat;
|
|
|
|
|
body.opi_sn = emailOPI;
|
|
|
|
|
body.mat_sn = emailMat;
|
|
|
|
|
console.log('body', body);
|
|
|
|
|
const values = await form.validateFields();
|
|
|
|
|
body.cc = values.cc || '';
|
|
|
|
@ -306,7 +338,7 @@ const EmailEditorPopup = ({ open, setOpen, fromEmail, fromUser, conversationid,
|
|
|
|
|
onCancel={() => {
|
|
|
|
|
form.resetFields();
|
|
|
|
|
}}
|
|
|
|
|
title={initialForm.subject || `${isEmpty(quoteid) ? '回复: ' : '写邮件: '} ${fromEmail || ''}`}
|
|
|
|
|
title={initialForm.subject || `${!isEmpty(quoteid) ? '回复: ' : '写邮件: '} ${fromEmail || ''}`}
|
|
|
|
|
footer={
|
|
|
|
|
<div className='w-full flex gap-6 justify-start items-center text-indigo-600'>
|
|
|
|
|
<Button type='primary' onClick={onHandleSend} loading={sendLoading}>
|
|
|
|
@ -317,10 +349,10 @@ const EmailEditorPopup = ({ open, setOpen, fromEmail, fromUser, conversationid,
|
|
|
|
|
纯文本
|
|
|
|
|
</Checkbox>
|
|
|
|
|
</Popconfirm>
|
|
|
|
|
<Select
|
|
|
|
|
<Select labelInValue
|
|
|
|
|
options={emailListOption}
|
|
|
|
|
value={newFromEmail || fromEmail}
|
|
|
|
|
onChange={(val) => setNewFromEmail(val)}
|
|
|
|
|
value={newFromEmail}
|
|
|
|
|
onChange={handleSwitchEmail}
|
|
|
|
|
variant={'borderless'}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|