Merge pull request 'Fix: bug fix' (#3) from longbot/WEB:Feature-add-shipment into main
Reviewed-on: #3
This commit is contained in:
commit
644fb1775f
|
|
@ -2,6 +2,7 @@ import InternationalPhoneInput from '@/components/InternationalPhoneInput';
|
||||||
import { ORDER_STATUS_ENUM } from '@/constants';
|
import { ORDER_STATUS_ENUM } from '@/constants';
|
||||||
import {
|
import {
|
||||||
logisticscontrollerCreateshipment,
|
logisticscontrollerCreateshipment,
|
||||||
|
logisticscontrollerGetShipmentFee,
|
||||||
logisticscontrollerDelshipment,
|
logisticscontrollerDelshipment,
|
||||||
logisticscontrollerGetpaymentmethods,
|
logisticscontrollerGetpaymentmethods,
|
||||||
logisticscontrollerGetratelist,
|
logisticscontrollerGetratelist,
|
||||||
|
|
@ -58,6 +59,7 @@ import {
|
||||||
Button,
|
Button,
|
||||||
Card,
|
Card,
|
||||||
Col,
|
Col,
|
||||||
|
Descriptions,
|
||||||
Divider,
|
Divider,
|
||||||
Drawer,
|
Drawer,
|
||||||
Dropdown,
|
Dropdown,
|
||||||
|
|
@ -69,6 +71,7 @@ import {
|
||||||
Tabs,
|
Tabs,
|
||||||
TabsProps,
|
TabsProps,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
|
import Item from 'antd/es/list/Item';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import React, { useMemo, useRef, useState } from 'react';
|
import React, { useMemo, useRef, useState } from 'react';
|
||||||
|
|
||||||
|
|
@ -1025,6 +1028,7 @@ const Shipping: React.FC<{
|
||||||
const [options, setOptions] = useState<any[]>([]);
|
const [options, setOptions] = useState<any[]>([]);
|
||||||
const formRef = useRef<ProFormInstance>();
|
const formRef = useRef<ProFormInstance>();
|
||||||
|
|
||||||
|
const [shipmentFee, setShipmentFee] = useState<number>(0);
|
||||||
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();
|
||||||
|
|
@ -1118,11 +1122,11 @@ const Shipping: React.FC<{
|
||||||
{
|
{
|
||||||
measurements: {
|
measurements: {
|
||||||
weight: {
|
weight: {
|
||||||
unit: 'lb',
|
unit: 'KGS',
|
||||||
value: 1,
|
value: 1,
|
||||||
},
|
},
|
||||||
cuboid: {
|
cuboid: {
|
||||||
unit: 'in',
|
unit: 'CM',
|
||||||
l: 6,
|
l: 6,
|
||||||
w: 4,
|
w: 4,
|
||||||
h: 4,
|
h: 4,
|
||||||
|
|
@ -1133,6 +1137,7 @@ const Shipping: React.FC<{
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
onFinish={async ({ customer_note, notes, items, details, ...data }) => {
|
onFinish={async ({ customer_note, notes, items, details, ...data }) => {
|
||||||
|
|
@ -1653,11 +1658,9 @@ const Shipping: React.FC<{
|
||||||
label="单位"
|
label="单位"
|
||||||
name={['measurements', 'cuboid', 'unit']}
|
name={['measurements', 'cuboid', 'unit']}
|
||||||
valueEnum={{
|
valueEnum={{
|
||||||
mm: '毫米',
|
CM: '厘米',
|
||||||
cm: '厘米',
|
IN: '英寸',
|
||||||
m: '米',
|
FT: '英尺',
|
||||||
in: '英寸',
|
|
||||||
ft: '英尺',
|
|
||||||
}}
|
}}
|
||||||
placeholder="请输入单位"
|
placeholder="请输入单位"
|
||||||
rules={[{ required: true, message: '请输入单位' }]}
|
rules={[{ required: true, message: '请输入单位' }]}
|
||||||
|
|
@ -1673,7 +1676,7 @@ const Shipping: React.FC<{
|
||||||
<ProFormSelect
|
<ProFormSelect
|
||||||
label="单位"
|
label="单位"
|
||||||
name={['measurements', 'weight', 'unit']}
|
name={['measurements', 'weight', 'unit']}
|
||||||
valueEnum={{ kg: '千克', lb: '磅', g: '克', oz: '盎司' }}
|
valueEnum={{ KGS: '千克', LBS: '磅', OZS: '盎司' }}
|
||||||
placeholder="请输入单位"
|
placeholder="请输入单位"
|
||||||
rules={[{ required: true, message: '请输入单位' }]}
|
rules={[{ required: true, message: '请输入单位' }]}
|
||||||
/>
|
/>
|
||||||
|
|
@ -1730,6 +1733,52 @@ const Shipping: React.FC<{
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
</ProFormDependency>
|
</ProFormDependency>
|
||||||
|
<Button
|
||||||
|
loading={ratesLoading}
|
||||||
|
onClick={async () => {
|
||||||
|
try {
|
||||||
|
console.log('test', formRef.current?.getFieldsValue());
|
||||||
|
const { customer_note, notes, items, details, ...data } = formRef.current?.getFieldsValue();
|
||||||
|
const originEmail = details.origin.email_addresses;
|
||||||
|
const destinationEmail = details.destination.email_addresses;
|
||||||
|
details.origin.email_addresses =
|
||||||
|
details.origin.email_addresses.split(',');
|
||||||
|
details.destination.email_addresses =
|
||||||
|
details.destination.email_addresses.split(',');
|
||||||
|
details.destination.phone_number.number =
|
||||||
|
details.destination.phone_number.phone;
|
||||||
|
details.origin.phone_number.number = details.origin.phone_number.phone;
|
||||||
|
const res =
|
||||||
|
await logisticscontrollerGetShipmentFee(
|
||||||
|
{
|
||||||
|
details,
|
||||||
|
...data
|
||||||
|
},
|
||||||
|
);
|
||||||
|
console.log('res', res.data);
|
||||||
|
if (!res?.success) throw new Error(res?.errMsg);
|
||||||
|
const fee = res.data;
|
||||||
|
setShipmentFee(fee);
|
||||||
|
details.origin.email_addresses = originEmail;
|
||||||
|
details.destination.email_addresses = destinationEmail;
|
||||||
|
formRef.current?.setFieldValue("details", {
|
||||||
|
...details,
|
||||||
|
shipmentFee: fee
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
message.error(error?.message || '获取运费失败');
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
获取运费
|
||||||
|
</Button>
|
||||||
|
<ProFormText
|
||||||
|
readonly
|
||||||
|
name={["details", "shipmentFee"]}
|
||||||
|
fieldProps={{
|
||||||
|
value: (shipmentFee / 100.0).toFixed(2)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</ModalForm>
|
</ModalForm>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,22 @@ export async function logisticscontrollerCreateshipment(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 此处后端没有提供注释 POST /logistics/getShipmentFee */
|
||||||
|
export async function logisticscontrollerGetShipmentFee(
|
||||||
|
body: API.ShipmentBookDTO,
|
||||||
|
options?: { [key: string]: any },
|
||||||
|
) {
|
||||||
|
return request<API.BooleanRes>(`/logistics/getShipmentFee`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
data: body,
|
||||||
|
...(options || {}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** 此处后端没有提供注释 POST /logistics/getShipmentLabel/${param0} */
|
/** 此处后端没有提供注释 POST /logistics/getShipmentLabel/${param0} */
|
||||||
export async function logisticscontrollerGetShipmentLabel(
|
export async function logisticscontrollerGetShipmentLabel(
|
||||||
shipmentId: number
|
shipmentId: number
|
||||||
|
|
|
||||||
|
|
@ -1021,6 +1021,7 @@ declare namespace API {
|
||||||
packaging_type?: 'pallet' | 'package' | 'courier-pak' | 'envelope';
|
packaging_type?: 'pallet' | 'package' | 'courier-pak' | 'envelope';
|
||||||
packaging_properties?: PackagingPackage[];
|
packaging_properties?: PackagingPackage[];
|
||||||
reference_codes?: any;
|
reference_codes?: any;
|
||||||
|
shipmentFee: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
type SiteConfig = {
|
type SiteConfig = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue