forked from yoone/WEB
feat(订单): 添加发货平台选择功能并优化表单验证
- 在发货表单中新增发货平台选择器 - 将公司名称字段改为非必填 - 添加控制台日志用于调试 - 优化地址选择器的数据处理逻辑
This commit is contained in:
parent
3690fd00f7
commit
1d9838f72e
|
|
@ -77,6 +77,7 @@ import {
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import React, { useMemo, useRef, useState } from 'react';
|
import React, { useMemo, useRef, useState } from 'react';
|
||||||
import RelatedOrders from '../../Subscription/Orders/RelatedOrders';
|
import RelatedOrders from '../../Subscription/Orders/RelatedOrders';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
const ListPage: React.FC = () => {
|
const ListPage: React.FC = () => {
|
||||||
const actionRef = useRef<ActionType>();
|
const actionRef = useRef<ActionType>();
|
||||||
|
|
@ -1267,7 +1268,10 @@ const Shipping: React.FC<{
|
||||||
const [rates, setRates] = useState<API.RateDTO[]>([]);
|
const [rates, setRates] = useState<API.RateDTO[]>([]);
|
||||||
const [ratesLoading, setRatesLoading] = useState(false);
|
const [ratesLoading, setRatesLoading] = useState(false);
|
||||||
const { message } = App.useApp();
|
const { message } = App.useApp();
|
||||||
|
const [shipmentPlatforms, setShipmentPlatforms] = useState([
|
||||||
|
{ label: 'uniuni', value: 'uniuni' },
|
||||||
|
{ label: 'tms.freightwaves', value: 'freightwaves' },
|
||||||
|
]);
|
||||||
return (
|
return (
|
||||||
<ModalForm
|
<ModalForm
|
||||||
formRef={formRef}
|
formRef={formRef}
|
||||||
|
|
@ -1296,6 +1300,7 @@ const Shipping: React.FC<{
|
||||||
await ordercontrollerGetorderdetail({
|
await ordercontrollerGetorderdetail({
|
||||||
orderId: id,
|
orderId: id,
|
||||||
});
|
});
|
||||||
|
console.log('success data',success,data)
|
||||||
if (!success || !data) return {};
|
if (!success || !data) return {};
|
||||||
data.sales = data.sales?.reduce(
|
data.sales = data.sales?.reduce(
|
||||||
(acc: API.OrderSale[], cur: API.OrderSale) => {
|
(acc: API.OrderSale[], cur: API.OrderSale) => {
|
||||||
|
|
@ -1318,7 +1323,8 @@ const Shipping: React.FC<{
|
||||||
if (reShipping) data.sales = [{}];
|
if (reShipping) data.sales = [{}];
|
||||||
let shipmentInfo = localStorage.getItem('shipmentInfo');
|
let shipmentInfo = localStorage.getItem('shipmentInfo');
|
||||||
if (shipmentInfo) shipmentInfo = JSON.parse(shipmentInfo);
|
if (shipmentInfo) shipmentInfo = JSON.parse(shipmentInfo);
|
||||||
return {
|
const a = {
|
||||||
|
shipmentPlatform: 'uniuni',
|
||||||
...data,
|
...data,
|
||||||
// payment_method_id: shipmentInfo?.payment_method_id,
|
// payment_method_id: shipmentInfo?.payment_method_id,
|
||||||
stockPointId: shipmentInfo?.stockPointId,
|
stockPointId: shipmentInfo?.stockPointId,
|
||||||
|
|
@ -1378,6 +1384,8 @@ const Shipping: React.FC<{
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
console.log('data',a)
|
||||||
|
return a
|
||||||
}}
|
}}
|
||||||
onFinish={async ({
|
onFinish={async ({
|
||||||
customer_note,
|
customer_note,
|
||||||
|
|
@ -1441,7 +1449,18 @@ const Shipping: React.FC<{
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ProFormText label="订单号" readonly name={'externalOrderId'} />
|
<Row gutter={16}>
|
||||||
|
<Col span={8}>
|
||||||
|
<ProFormSelect
|
||||||
|
name="shipmentPlatform"
|
||||||
|
label="发货平台"
|
||||||
|
options={shipmentPlatforms}
|
||||||
|
placeholder="请选择发货平台"
|
||||||
|
rules={[{ required: true, message: '请选择一个选项' }]}
|
||||||
|
/>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
<ProFormText label="订单号" readonly name='externalOrderId' />
|
||||||
<ProFormText label="客户备注" readonly name="customer_note" />
|
<ProFormText label="客户备注" readonly name="customer_note" />
|
||||||
<ProFormList
|
<ProFormList
|
||||||
label="后台备注"
|
label="后台备注"
|
||||||
|
|
@ -1573,16 +1592,20 @@ const Shipping: React.FC<{
|
||||||
title="发货信息"
|
title="发货信息"
|
||||||
extra={
|
extra={
|
||||||
<AddressPicker
|
<AddressPicker
|
||||||
onChange={({
|
onChange={(row) => {
|
||||||
address,
|
console.log(row);
|
||||||
phone_number,
|
const {
|
||||||
phone_number_extension,
|
address,
|
||||||
stockPointId,
|
phone_number,
|
||||||
}) => {
|
phone_number_extension,
|
||||||
|
stockPointId,
|
||||||
|
} = row;
|
||||||
formRef?.current?.setFieldsValue({
|
formRef?.current?.setFieldsValue({
|
||||||
stockPointId,
|
stockPointId,
|
||||||
|
// address_id: row.id,
|
||||||
details: {
|
details: {
|
||||||
origin: {
|
origin: {
|
||||||
|
|
||||||
address,
|
address,
|
||||||
phone_number: {
|
phone_number: {
|
||||||
phone: phone_number,
|
phone: phone_number,
|
||||||
|
|
@ -1595,6 +1618,11 @@ const Shipping: React.FC<{
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
{/* <ProFormText
|
||||||
|
label="address_id"
|
||||||
|
name={'address_id'}
|
||||||
|
rules={[{ required: true, message: '请输入ID' }]}
|
||||||
|
/> */}
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
name="stockPointId"
|
name="stockPointId"
|
||||||
width="md"
|
width="md"
|
||||||
|
|
@ -1687,7 +1715,7 @@ const Shipping: React.FC<{
|
||||||
<ProFormText
|
<ProFormText
|
||||||
label="公司名称"
|
label="公司名称"
|
||||||
name={['details', 'destination', 'name']}
|
name={['details', 'destination', 'name']}
|
||||||
rules={[{ required: true, message: '请输入公司名称' }]}
|
rules={[{ message: '请输入公司名称' }]}
|
||||||
/>
|
/>
|
||||||
<ProFormItem
|
<ProFormItem
|
||||||
name={['details', 'destination', 'address', 'country']}
|
name={['details', 'destination', 'address', 'country']}
|
||||||
|
|
@ -2017,6 +2045,7 @@ const Shipping: React.FC<{
|
||||||
details.origin.phone_number.number =
|
details.origin.phone_number.number =
|
||||||
details.origin.phone_number.phone;
|
details.origin.phone_number.phone;
|
||||||
const res = await logisticscontrollerGetshipmentfee({
|
const res = await logisticscontrollerGetshipmentfee({
|
||||||
|
shipmentPlatform: data.shipmentPlatform,
|
||||||
stockPointId: data.stockPointId,
|
stockPointId: data.stockPointId,
|
||||||
|
|
||||||
sender: details.origin.contact_name,
|
sender: details.origin.contact_name,
|
||||||
|
|
@ -2343,7 +2372,7 @@ const CreateOrder: React.FC<{
|
||||||
<ProFormText
|
<ProFormText
|
||||||
label="公司名称"
|
label="公司名称"
|
||||||
name={['billing', 'company']}
|
name={['billing', 'company']}
|
||||||
rules={[{ required: true, message: '请输入公司名称' }]}
|
rules={[{ message: '请输入公司名称' }]}
|
||||||
/>
|
/>
|
||||||
<ProFormItem
|
<ProFormItem
|
||||||
name={['billing', 'country']}
|
name={['billing', 'country']}
|
||||||
|
|
@ -2429,6 +2458,11 @@ const AddressPicker: React.FC<{
|
||||||
value: item.id,
|
value: item.id,
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'id',
|
||||||
|
dataIndex: ['id'],
|
||||||
|
hideInSearch: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '地区',
|
title: '地区',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue