zksu
/
WEB
forked from yoone/WEB
1
0
Fork 0

Merge pull request 'Feature-add-shipment' (#1) from longbot/WEB:Feature-add-shipment into main

Reviewed-on: yoone/WEB#1
This commit is contained in:
yoone 2025-08-07 08:36:52 +00:00
commit 7e6de57924
7 changed files with 55 additions and 149 deletions

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

@ -141,11 +141,6 @@ declare namespace API {
email_addresses?: any; email_addresses?: any;
}; };
type LoginDTO = {
username?: string;
password?: string;
};
type LoginRes = { type LoginRes = {
/** 状态码 */ /** 状态码 */
code?: number; code?: number;
@ -213,6 +208,7 @@ declare namespace API {
externalOrderId?: string; externalOrderId?: string;
status?: any; status?: any;
orderStatus?: any; orderStatus?: any;
shipmentId?: string;
currency?: string; currency?: string;
currency_symbol?: string; currency_symbol?: string;
prices_include_tax?: boolean; prices_include_tax?: boolean;
@ -343,6 +339,7 @@ declare namespace API {
externalOrderId?: string; externalOrderId?: string;
status?: any; status?: any;
orderStatus?: any; orderStatus?: any;
shipmentId?: string;
currency?: string; currency?: string;
currency_symbol?: string; currency_symbol?: string;
prices_include_tax?: boolean; prices_include_tax?: boolean;
@ -386,7 +383,6 @@ declare namespace API {
items?: OrderItem[]; items?: OrderItem[];
sales?: OrderSale[]; sales?: OrderSale[];
refundItems?: OrderRefundItem[]; refundItems?: OrderRefundItem[];
trackings?: Tracking[];
notes?: OrderNote[]; notes?: OrderNote[];
}; };
@ -984,28 +980,11 @@ declare namespace API {
type ShipmentBookDTO = { type ShipmentBookDTO = {
sales?: OrderSale[]; sales?: OrderSale[];
payment_method_id?: string;
service_id?: string;
service_type?: string;
details?: ShippingDetailsDTO; details?: ShippingDetailsDTO;
stockPointId?: number; stockPointId?: number;
orderIds?: number[]; orderIds?: number[];
}; };
type ShipmentItem = {
id?: number;
shipment_id?: string;
productId?: number;
name?: string;
/** sku */
sku?: string;
quantity?: number;
/** 创建时间 */
createdAt: string;
/** 更新时间 */
updatedAt: string;
};
type ShippingAddress = { type ShippingAddress = {
id?: number; id?: number;
name?: string; name?: string;
@ -1270,27 +1249,6 @@ declare namespace API {
minute?: string; minute?: string;
}; };
type Tracking = {
id?: string;
tracking_provider?: string;
unique_id?: string;
transaction_number?: string;
primary_tracking_number?: string;
tracking_numbers?: string[];
tracking_url?: string;
return_tracking_number?: string;
bol_number?: string;
pickup_confirmation_number?: string;
customs_invoice_url?: string;
rate?: Record<string, any>;
labels?: any;
/** 创建时间 */
createdAt: string;
/** 更新时间 */
updatedAt: string;
products?: ShipmentItem[];
};
type UpdateCategoryDTO = { type UpdateCategoryDTO = {
/** 分类名称 */ /** 分类名称 */
name?: string; name?: string;

View File

@ -37,13 +37,13 @@ export async function usercontrollerListusers(options?: {
/** 此处后端没有提供注释 POST /user/login */ /** 此处后端没有提供注释 POST /user/login */
export async function usercontrollerLogin( export async function usercontrollerLogin(
body: API.LoginDTO, body: Record<string, any>,
options?: { [key: string]: any }, options?: { [key: string]: any },
) { ) {
return request<API.LoginRes>('/user/login', { return request<API.LoginRes>('/user/login', {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'text/plain',
}, },
data: body, data: body,
...(options || {}), ...(options || {}),

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 '';
} }