Feature-add-shipment #1

Merged
yoone merged 2 commits from longbot/WEB:Feature-add-shipment into main 2025-08-07 08:36:52 +00:00
6 changed files with 52 additions and 104 deletions
Showing only changes of commit cb7a27530a - Show all commits

View File

@ -124,27 +124,27 @@ export default defineConfig({
}, },
], ],
}, },
// { {
// name: '物流管理', name: '物流管理',
// path: '/logistics', path: '/logistics',
// routes: [ routes: [
// { {
// name: '服务商', name: '服务商',
// path: '/logistics/services', path: '/logistics/services',
// component: './Logistics/Services', component: './Logistics/Services',
// }, },
// { {
// name: '地址管理', name: '地址管理',
// path: '/logistics/address', path: '/logistics/address',
// component: './Logistics/Address', component: './Logistics/Address',
// }, },
// { {
// name: '物流列表', name: '物流列表',
// path: '/logistics/list', path: '/logistics/list',
// component: './Logistics/List', component: './Logistics/List',
// }, },
// ], ],
// }, },
{ {
name: '数据统计', name: '数据统计',
path: '/statistics', path: '/statistics',

View File

@ -26,7 +26,7 @@ const ListPage: React.FC = () => {
{ {
title: '仓库', title: '仓库',
dataIndex: 'stockPointId', dataIndex: 'stockPointId',
hideInTable: true, // hideInTable: true,
valueType: 'select', valueType: 'select',
request: async () => { request: async () => {
const { data = [] } = await stockcontrollerGetallstockpoints(); const { data = [] } = await stockcontrollerGetallstockpoints();
@ -42,11 +42,11 @@ const ListPage: React.FC = () => {
render(_, record) { render(_, record) {
return ( return (
<> <>
{record.primary_tracking_number} {record.unique_id}
<CopyOutlined <CopyOutlined
onClick={async () => { onClick={async () => {
try { try {
await navigator.clipboard.writeText(record.tracking_url); await navigator.clipboard.writeText(record.unique_id);
message.success('复制成功!'); message.success('复制成功!');
} catch (err) { } catch (err) {
message.error('复制失败!'); message.error('复制失败!');

View File

@ -68,23 +68,23 @@ const ListPage: React.FC = () => {
actionRef={actionRef} actionRef={actionRef}
rowKey="id" rowKey="id"
toolBarRender={() => [ toolBarRender={() => [
<Button // <Button
key="syncSite" // key="syncSite"
type="primary" // type="primary"
onClick={async () => { // onClick={async () => {
try { // try {
const { success } = await logisticscontrollerSyncservices(); // const { success } = await logisticscontrollerSyncservices();
if (!success) { // if (!success) {
throw new Error('同步失败'); // throw new Error('同步失败');
} // }
actionRef.current?.reload(); // actionRef.current?.reload();
} catch (e: any) { // } catch (e: any) {
message.error(e?.message || '同步失败'); // message.error(e?.message || '同步失败');
} // }
}} // }}
> // >
// 同步服务商
</Button>, // </Button>,
]} ]}
request={async (values) => { request={async (values) => {
console.log(values); console.log(values);

View File

@ -1027,7 +1027,6 @@ 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 [serviceType, setServiceType] = useState('');
return ( return (
<ModalForm <ModalForm
@ -1076,7 +1075,7 @@ const Shipping: React.FC<{
if (shipmentInfo) shipmentInfo = JSON.parse(shipmentInfo); if (shipmentInfo) shipmentInfo = JSON.parse(shipmentInfo);
return { return {
...data, ...data,
payment_method_id: shipmentInfo?.payment_method_id, // payment_method_id: shipmentInfo?.payment_method_id,
stockPointId: shipmentInfo?.stockPointId, stockPointId: shipmentInfo?.stockPointId,
details: { details: {
destination: { destination: {
@ -1148,7 +1147,6 @@ const Shipping: React.FC<{
await logisticscontrollerCreateshipment( await logisticscontrollerCreateshipment(
{ orderId: id }, { orderId: id },
{ {
service_type: serviceType,
details, details,
...data, ...data,
}, },
@ -1161,7 +1159,7 @@ const Shipping: React.FC<{
localStorage.setItem( localStorage.setItem(
'shipmentInfo', 'shipmentInfo',
JSON.stringify({ JSON.stringify({
payment_method_id: data.payment_method_id, // payment_method_id: data.payment_method_id,
stockPointId: data.stockPointId, stockPointId: data.stockPointId,
region: details.origin.address.region, region: details.origin.address.region,
city: details.origin.address.city, city: details.origin.address.city,
@ -1213,7 +1211,7 @@ const Shipping: React.FC<{
}} }}
/> />
</Col> </Col>
<Col span={12}> {/* <Col span={12}>
<ProFormSelect <ProFormSelect
label="付款方式" label="付款方式"
name="payment_method_id" name="payment_method_id"
@ -1230,7 +1228,7 @@ const Shipping: React.FC<{
return []; return [];
}} }}
/> />
</Col> </Col> */}
</Row> </Row>
<Row gutter={16}> <Row gutter={16}>
<Col span={12}> <Col span={12}>
@ -1729,62 +1727,6 @@ const Shipping: React.FC<{
} }
}} }}
</ProFormDependency> </ProFormDependency>
<Button
loading={ratesLoading}
onClick={async () => {
await formRef?.current?.validateFields(['details']);
setRatesLoading(true);
setRates([]);
const details = formRef?.current?.getFieldFormatValue?.('details');
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;
try {
const {
success,
message: errMsg,
data,
} = await logisticscontrollerGetratelist(details);
if (!success) throw new Error(errMsg);
setRates(data || []);
} catch (error) {
message.error(error?.message || '获取运费失败');
}
setRatesLoading(false);
}}
>
</Button>
<ProFormRadio.Group
label="选择运费"
name="service_id"
rules={[{ required: true, message: '请选择运费' }]}
fieldProps={{
onChange: (e) => {
console.log(e.target.value);
const type = rates.find(
(v) => v.service_id === e.target.value,
)?.type;
setServiceType(type);
},
}}
options={rates
?.sort((a, b) => Number(a?.total?.value) - Number(b?.total?.value))
?.map((rate) => {
return {
label: `${rate.carrier_name} ${rate.service_name} : ${
rate?.total?.value / 100
}${rate?.total?.currency}(${rate.transit_time_days})`,
value: rate.service_id,
};
})}
/>
</ModalForm> </ModalForm>
); );
}; };

View File

@ -984,7 +984,7 @@ declare namespace API {
type ShipmentBookDTO = { type ShipmentBookDTO = {
sales?: OrderSale[]; sales?: OrderSale[];
payment_method_id?: string; // payment_method_id?: string;
service_id?: string; service_id?: string;
service_type?: string; service_type?: string;
details?: ShippingDetailsDTO; details?: ShippingDetailsDTO;

View File

@ -55,6 +55,12 @@ export function formatShipmentState(state: string) {
return '丢失'; return '丢失';
case 'cancelled': case 'cancelled':
return '取消'; return '取消';
case '190': // ORDER_RECEIVED
return '订单待发送';
case '202': // IN_TRANSIT
return '在途中';
case '203': // DELIVERED
return '订单已送达';
default: default:
return ''; return '';
} }