From fe3cde0c8974dd92e322b07ee9c6690720cf5026 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Tue, 10 Jun 2025 17:03:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=9D=E5=AD=98=E8=8D=89=E7=A8=BF;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/actions/EmailActions.js | 9 +++++---- src/hooks/useEmail.js | 1 + src/views/NewEmail.jsx | 22 +++++++++++++++------- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/actions/EmailActions.js b/src/actions/EmailActions.js index f3ce211..117bcd7 100644 --- a/src/actions/EmailActions.js +++ b/src/actions/EmailActions.js @@ -164,7 +164,7 @@ const todoTypes = { */ export const getEmailDirAction = async (params = { opi_sn: '' }) => { const defaultParams = { opi_sn: 0, year: dayjs().year(), by_start_date: -1, by_success: -1, important: -1, if_want_book: -1, if_thinking: -1 } - const { errcode, result } = await fetchJSON(`http://202.103.68.144:8889/v3/email_dir`, { ...defaultParams, ...params }) + const { errcode, result } = await fetchJSON(`${API_HOST}/v3/email_dir`, { ...defaultParams, ...params }) const mailboxSort = result //.sort(sortBy('MDR_Order')); let tree = buildTree(mailboxSort, { key: 'VKey', parent: 'VParent', name: 'VName', iconIndex: 'ImageIndex', rootKeys: [1], ignoreKeys: [-227001, -227002] }) tree = tree.filter((ele) => ele.key !== 1) @@ -306,7 +306,7 @@ export const queryEmailListAction = async ({ opi_sn = '', pagesize = 10, last_id } _params.mai_senddate1 = dayjs(_params.mai_senddate1).format(DATE_FORMAT) const cacheKey = isEmpty(_params.coli_sn) ? `dir-${node.vkey}` : `order-${node.vkey}`; - const { errcode, result } = await fetchJSON(`http://202.103.68.144:8889/v3/mail_list`, _params) + const { errcode, result } = await fetchJSON(`${API_HOST}/v3/mail_list`, _params) const ret = errcode === 0 ? result : [] if (!isEmpty(ret)) { writeIndexDB([{key: cacheKey, data: ret}], 'maillist', 'mailbox') @@ -333,7 +333,8 @@ export const getEmailTemplateAction = async (template_name, params = { coli_sn: /** * 保存邮件草稿 */ -export const saveEmailDraftAction = async (body) => { +export const saveEmailDraftOrSendAction = async (body, isDraft = false) => { + const url = isDraft !== false ? `${API_HOST}/v3/email_draft_save` : `${EMAIL_HOST}/sendmail`; const { attaList=[], atta, content, ...bodyData } = body; bodyData.ordertype = 227001; const formData = new FormData(); @@ -343,7 +344,7 @@ export const saveEmailDraftAction = async (body) => { attaList.forEach(function (item) { formData.append('attachment', item); }); - const { result } = await postForm(`${EMAIL_HOST}/email-draft/save`, formData); + const { result } = await postForm(url, formData); return result; }; diff --git a/src/hooks/useEmail.js b/src/hooks/useEmail.js index 4666fa3..ddd77b4 100644 --- a/src/hooks/useEmail.js +++ b/src/hooks/useEmail.js @@ -157,6 +157,7 @@ export const useEmailList = (mailboxDirNode) => { key: ele.MAI_SN, })) setMailList(_x) + setLoading(false) } try { const nodeParam = { coli_sn: COLI_SN, order_source_type: OrderSourceType, vkey: VKey, vparent: VParent, mai_senddate1: ApplyDate } diff --git a/src/views/NewEmail.jsx b/src/views/NewEmail.jsx index 6097a1f..d41938e 100644 --- a/src/views/NewEmail.jsx +++ b/src/views/NewEmail.jsx @@ -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) => `

${mailData.content}

` +const generateMailContent = (mailData) => `

${mailData.content}


` /** * ! 无状态管理 @@ -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 = () => { <>
- + {pageParam.quoteid && pageParam.action!=='edit' && !showQuoteContent && (