From 5b6001e68c24c1a2d6dc29d50512c82027178111 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Mon, 18 Mar 2024 16:28:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AE=A2=E5=8D=95=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=8A=A0=E8=BD=BD=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/OrderStore.js | 27 +++++++++++-------- .../Components/CustomerProfile.jsx | 21 ++++++++++++--- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/stores/OrderStore.js b/src/stores/OrderStore.js index 3c73ef2..e4bcd98 100644 --- a/src/stores/OrderStore.js +++ b/src/stores/OrderStore.js @@ -61,17 +61,22 @@ const useOrderStore = create((set, get) => ({ }, - fetchOrderDetail: async (colisn) => { - const json = await fetchJSON(`${API_HOST}/getorderinfo`, { colisn }) - if (json.errcode === 0 && json.result.length > 0) { - const orderResult = json.result[0] - set(() => ({ - orderDetail: orderResult, - customerDetail: orderResult.contact.length > 0 ? orderResult.contact[0] : {}, - lastQuotation: orderResult.quotes.length > 0 ? orderResult.quotes[0] : {}, - quotationList: orderResult.quotes, - })) - } + fetchOrderDetail: (colisn) => { + return fetchJSON(`${API_HOST}/getorderinfo`, { colisn }) + .then(json => { + if (json.errcode === 0 && json.result.length > 0) { + const orderResult = json.result[0] + set(() => ({ + 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) + } + }) + }, setOrderPropValue: async (colisn, propName, value) => { diff --git a/src/views/Conversations/Components/CustomerProfile.jsx b/src/views/Conversations/Components/CustomerProfile.jsx index ae3af44..26a7349 100644 --- a/src/views/Conversations/Components/CustomerProfile.jsx +++ b/src/views/Conversations/Components/CustomerProfile.jsx @@ -1,6 +1,6 @@ import { LinkOutlined, MailOutlined, PhoneOutlined, UserOutlined, WhatsAppOutlined } from '@ant-design/icons' -import { App, Button, Card, Empty, Flex, Select, Typography } from 'antd' -import { useEffect } from 'react' +import { App, Button, Card, Empty, Flex, Select, Spin, Typography } from 'antd' +import { useEffect, useState } from 'react' import { Conditional } from '@/components/Conditional' import useConversationStore from '@/stores/ConversationStore' @@ -9,13 +9,26 @@ import QuotesHistory from './QuotesHistory' const CustomerProfile = (() => { const { notification } = App.useApp() + const [loading, setLoading] = useState(false) const currentOrder = useConversationStore((state) => state.currentConversation?.coli_sn || '') const { orderDetail, customerDetail, lastQuotation, quotationList, fetchOrderDetail, setOrderPropValue } = useOrderStore() useEffect(() => { - if (currentOrder) fetchOrderDetail(currentOrder) + if (currentOrder) { + setLoading(true) + fetchOrderDetail(currentOrder) + .finally(() => setLoading(false)) + .catch(reason => { + notification.error({ + message: '查询出错', + description: reason.message, + placement: 'top', + duration: 60, + }) + }) + } }, [currentOrder]) let regularText = '' @@ -24,6 +37,7 @@ const CustomerProfile = (() => { if (currentOrder) { return (
+ { }/>

+
) } else {