You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
143 lines
5.3 KiB
React
143 lines
5.3 KiB
React
2 years ago
|
import { LinkOutlined, MailOutlined, PhoneOutlined, UserOutlined, WhatsAppOutlined } from '@ant-design/icons'
|
||
2 years ago
|
import { App, Button, Card, Empty, Flex, Select, Spin, Typography } from 'antd'
|
||
|
import { useEffect, useState } from 'react'
|
||
2 years ago
|
|
||
2 years ago
|
import { copy, isNotEmpty } from '@/utils/commons'
|
||
2 years ago
|
import { Conditional } from '@/components/Conditional'
|
||
2 years ago
|
import useConversationStore from '@/stores/ConversationStore'
|
||
2 years ago
|
import { useOrderStore, OrderLabelDefaultOptions, OrderStatusDefaultOptions } from '@/stores/OrderStore'
|
||
2 years ago
|
import QuotesHistory from './QuotesHistory'
|
||
2 years ago
|
|
||
2 years ago
|
const CustomerProfile = (() => {
|
||
2 years ago
|
const { notification, message } = App.useApp()
|
||
2 years ago
|
const [loading, setLoading] = useState(false)
|
||
2 years ago
|
const currentOrder = useConversationStore((state) => state.currentConversation?.coli_sn || '')
|
||
2 years ago
|
const { orderDetail, customerDetail, lastQuotation, quotationList,
|
||
2 years ago
|
fetchOrderDetail, setOrderPropValue
|
||
2 years ago
|
} = useOrderStore()
|
||
2 years ago
|
|
||
2 years ago
|
const orderLabelOptions = copy(OrderLabelDefaultOptions)
|
||
|
orderLabelOptions.unshift({ value: 0, label: '未设置', disabled: true, })
|
||
|
|
||
|
const orderStatusOptions = copy(OrderStatusDefaultOptions)
|
||
|
|
||
2 years ago
|
useEffect(() => {
|
||
2 years ago
|
if (currentOrder) {
|
||
|
setLoading(true)
|
||
|
fetchOrderDetail(currentOrder)
|
||
|
.finally(() => setLoading(false))
|
||
|
.catch(reason => {
|
||
|
notification.error({
|
||
|
message: '查询出错',
|
||
|
description: reason.message,
|
||
|
placement: 'top',
|
||
|
duration: 60,
|
||
|
})
|
||
|
})
|
||
|
}
|
||
2 years ago
|
}, [currentOrder])
|
||
2 years ago
|
|
||
2 years ago
|
let regularText = ''
|
||
|
if (orderDetail.buytime > 0) regularText = '(R' + orderDetail.buytime + ')'
|
||
|
|
||
2 years ago
|
if (currentOrder) {
|
||
2 years ago
|
return (
|
||
2 years ago
|
<div className='divide-x-0 divide-y divide-dashed divide-gray-300'>
|
||
2 years ago
|
<Spin spinning={loading}>
|
||
2 years ago
|
<Card className='p-2 '
|
||
|
bordered={false}
|
||
|
title={orderDetail.order_no}
|
||
|
actions={[
|
||
|
<Select
|
||
|
style={{
|
||
|
width: '100%'
|
||
|
}}
|
||
|
variant='borderless'
|
||
|
onSelect={(value) => {
|
||
2 years ago
|
setOrderPropValue(currentOrder, 'orderlabel', value)
|
||
|
.then(() => {
|
||
|
message.success('设置成功')
|
||
|
})
|
||
|
.catch(reason => {
|
||
|
notification.error({
|
||
|
message: '设置出错',
|
||
|
description: reason.message,
|
||
|
placement: 'top',
|
||
|
duration: 60,
|
||
|
})
|
||
|
})
|
||
2 years ago
|
}}
|
||
|
value={orderDetail.tags}
|
||
2 years ago
|
options={orderLabelOptions}
|
||
2 years ago
|
/>,
|
||
|
<Select
|
||
|
style={{
|
||
|
width: '100%'
|
||
|
}}
|
||
|
variant='borderless'
|
||
|
onSelect={(value) => {
|
||
2 years ago
|
setOrderPropValue(currentOrder,'orderstatus', value)
|
||
|
.then(() => {
|
||
|
message.success('设置成功')
|
||
|
})
|
||
|
.catch(reason => {
|
||
|
notification.error({
|
||
|
message: '设置出错',
|
||
|
description: reason.message,
|
||
|
placement: 'top',
|
||
|
duration: 60,
|
||
|
})
|
||
|
})
|
||
2 years ago
|
}}
|
||
|
value={orderDetail.states}
|
||
2 years ago
|
options={orderStatusOptions}
|
||
2 years ago
|
/>
|
||
|
]}
|
||
|
>
|
||
|
<Flex gap={10}>
|
||
|
<Flex vertical={true} justify='space-between'>
|
||
|
<Typography.Text ><UserOutlined className=' pr-1' />{customerDetail.name + regularText}</Typography.Text>
|
||
|
<Typography.Text ><PhoneOutlined className=' pr-1' />{customerDetail.phone}</Typography.Text>
|
||
|
<Typography.Text ><MailOutlined className=' pr-1' />{customerDetail.email}</Typography.Text>
|
||
|
<Typography.Text ><WhatsAppOutlined className='pr-1' />{customerDetail.whatsapp_phone_number}</Typography.Text>
|
||
|
</Flex>
|
||
|
</Flex>
|
||
|
</Card>
|
||
|
<Flex vertical={true} className='p-2 '>
|
||
|
<Typography.Text strong>最新报价</Typography.Text>
|
||
2 years ago
|
<Conditional
|
||
|
condition={quotationList.length > 0}
|
||
2 years ago
|
whenFalse={<Empty description={<span>暂无报价</span>}></Empty>}
|
||
|
whenTrue={
|
||
|
<>
|
||
|
<p className='m-0 py-2 line-clamp-2 '><a target='_blank' href={lastQuotation.letterurl}><LinkOutlined /> {lastQuotation.lettertitle}</a></p>
|
||
|
<Flex justify={'space-between'} >
|
||
|
<QuotesHistory dataSource={quotationList} />
|
||
|
</Flex>
|
||
|
</>
|
||
|
}/>
|
||
2 years ago
|
</Flex>
|
||
2 years ago
|
<p className='p-2 shadow-inner overflow-auto m-0 break-words whitespace-pre-wrap' dangerouslySetInnerHTML={{__html: orderDetail.order_detail}}></p>
|
||
2 years ago
|
</Spin>
|
||
2 years ago
|
</div>
|
||
2 years ago
|
)
|
||
2 years ago
|
} else {
|
||
|
return (
|
||
|
<Empty
|
||
2 years ago
|
description={<span>暂无相关订单</span>}
|
||
2 years ago
|
>
|
||
2 years ago
|
<Button type='primary' onClick={() => {
|
||
|
notification.info({
|
||
|
message: '温馨提示',
|
||
|
description: '功能还在开发中,敬请期待',
|
||
|
placement: 'top',
|
||
|
duration: 60,
|
||
|
})
|
||
|
}}>现在关联</Button>
|
||
2 years ago
|
</Empty>
|
||
|
)
|
||
|
}
|
||
2 years ago
|
})
|
||
2 years ago
|
|
||
2 years ago
|
export default CustomerProfile
|