|
|
@ -13,7 +13,7 @@ import {
|
|
|
|
} from '@ant-design/icons'
|
|
|
|
} from '@ant-design/icons'
|
|
|
|
|
|
|
|
|
|
|
|
import { useEffect, useState } from 'react'
|
|
|
|
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 { App, Flex, Select, Tooltip, Divider, Typography, Skeleton, Checkbox, Drawer, Button, Form, Input } from 'antd'
|
|
|
|
import { useOrderStore, fetchSetRemindStateAction, OrderLabelDefaultOptions, OrderStatusDefaultOptions, remindStatusOptions } from '@/stores/OrderStore'
|
|
|
|
import { useOrderStore, fetchSetRemindStateAction, OrderLabelDefaultOptions, OrderStatusDefaultOptions, remindStatusOptions } from '@/stores/OrderStore'
|
|
|
|
import { copy, isEmpty } from '@/utils/commons'
|
|
|
|
import { copy, isEmpty } from '@/utils/commons'
|
|
|
@ -21,24 +21,28 @@ import { useShallow } from 'zustand/react/shallow'
|
|
|
|
import useConversationStore from '@/stores/ConversationStore'
|
|
|
|
import useConversationStore from '@/stores/ConversationStore'
|
|
|
|
import useAuthStore from '@/stores/AuthStore'
|
|
|
|
import useAuthStore from '@/stores/AuthStore'
|
|
|
|
const OrderProfile = ({ coliSN, ...props }) => {
|
|
|
|
const OrderProfile = ({ coliSN, ...props }) => {
|
|
|
|
const navigate = useNavigate()
|
|
|
|
|
|
|
|
const { notification, message } = App.useApp()
|
|
|
|
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 [loading, setLoading] = useState(false)
|
|
|
|
|
|
|
|
|
|
|
|
const [openOrderCommnet, setOpenOrderCommnet] = useState(false)
|
|
|
|
const [openOrderCommnet, setOpenOrderCommnet] = useState(false)
|
|
|
|
const [openWhatsApp, setOpenWhatsApp] = useState(false)
|
|
|
|
const [openWhatsApp, setOpenWhatsApp] = useState(false)
|
|
|
|
|
|
|
|
const [openExtra, setOpenExtra] = useState(false)
|
|
|
|
|
|
|
|
|
|
|
|
const orderLabelOptions = copy(OrderLabelDefaultOptions)
|
|
|
|
const orderLabelOptions = copy(OrderLabelDefaultOptions)
|
|
|
|
orderLabelOptions.unshift({ value: 0, label: '未设置', disabled: true })
|
|
|
|
orderLabelOptions.unshift({ value: 0, label: '未设置', disabled: true })
|
|
|
|
|
|
|
|
|
|
|
|
const orderStatusOptions = copy(OrderStatusDefaultOptions)
|
|
|
|
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.orderDetail,
|
|
|
|
s.customerDetail,
|
|
|
|
s.customerDetail,
|
|
|
|
s.fetchOrderDetail,
|
|
|
|
s.fetchOrderDetail,
|
|
|
|
s.setOrderPropValue,
|
|
|
|
s.setOrderPropValue,
|
|
|
|
s.appendOrderComment,
|
|
|
|
s.appendOrderComment,
|
|
|
|
|
|
|
|
s.updateWhatsapp,
|
|
|
|
|
|
|
|
s.updateExtraInfo,
|
|
|
|
])
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
const loginUser = useAuthStore((state) => state.loginUser)
|
|
|
|
const loginUser = useAuthStore((state) => state.loginUser)
|
|
|
@ -47,8 +51,8 @@ const OrderProfile = ({ coliSN, ...props }) => {
|
|
|
|
|
|
|
|
|
|
|
|
const [orderRemindState, setOrderRemindState] = useState(orderDetail.remindstate)
|
|
|
|
const [orderRemindState, setOrderRemindState] = useState(orderDetail.remindstate)
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
setOrderRemindState(orderDetail.remindstate);
|
|
|
|
setOrderRemindState(orderDetail.remindstate)
|
|
|
|
}, [orderDetail.remindstate]);
|
|
|
|
}, [orderDetail.remindstate])
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
if (orderId) {
|
|
|
|
if (orderId) {
|
|
|
|
setLoading(true)
|
|
|
|
setLoading(true)
|
|
|
@ -119,12 +123,15 @@ const OrderProfile = ({ coliSN, ...props }) => {
|
|
|
|
</Typography.Text>
|
|
|
|
</Typography.Text>
|
|
|
|
<Typography.Text>
|
|
|
|
<Typography.Text>
|
|
|
|
<WhatsAppOutlined className='pr-1' />
|
|
|
|
<WhatsAppOutlined className='pr-1' />
|
|
|
|
{isEmpty(customerDetail.whatsapp_phone_number) ?
|
|
|
|
{isEmpty(customerDetail.whatsapp_phone_number) ? (
|
|
|
|
<Button type="text" onClick={() => setOpenWhatsApp(true)} size='small'>设置 WhatsApp</Button> :
|
|
|
|
<Button type='text' onClick={() => setOpenWhatsApp(true)} size='small'>
|
|
|
|
<Link to={`/order/chat/${coliSN}`} state={orderDetail}>
|
|
|
|
设置 WhatsApp
|
|
|
|
{customerDetail.whatsapp_phone_number}
|
|
|
|
</Button>
|
|
|
|
</Link>
|
|
|
|
) : (
|
|
|
|
}
|
|
|
|
<Link to={`/order/chat/${coliSN}`} state={orderDetail}>
|
|
|
|
|
|
|
|
{customerDetail.whatsapp_phone_number}
|
|
|
|
|
|
|
|
</Link>
|
|
|
|
|
|
|
|
)}
|
|
|
|
</Typography.Text>
|
|
|
|
</Typography.Text>
|
|
|
|
<Typography.Text>
|
|
|
|
<Typography.Text>
|
|
|
|
<Tooltip title='出发日期'>
|
|
|
|
<Tooltip title='出发日期'>
|
|
|
@ -227,9 +234,14 @@ const OrderProfile = ({ coliSN, ...props }) => {
|
|
|
|
|
|
|
|
|
|
|
|
<Divider orientation='left'>
|
|
|
|
<Divider orientation='left'>
|
|
|
|
<Typography.Text strong>附加信息</Typography.Text>
|
|
|
|
<Typography.Text strong>附加信息</Typography.Text>
|
|
|
|
{/* <Tooltip title='修改'>
|
|
|
|
<Tooltip title='修改'>
|
|
|
|
<EditOutlined className='pl-1' />
|
|
|
|
<EditOutlined
|
|
|
|
</Tooltip> */}
|
|
|
|
className='pl-1'
|
|
|
|
|
|
|
|
onClick={() => {
|
|
|
|
|
|
|
|
setOpenExtra(true)
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</Tooltip>
|
|
|
|
</Divider>
|
|
|
|
</Divider>
|
|
|
|
<Typography.Text>{orderDetail.COLI_Introduction}</Typography.Text>
|
|
|
|
<Typography.Text>{orderDetail.COLI_Introduction}</Typography.Text>
|
|
|
|
</Skeleton>
|
|
|
|
</Skeleton>
|
|
|
@ -240,7 +252,6 @@ const OrderProfile = ({ coliSN, ...props }) => {
|
|
|
|
initialValues={{ comment: '' }}
|
|
|
|
initialValues={{ comment: '' }}
|
|
|
|
scrollToFirstError
|
|
|
|
scrollToFirstError
|
|
|
|
onFinish={(values) => {
|
|
|
|
onFinish={(values) => {
|
|
|
|
console.log('Received values of form: ', values)
|
|
|
|
|
|
|
|
appendOrderComment(loginUser.userId, orderId, values.comment)
|
|
|
|
appendOrderComment(loginUser.userId, orderId, values.comment)
|
|
|
|
.then(() => {
|
|
|
|
.then(() => {
|
|
|
|
notification.success({
|
|
|
|
notification.success({
|
|
|
@ -276,15 +287,49 @@ const OrderProfile = ({ coliSN, ...props }) => {
|
|
|
|
initialValues={{ number: '' }}
|
|
|
|
initialValues={{ number: '' }}
|
|
|
|
scrollToFirstError
|
|
|
|
scrollToFirstError
|
|
|
|
onFinish={(values) => {
|
|
|
|
onFinish={(values) => {
|
|
|
|
console.log('Received values of form: ', values)
|
|
|
|
updateWhatsapp(orderId, values.number)
|
|
|
|
// appendOrderComment(loginUser.userId, orderId, values.number)
|
|
|
|
|
|
|
|
.then(() => {
|
|
|
|
.then(() => {
|
|
|
|
notification.success({
|
|
|
|
notification.success({
|
|
|
|
message: '温性提示',
|
|
|
|
message: '温性提示',
|
|
|
|
description: '设置 WhatsApp 成功',
|
|
|
|
description: '设置 WhatsApp 成功',
|
|
|
|
})
|
|
|
|
})
|
|
|
|
setOpenWhatsApp(false)
|
|
|
|
setOpenWhatsApp(false)
|
|
|
|
formComment.setFieldsValue({ number: '' })
|
|
|
|
formWhatsApp.setFieldsValue({ number: '' })
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.catch((reason) => {
|
|
|
|
|
|
|
|
notification.error({
|
|
|
|
|
|
|
|
message: '设置出错',
|
|
|
|
|
|
|
|
description: reason.message,
|
|
|
|
|
|
|
|
placement: 'top',
|
|
|
|
|
|
|
|
duration: 60,
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}}>
|
|
|
|
|
|
|
|
<Form.Item name='number' label='WhatsApp' rules={[{ required: true, message: '请输入 WhatsApp 号码' }]}>
|
|
|
|
|
|
|
|
<Input placeholder='国家代码+城市代码+电话号码' />
|
|
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
<Form.Item>
|
|
|
|
|
|
|
|
<Button type='primary' htmlType='submit'>
|
|
|
|
|
|
|
|
提交
|
|
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
|
|
</Form>
|
|
|
|
|
|
|
|
</Drawer>
|
|
|
|
|
|
|
|
<Drawer title='设置附加信息' closable={{ 'aria-label': 'Close Button' }} onClose={() => setOpenExtra(false)} open={openExtra}>
|
|
|
|
|
|
|
|
<Form
|
|
|
|
|
|
|
|
layout={'vertical'}
|
|
|
|
|
|
|
|
form={formExtra}
|
|
|
|
|
|
|
|
initialValues={{ text: '' }}
|
|
|
|
|
|
|
|
scrollToFirstError
|
|
|
|
|
|
|
|
onFinish={(values) => {
|
|
|
|
|
|
|
|
console.log('Received values of form: ', values)
|
|
|
|
|
|
|
|
updateExtraInfo(orderId, values.extra)
|
|
|
|
|
|
|
|
.then(() => {
|
|
|
|
|
|
|
|
notification.success({
|
|
|
|
|
|
|
|
message: '温性提示',
|
|
|
|
|
|
|
|
description: '设置附加信息成功',
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
setOpenExtra(false)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch((reason) => {
|
|
|
|
.catch((reason) => {
|
|
|
|
notification.error({
|
|
|
|
notification.error({
|
|
|
@ -295,8 +340,8 @@ const OrderProfile = ({ coliSN, ...props }) => {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}}>
|
|
|
|
}}>
|
|
|
|
<Form.Item name='comment' label='WhatsApp' rules={[{ required: true, message: '请输入 WhatsApp 号码' }]}>
|
|
|
|
<Form.Item name='extra' label='附加信息' rules={[{ required: true, message: '请输入附加信息' }]}>
|
|
|
|
<Input placeholder='国家代码+城市代码+电话号码'/>
|
|
|
|
<Input />
|
|
|
|
</Form.Item>
|
|
|
|
</Form.Item>
|
|
|
|
<Form.Item>
|
|
|
|
<Form.Item>
|
|
|
|
<Button type='primary' htmlType='submit'>
|
|
|
|
<Button type='primary' htmlType='submit'>
|
|
|
|