增加订单数据加载状态

dev/mobile
Jimmy 2 years ago
parent a3be35ca02
commit 5b6001e68c

@ -61,17 +61,22 @@ const useOrderStore = create((set, get) => ({
}, },
fetchOrderDetail: async (colisn) => { fetchOrderDetail: (colisn) => {
const json = await fetchJSON(`${API_HOST}/getorderinfo`, { colisn }) return fetchJSON(`${API_HOST}/getorderinfo`, { colisn })
if (json.errcode === 0 && json.result.length > 0) { .then(json => {
const orderResult = json.result[0] if (json.errcode === 0 && json.result.length > 0) {
set(() => ({ const orderResult = json.result[0]
orderDetail: orderResult, set(() => ({
customerDetail: orderResult.contact.length > 0 ? orderResult.contact[0] : {}, orderDetail: orderResult,
lastQuotation: orderResult.quotes.length > 0 ? orderResult.quotes[0] : {}, customerDetail: orderResult.contact.length > 0 ? orderResult.contact[0] : {},
quotationList: orderResult.quotes, lastQuotation: orderResult.quotes.length > 0 ? orderResult.quotes[0] : {},
})) quotationList: orderResult.quotes,
} }))
} else {
throw new Error(json?.errmsg + ': ' + json.errcode)
}
})
}, },
setOrderPropValue: async (colisn, propName, value) => { setOrderPropValue: async (colisn, propName, value) => {

@ -1,6 +1,6 @@
import { LinkOutlined, MailOutlined, PhoneOutlined, UserOutlined, WhatsAppOutlined } from '@ant-design/icons' import { LinkOutlined, MailOutlined, PhoneOutlined, UserOutlined, WhatsAppOutlined } from '@ant-design/icons'
import { App, Button, Card, Empty, Flex, Select, Typography } from 'antd' import { App, Button, Card, Empty, Flex, Select, Spin, Typography } from 'antd'
import { useEffect } from 'react' import { useEffect, useState } from 'react'
import { Conditional } from '@/components/Conditional' import { Conditional } from '@/components/Conditional'
import useConversationStore from '@/stores/ConversationStore' import useConversationStore from '@/stores/ConversationStore'
@ -9,13 +9,26 @@ import QuotesHistory from './QuotesHistory'
const CustomerProfile = (() => { const CustomerProfile = (() => {
const { notification } = App.useApp() const { notification } = App.useApp()
const [loading, setLoading] = useState(false)
const currentOrder = useConversationStore((state) => state.currentConversation?.coli_sn || '') const currentOrder = useConversationStore((state) => state.currentConversation?.coli_sn || '')
const { orderDetail, customerDetail, lastQuotation, quotationList, const { orderDetail, customerDetail, lastQuotation, quotationList,
fetchOrderDetail, setOrderPropValue fetchOrderDetail, setOrderPropValue
} = useOrderStore() } = useOrderStore()
useEffect(() => { 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]) }, [currentOrder])
let regularText = '' let regularText = ''
@ -24,6 +37,7 @@ const CustomerProfile = (() => {
if (currentOrder) { if (currentOrder) {
return ( return (
<div className=' divide-x-0 divide-y divide-dashed divide-gray-300 '> <div className=' divide-x-0 divide-y divide-dashed divide-gray-300 '>
<Spin spinning={loading}>
<Card className='p-2 ' <Card className='p-2 '
bordered={false} bordered={false}
title={orderDetail.order_no} title={orderDetail.order_no}
@ -90,6 +104,7 @@ const CustomerProfile = (() => {
}/> }/>
</Flex> </Flex>
<p className='p-2 shadow-inner overflow-auto m-0 break-words whitespace-pre-wrap' dangerouslySetInnerHTML={{__html: orderDetail.order_detail}}></p> <p className='p-2 shadow-inner overflow-auto m-0 break-words whitespace-pre-wrap' dangerouslySetInnerHTML={{__html: orderDetail.order_detail}}></p>
</Spin>
</div> </div>
) )
} else { } else {

Loading…
Cancel
Save