From cd5dbb3be51127db99d9aa43fc65067016df9972 Mon Sep 17 00:00:00 2001 From: LiaoYijun Date: Tue, 24 Jun 2025 10:43:01 +0800 Subject: [PATCH 01/17] =?UTF-8?q?feat=EF=BC=9A=E5=A2=9E=E5=8A=A0=20WA?= =?UTF-8?q?=E3=80=81=E9=99=84=E5=8A=A0=E4=BF=A1=E6=81=AF=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/OrderProfile.jsx | 87 +++++++++++++++++++++++++-------- src/stores/OrderStore.js | 42 +++++++++++++++- 2 files changed, 106 insertions(+), 23 deletions(-) diff --git a/src/components/OrderProfile.jsx b/src/components/OrderProfile.jsx index 64478de..a51eee1 100644 --- a/src/components/OrderProfile.jsx +++ b/src/components/OrderProfile.jsx @@ -13,7 +13,7 @@ import { } from '@ant-design/icons' import { useEffect, useState } from 'react' -import { Link, useNavigate } from 'react-router-dom' +import { Link } from 'react-router-dom' import { App, Flex, Select, Tooltip, Divider, Typography, Skeleton, Checkbox, Drawer, Button, Form, Input } from 'antd' import { useOrderStore, fetchSetRemindStateAction, OrderLabelDefaultOptions, OrderStatusDefaultOptions, remindStatusOptions } from '@/stores/OrderStore' import { copy, isEmpty } from '@/utils/commons' @@ -21,24 +21,28 @@ import { useShallow } from 'zustand/react/shallow' import useConversationStore from '@/stores/ConversationStore' import useAuthStore from '@/stores/AuthStore' const OrderProfile = ({ coliSN, ...props }) => { - const navigate = useNavigate() const { notification, message } = App.useApp() - const [formComment, formWhatsApp] = Form.useForm() + const [formComment] = Form.useForm() + const [formWhatsApp] = Form.useForm() + const [formExtra] = Form.useForm() const [loading, setLoading] = useState(false) const [openOrderCommnet, setOpenOrderCommnet] = useState(false) const [openWhatsApp, setOpenWhatsApp] = useState(false) + const [openExtra, setOpenExtra] = useState(false) const orderLabelOptions = copy(OrderLabelDefaultOptions) orderLabelOptions.unshift({ value: 0, label: '未设置', disabled: true }) const orderStatusOptions = copy(OrderStatusDefaultOptions) - const [orderDetail, customerDetail, fetchOrderDetail, setOrderPropValue, appendOrderComment] = useOrderStore((s) => [ + const [orderDetail, customerDetail, fetchOrderDetail, setOrderPropValue, appendOrderComment, updateWhatsapp, updateExtraInfo] = useOrderStore((s) => [ s.orderDetail, s.customerDetail, s.fetchOrderDetail, s.setOrderPropValue, s.appendOrderComment, + s.updateWhatsapp, + s.updateExtraInfo, ]) const loginUser = useAuthStore((state) => state.loginUser) @@ -47,8 +51,8 @@ const OrderProfile = ({ coliSN, ...props }) => { const [orderRemindState, setOrderRemindState] = useState(orderDetail.remindstate) useEffect(() => { - setOrderRemindState(orderDetail.remindstate); - }, [orderDetail.remindstate]); + setOrderRemindState(orderDetail.remindstate) + }, [orderDetail.remindstate]) useEffect(() => { if (orderId) { setLoading(true) @@ -119,12 +123,15 @@ const OrderProfile = ({ coliSN, ...props }) => { - {isEmpty(customerDetail.whatsapp_phone_number) ? - : - - {customerDetail.whatsapp_phone_number} - - } + {isEmpty(customerDetail.whatsapp_phone_number) ? ( + + ) : ( + + {customerDetail.whatsapp_phone_number} + + )} @@ -227,9 +234,14 @@ const OrderProfile = ({ coliSN, ...props }) => { 附加信息 - {/* - - */} + + { + setOpenExtra(true) + }} + /> + {orderDetail.COLI_Introduction} @@ -240,7 +252,6 @@ const OrderProfile = ({ coliSN, ...props }) => { initialValues={{ comment: '' }} scrollToFirstError onFinish={(values) => { - console.log('Received values of form: ', values) appendOrderComment(loginUser.userId, orderId, values.comment) .then(() => { notification.success({ @@ -276,15 +287,49 @@ const OrderProfile = ({ coliSN, ...props }) => { initialValues={{ number: '' }} scrollToFirstError onFinish={(values) => { - console.log('Received values of form: ', values) - // appendOrderComment(loginUser.userId, orderId, values.number) + updateWhatsapp(orderId, values.number) .then(() => { notification.success({ message: '温性提示', description: '设置 WhatsApp 成功', }) setOpenWhatsApp(false) - formComment.setFieldsValue({ number: '' }) + formWhatsApp.setFieldsValue({ number: '' }) + }) + .catch((reason) => { + notification.error({ + message: '设置出错', + description: reason.message, + placement: 'top', + duration: 60, + }) + }) + }}> + + + + + + + + + setOpenExtra(false)} open={openExtra}> +
{ + console.log('Received values of form: ', values) + updateExtraInfo(orderId, values.extra) + .then(() => { + notification.success({ + message: '温性提示', + description: '设置附加信息成功', + }) + setOpenExtra(false) }) .catch((reason) => { notification.error({ @@ -295,8 +340,8 @@ const OrderProfile = ({ coliSN, ...props }) => { }) }) }}> - - + + @@ -705,7 +705,10 @@ const NewEmail = () => { {!isEmpty(Number(pageParam.quoteid)) && pageParam.action!=='edit' && !showQuoteContent && (
- {/* */}
)} - {showQuoteContent && ( + {/* {showQuoteContent && (
setQuoteContent(`
${e.target.innerHTML}
`)} dangerouslySetInnerHTML={{ __html: generateQuoteContent(mailData) }}>
- )} + )} */} ) From 2abd14965516b39583b83a273fb91b30b4cdbe58 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Wed, 25 Jun 2025 09:57:31 +0800 Subject: [PATCH 05/17] =?UTF-8?q?perf:=20email=20=E4=B8=8D=E5=9C=A8?= =?UTF-8?q?=E5=9C=A8=E7=BA=BF=E8=81=8A=E5=A4=A9=E9=A1=B5=E9=9D=A2=E9=80=9A?= =?UTF-8?q?=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/ConversationStore.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/stores/ConversationStore.js b/src/stores/ConversationStore.js index 83d9974..b74c7e0 100644 --- a/src/stores/ConversationStore.js +++ b/src/stores/ConversationStore.js @@ -197,10 +197,10 @@ const websocketSlice = (set, get) => ({ // console.log('msgRender msgUpdate', msgRender, msgUpdate); if (['email.updated', 'email.inbound.received',].includes(resultType)) { updateMailboxCount({ opi_sn: msgObj.opi_sn }) - if (!isEmpty(msgRender)) { - const msgNotify = receivedMsgTypeMapped[resultType].contentToNotify(msgObj); - addGlobalNotify(msgNotify); - } + // if (!isEmpty(msgRender)) { + // const msgNotify = receivedMsgTypeMapped[resultType].contentToNotify(msgObj); + // addGlobalNotify(msgNotify); + // } return false; } if ([ @@ -238,7 +238,9 @@ const websocketSlice = (set, get) => ({ // }, 60_000); } // 会话表 更新 - if (['session.new', 'session.updated'].includes(resultType)) { + if (['session.new', 'session.updated'].includes(resultType) + && result.webhooksource !== 'email' + ) { const sessionList = receivedMsgTypeMapped[resultType].getMsg(result); addToConversationList(sessionList, 'top'); } From 068a02ff64da12fb2c98f3b5a2b64558c75dc4bd Mon Sep 17 00:00:00 2001 From: Lei OT Date: Wed, 25 Jun 2025 11:40:41 +0800 Subject: [PATCH 06/17] perf: email quote, text/plain --- src/views/NewEmail.jsx | 43 ++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/src/views/NewEmail.jsx b/src/views/NewEmail.jsx index 4bd74a5..8e7e43d 100644 --- a/src/views/NewEmail.jsx +++ b/src/views/NewEmail.jsx @@ -46,14 +46,15 @@ const parseHTMLText = (html) => { const parser = new DOMParser() const dom = parser.parseFromString(html, 'text/html') // Replace
and

with line breaks - Array.from(dom.body.querySelectorAll('br, p')).forEach((el) => { - el.textContent = '\n' + el.textContent - }) + // Array.from(dom.body.querySelectorAll('br, p')).forEach((el) => { + // el.textContent = '
' + el.textContent + // }) // Replace


with a line of dashes - Array.from(dom.body.querySelectorAll('hr')).forEach((el) => { - el.textContent = '\n------------------------------------------------------------------\n' - }) - return dom.body.textContent || '' + // Array.from(dom.body.querySelectorAll('hr')).forEach((el) => { + // el.innerHTML = '


------------------------------------------------------------------

' + // }) + const line = '

------------------------------------------------------------------

' + return line+(dom.body.innerHTML || '') } const generateQuoteContent = (mailData, isRichText = true) => { @@ -199,6 +200,8 @@ const NewEmail = () => { mat_sn: emailAccount?.mat_sn || info?.MAI_MAT_SN || defaultMAT, opi_sn: emailAccount?.opi_sn || info?.MAI_OPI_SN || orderDetail.opi_sn || '', } + const originalContentType = info?.mailType === 'text/html'; + setIsRichText(originalContentType) let readyToInitialContent = ''; let _formValues = {}; @@ -225,6 +228,7 @@ const NewEmail = () => { subject: `Re: ${info.MAI_Subject || ''}`, ..._form2 } + readyToInitialContent += generateQuoteContent(mailData, originalContentType) break case 'replyall': _formValues = { @@ -235,6 +239,7 @@ const NewEmail = () => { subject: `Re: ${info.MAI_Subject || ''}`, ..._form2 } + readyToInitialContent += generateQuoteContent(mailData, originalContentType) break case 'forward': _formValues = { @@ -243,6 +248,7 @@ const NewEmail = () => { // coli_sn: pageParam.oid, ..._form2 } + readyToInitialContent += generateQuoteContent(mailData, originalContentType) break case 'edit': _formValues = { @@ -341,12 +347,14 @@ const NewEmail = () => { } const handleEditorChange = ({ editorStateJSON, htmlContent, textContent }) => { - // console.log('textContent', textContent); + const _text = textContent.replace(/\r\n/g, '\n').replace(/\n{2,}/g, '\n') + // console.log('textContent---\n', textContent, 'textContent'); // console.log('html', html); setHtmlContent(htmlContent) - setTextContent(textContent) + setTextContent(_text) form.setFieldValue('content', htmlContent) - const { bodyText: abstract } = parseHTMLString(htmlContent, true); + const abstract = _text; + // const { bodyText: abstract } = parseHTMLString(htmlContent, true); // form.setFieldValue('abstract', getAbstract(textContent)) const formValues = omitEmpty(form.getFieldsValue()); if (!isEmpty(formValues)) { @@ -496,8 +504,8 @@ const NewEmail = () => { body.attaList = fileList; // console.log('body', body, '\n', fileList); const values = await form.validateFields() - const preQuoteBody = !['edit', 'new'].includes(pageParam.action) && pageParam.quoteid ? (quoteContent ? quoteContent : generateQuoteContent(mailData, isRichText)) : '' - body.mailcontent = isRichText ? EmailBuilder({ subject: values.subject, content: htmlContent + preQuoteBody }) : textContent + preQuoteBody + // const preQuoteBody = !['edit', 'new'].includes(pageParam.action) && pageParam.quoteid ? (quoteContent ? quoteContent : generateQuoteContent(mailData, isRichText)) : '' + body.mailcontent = isRichText ? EmailBuilder({ subject: values.subject, content: htmlContent }) : textContent body.cc = values.cc || '' body.bcc = values.bcc || '' body.bcc = values.mailtype || '' @@ -517,6 +525,8 @@ const NewEmail = () => { try { // console.log('postSendEmail', body, '\n'); + // console.log('🎈postSendEmail mailContent', body.mailcontent, '\n'); + // throw new Error('test') // return; const mailSavedId = await postEmailSaveOrSend(body, isDraft) form.setFieldsValue({ @@ -703,20 +713,17 @@ const NewEmail = () => {
- {!isEmpty(Number(pageParam.quoteid)) && pageParam.action!=='edit' && !showQuoteContent && ( + {/* {!isEmpty(Number(pageParam.quoteid)) && pageParam.action!=='edit' && !showQuoteContent && (
- {/* */}
)} - {/* {showQuoteContent && ( + {showQuoteContent && (
Date: Wed, 25 Jun 2025 11:41:15 +0800 Subject: [PATCH 07/17] conf: build chunk --- vite.config.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/vite.config.js b/vite.config.js index 448192f..db009c6 100644 --- a/vite.config.js +++ b/vite.config.js @@ -183,12 +183,9 @@ export default defineConfig({ output: { entryFileNames: '[name]/build.[hash].js', manualChunks(id) { - if (id.toLowerCase().includes('lexical')) { - return 'lexical'; - } - if (id.includes('node_modules')) { - return 'vendor'; - // return id.toString().split('node_modules/')[1].split('/')[0].toString(); + if (id.includes('node_modules/')) { + // return 'vendor'; + return id.toString().split('node_modules/')[1].split('/')[0].toString(); } }, // chunkFileNames: (chunkInfo) => { From e0950bb77374c8ffc15192a37122c8a3b568723a Mon Sep 17 00:00:00 2001 From: Lei OT Date: Wed, 25 Jun 2025 11:47:30 +0800 Subject: [PATCH 08/17] style: --- src/views/Conversations/Online/Components/EmailContent.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/Conversations/Online/Components/EmailContent.jsx b/src/views/Conversations/Online/Components/EmailContent.jsx index d4cdf8a..0d66293 100644 --- a/src/views/Conversations/Online/Components/EmailContent.jsx +++ b/src/views/Conversations/Online/Components/EmailContent.jsx @@ -113,7 +113,7 @@ const EmailContent = ({ id, content: MailContent, className='', ...props }) => { return (
-
+