Compare commits

..

No commits in common. "7e6de57924aab59d1eb835d20a97b5e7f3db02f8" and "c06cb33e89693b84f3e477d732db397d39df193d" have entirely different histories.

7 changed files with 149 additions and 55 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.unique_id} {record.primary_tracking_number}
<CopyOutlined <CopyOutlined
onClick={async () => { onClick={async () => {
try { try {
await navigator.clipboard.writeText(record.unique_id); await navigator.clipboard.writeText(record.tracking_url);
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,6 +1027,7 @@ 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
@ -1075,7 +1076,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: {
@ -1147,6 +1148,7 @@ const Shipping: React.FC<{
await logisticscontrollerCreateshipment( await logisticscontrollerCreateshipment(
{ orderId: id }, { orderId: id },
{ {
service_type: serviceType,
details, details,
...data, ...data,
}, },
@ -1159,7 +1161,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,
@ -1211,7 +1213,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"
@ -1228,7 +1230,7 @@ const Shipping: React.FC<{
return []; return [];
}} }}
/> />
</Col> */} </Col>
</Row> </Row>
<Row gutter={16}> <Row gutter={16}>
<Col span={12}> <Col span={12}>
@ -1727,6 +1729,62 @@ 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,6 +141,11 @@ declare namespace API {
email_addresses?: any; email_addresses?: any;
}; };
type LoginDTO = {
username?: string;
password?: string;
};
type LoginRes = { type LoginRes = {
/** 状态码 */ /** 状态码 */
code?: number; code?: number;
@ -208,7 +213,6 @@ 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;
@ -339,7 +343,6 @@ 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;
@ -383,6 +386,7 @@ declare namespace API {
items?: OrderItem[]; items?: OrderItem[];
sales?: OrderSale[]; sales?: OrderSale[];
refundItems?: OrderRefundItem[]; refundItems?: OrderRefundItem[];
trackings?: Tracking[];
notes?: OrderNote[]; notes?: OrderNote[];
}; };
@ -980,11 +984,28 @@ 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;
@ -1249,6 +1270,27 @@ 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: Record<string, any>, body: API.LoginDTO,
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': 'text/plain', 'Content-Type': 'application/json',
}, },
data: body, data: body,
...(options || {}), ...(options || {}),

View File

@ -55,12 +55,6 @@ 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 '';
} }