From e6756e5da0f435f39709e028bde11b1be01bf959 Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Tue, 19 Nov 2024 10:54:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=94=AF=E4=BB=98Drawer=EF=BC=9B=E6=94=AF=E4=BB=98=E8=A1=A8?= =?UTF-8?q?=E5=8D=95=E9=BB=98=E8=AE=A4=E5=BD=93=E5=89=8D=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=92=8C=E9=A1=BE=E9=97=AE=EF=BC=9B=E5=9B=BE=E6=96=87=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=88=96=E4=BF=9D=E5=AD=98=E6=98=AF=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/OrderStore.js | 19 +++++ src/stores/SnippetStore.js | 2 +- src/views/DesktopApp.jsx | 37 ++++++++-- src/views/accounts/GeneratePayment.jsx | 97 ++++++++++++++++---------- src/views/accounts/SnippetList.jsx | 7 +- 5 files changed, 116 insertions(+), 46 deletions(-) diff --git a/src/stores/OrderStore.js b/src/stores/OrderStore.js index 361ece3..223acb6 100644 --- a/src/stores/OrderStore.js +++ b/src/stores/OrderStore.js @@ -11,6 +11,19 @@ export const useOrderStore = create(devtools((set, get) => ({ customerDetail: {}, lastQuotation: {}, quotationList: [], + drawerOpen: false, + + openDrawer: () => { + set(() => ({ + drawerOpen: true + })) + }, + + closeDrawer: () => { + set(() => ({ + drawerOpen: false + })) + }, fetchOrderList: async (formValues, loginUser) => { let fetchOrderUrl = `${API_HOST}/getwlorder?opisn=${loginUser.userIdStr}&otype=${formValues.type}` @@ -46,6 +59,12 @@ export const useOrderStore = create(devtools((set, get) => ({ lastQuotation: orderResult.quotes.length > 0 ? orderResult.quotes[0] : {}, quotationList: orderResult.quotes, })) + return { + orderDetail: orderResult, + customerDetail: orderResult.contact.length > 0 ? orderResult.contact[0] : {}, + lastQuotation: orderResult.quotes.length > 0 ? orderResult.quotes[0] : {}, + quotationList: orderResult.quotes, + } } else { throw new Error(json?.errmsg + ': ' + json.errcode) } diff --git a/src/stores/SnippetStore.js b/src/stores/SnippetStore.js index f17ce58..62da913 100644 --- a/src/stores/SnippetStore.js +++ b/src/stores/SnippetStore.js @@ -114,7 +114,7 @@ const useSnippetStore = create(devtools((set, get) => ({ formData.append('type', formValues.category) formData.append('title', formValues.title) formData.append('adi_content', formValues.content.htmlContent) - formData.append('opi_sn', 383) + formData.append('opi_sn', formValues.opi_sn) return postForm(postSnippetUrl, formData) .then(json => { diff --git a/src/views/DesktopApp.jsx b/src/views/DesktopApp.jsx index 7b5e850..ecefef7 100644 --- a/src/views/DesktopApp.jsx +++ b/src/views/DesktopApp.jsx @@ -1,5 +1,6 @@ import useAuthStore from '@/stores/AuthStore' import useSnippetStore from '@/stores/SnippetStore' +import { useOrderStore } from '@/stores/OrderStore' import useConversationStore from '@/stores/ConversationStore' import { useThemeContext } from '@/stores/ThemeContext' import { DownOutlined } from '@ant-design/icons' @@ -26,7 +27,8 @@ import 'react-chat-elements/dist/main.css' import ReloadPrompt from './ReloadPrompt' import ClearCache from './ClearCache' -import SnippetList from './accounts/SnippetList' +import SnippetList from '@/views/accounts/SnippetList' +import GeneratePayment from '@/views/accounts/GeneratePayment' import { BUILD_VERSION, BUILD_DATE } from '@/config' @@ -42,18 +44,30 @@ function DesktopApp() { const totalNotify = useConversationStore((state) => state.totalNotify) const [ - openSnippetDrawer , - closeDrawer, - drawerOpen, + openSnippetDrawer, + closeSnippetDrawer, + snippetDrawerOpen, ] = useSnippetStore((state) => [ state.openDrawer, state.closeDrawer, state.drawerOpen, ]) + const [ + openPaymentDrawer, + closePaymentDrawer, + paymentDrawerOpen, + ] = useOrderStore((state) => [ + state.openDrawer, + state.closeDrawer, + state.drawerOpen, + ]) + const onClick = ({ key }) => { if (key === 'snippet-list') { openSnippetDrawer() + } else if (key == 'generate-payment') { + openPaymentDrawer() } } @@ -110,11 +124,20 @@ function DesktopApp() { title='图文集管理' placement={'top'} size={'large'} - onClose={() => closeDrawer()} - open={drawerOpen} + onClose={() => closeSnippetDrawer()} + open={snippetDrawerOpen} > + closePaymentDrawer()} + open={paymentDrawerOpen} + > + + @@ -169,7 +192,7 @@ function DesktopApp() { key: 'profile', }, { - label: 付款链接, + label: '生成付款链接', key: 'generate-payment', }, { diff --git a/src/views/accounts/GeneratePayment.jsx b/src/views/accounts/GeneratePayment.jsx index c11e151..19fb6ba 100644 --- a/src/views/accounts/GeneratePayment.jsx +++ b/src/views/accounts/GeneratePayment.jsx @@ -2,6 +2,7 @@ import { Radio, Row, Col, Tooltip, Flex, Form, Input, Button, InputNumber, Selec import { useState, useEffect } from 'react' import HtmlPreview from './HtmlPreview' import useAuthStore from '@/stores/AuthStore' +import useConversationStore from '@/stores/ConversationStore' import { useOrderStore } from '@/stores/OrderStore' import { InfoCircleOutlined } from '@ant-design/icons' @@ -10,8 +11,9 @@ function GeneratePayment() { const [generateForm] = Form.useForm() - const [getPrimaryEmail, loginUser] = useAuthStore(s => [s.getPrimaryEmail, s.loginUser]) - const [generatePayment] = useOrderStore(s => [s.generatePayment]) + const [getPrimaryEmail, loginUser] = useAuthStore((s) => [s.getPrimaryEmail, s.loginUser]) + const [generatePayment, fetchOrderDetail] = useOrderStore((s) => [s.generatePayment, s.fetchOrderDetail]) + const currentOrder = useConversationStore((state) => state.currentConversation?.coli_sn || '') const [isHtmlLoading, setHtmlLoading] = useState(false) const [generatedObject, setGeneratedObject] = useState('') @@ -26,6 +28,35 @@ function GeneratePayment() { .finally(() => setHtmlLoading(false)) } + useEffect(() => { + if (currentOrder) { + fetchOrderDetail(currentOrder) + .then((result) => { + const orderNumber = result.orderDetail.order_no + const travelAdvisor = loginUser.accountList.length > 0 ? loginUser.accountList[0].OPI_NameEN : '' + generateForm.setFieldsValue({ + notifyEmail: getPrimaryEmail(), + orderNumber: orderNumber, + description: 'Tracking Code: ' + orderNumber + '\r\nTravel Advisor: ' + travelAdvisor + '\r\nContent: \r\n', + langauge: 'US', + orderType: '227001', + currency: 'USD', + amount: 1, + userId: loginUser.userId, + }) + }) + // .finally(() => setLoading(false)) + .catch((reason) => { + // notification.error({ + // message: "查询出错", + // description: reason.message, + // placement: "top", + // duration: 60, + // }); + }) + } + }, [currentOrder]) + return ( <> @@ -35,39 +66,33 @@ function GeneratePayment() { span: 4, }} layout={'horizontal'} - form={generateForm} - initialValues={{ - notifyEmail: getPrimaryEmail(), - description: 'Tracking Code:\r\nTravel Advisor: \r\nContent:\r\n', - orderNumber: 'lyj202411141004001', - langauge: 'US', - orderType: '227001', - currency: 'USD', - amount: 1, - userId: loginUser.userId - }}> - - + + + + + ]}> 线路订单 商务订单 - + ]}> - + ]}> @@ -106,16 +133,14 @@ function GeneratePayment() { width: 90, }} options={[ - {value: 'USD', label: '美元'}, - {value: 'CNY', label: '人民币'}, - {value: 'EUR', label: '欧元'}, - {value: 'JPY', label: '日元'}, - {value: 'AUD', label: '澳元'}, - {value: 'CAD', label: '加元'}, - {value: 'HKD', label: '港币'}, - ]} - > - + { value: 'USD', label: '美元' }, + { value: 'CNY', label: '人民币' }, + { value: 'EUR', label: '欧元' }, + { value: 'JPY', label: '日元' }, + { value: 'AUD', label: '澳元' }, + { value: 'CAD', label: '加元' }, + { value: 'HKD', label: '港币' }, + ]}> } min={1} diff --git a/src/views/accounts/SnippetList.jsx b/src/views/accounts/SnippetList.jsx index 6ac21ff..ac3c508 100644 --- a/src/views/accounts/SnippetList.jsx +++ b/src/views/accounts/SnippetList.jsx @@ -70,12 +70,12 @@ function SnippetList() { } const handelSnippetEdit = () => { - snippetForm.setFieldsValue(currentSnippet) + snippetForm.setFieldsValue({opi_sn: loginUser.userId, ...currentSnippet}) setSnippetModalOpen(true) } const handelSnippetNew = () => { - const snippet = createSnippet(383) + const snippet = createSnippet(loginUser.userId) snippetForm.setFieldsValue(snippet) setSnippetModalOpen(true) } @@ -131,6 +131,9 @@ function SnippetList() { + + +