Merge pull request 'Feature-add-shipment' (#1) from longbot/WEB:Feature-add-shipment into main
Reviewed-on: #1
This commit is contained in:
commit
7e6de57924
42
.umirc.ts
42
.umirc.ts
|
|
@ -124,27 +124,27 @@ export default defineConfig({
|
|||
},
|
||||
],
|
||||
},
|
||||
// {
|
||||
// name: '物流管理',
|
||||
// path: '/logistics',
|
||||
// routes: [
|
||||
// {
|
||||
// name: '服务商',
|
||||
// path: '/logistics/services',
|
||||
// component: './Logistics/Services',
|
||||
// },
|
||||
// {
|
||||
// name: '地址管理',
|
||||
// path: '/logistics/address',
|
||||
// component: './Logistics/Address',
|
||||
// },
|
||||
// {
|
||||
// name: '物流列表',
|
||||
// path: '/logistics/list',
|
||||
// component: './Logistics/List',
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
{
|
||||
name: '物流管理',
|
||||
path: '/logistics',
|
||||
routes: [
|
||||
{
|
||||
name: '服务商',
|
||||
path: '/logistics/services',
|
||||
component: './Logistics/Services',
|
||||
},
|
||||
{
|
||||
name: '地址管理',
|
||||
path: '/logistics/address',
|
||||
component: './Logistics/Address',
|
||||
},
|
||||
{
|
||||
name: '物流列表',
|
||||
path: '/logistics/list',
|
||||
component: './Logistics/List',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: '数据统计',
|
||||
path: '/statistics',
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ const ListPage: React.FC = () => {
|
|||
{
|
||||
title: '仓库',
|
||||
dataIndex: 'stockPointId',
|
||||
hideInTable: true,
|
||||
// hideInTable: true,
|
||||
valueType: 'select',
|
||||
request: async () => {
|
||||
const { data = [] } = await stockcontrollerGetallstockpoints();
|
||||
|
|
@ -42,11 +42,11 @@ const ListPage: React.FC = () => {
|
|||
render(_, record) {
|
||||
return (
|
||||
<>
|
||||
{record.primary_tracking_number}
|
||||
{record.unique_id}
|
||||
<CopyOutlined
|
||||
onClick={async () => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(record.tracking_url);
|
||||
await navigator.clipboard.writeText(record.unique_id);
|
||||
message.success('复制成功!');
|
||||
} catch (err) {
|
||||
message.error('复制失败!');
|
||||
|
|
|
|||
|
|
@ -68,23 +68,23 @@ const ListPage: React.FC = () => {
|
|||
actionRef={actionRef}
|
||||
rowKey="id"
|
||||
toolBarRender={() => [
|
||||
<Button
|
||||
key="syncSite"
|
||||
type="primary"
|
||||
onClick={async () => {
|
||||
try {
|
||||
const { success } = await logisticscontrollerSyncservices();
|
||||
if (!success) {
|
||||
throw new Error('同步失败');
|
||||
}
|
||||
actionRef.current?.reload();
|
||||
} catch (e: any) {
|
||||
message.error(e?.message || '同步失败');
|
||||
}
|
||||
}}
|
||||
>
|
||||
同步服务商
|
||||
</Button>,
|
||||
// <Button
|
||||
// key="syncSite"
|
||||
// type="primary"
|
||||
// onClick={async () => {
|
||||
// try {
|
||||
// const { success } = await logisticscontrollerSyncservices();
|
||||
// if (!success) {
|
||||
// throw new Error('同步失败');
|
||||
// }
|
||||
// actionRef.current?.reload();
|
||||
// } catch (e: any) {
|
||||
// message.error(e?.message || '同步失败');
|
||||
// }
|
||||
// }}
|
||||
// >
|
||||
// 同步服务商
|
||||
// </Button>,
|
||||
]}
|
||||
request={async (values) => {
|
||||
console.log(values);
|
||||
|
|
|
|||
|
|
@ -1027,7 +1027,6 @@ const Shipping: React.FC<{
|
|||
const [rates, setRates] = useState<API.RateDTO[]>([]);
|
||||
const [ratesLoading, setRatesLoading] = useState(false);
|
||||
const { message } = App.useApp();
|
||||
const [serviceType, setServiceType] = useState('');
|
||||
|
||||
return (
|
||||
<ModalForm
|
||||
|
|
@ -1076,7 +1075,7 @@ const Shipping: React.FC<{
|
|||
if (shipmentInfo) shipmentInfo = JSON.parse(shipmentInfo);
|
||||
return {
|
||||
...data,
|
||||
payment_method_id: shipmentInfo?.payment_method_id,
|
||||
// payment_method_id: shipmentInfo?.payment_method_id,
|
||||
stockPointId: shipmentInfo?.stockPointId,
|
||||
details: {
|
||||
destination: {
|
||||
|
|
@ -1148,7 +1147,6 @@ const Shipping: React.FC<{
|
|||
await logisticscontrollerCreateshipment(
|
||||
{ orderId: id },
|
||||
{
|
||||
service_type: serviceType,
|
||||
details,
|
||||
...data,
|
||||
},
|
||||
|
|
@ -1161,7 +1159,7 @@ const Shipping: React.FC<{
|
|||
localStorage.setItem(
|
||||
'shipmentInfo',
|
||||
JSON.stringify({
|
||||
payment_method_id: data.payment_method_id,
|
||||
// payment_method_id: data.payment_method_id,
|
||||
stockPointId: data.stockPointId,
|
||||
region: details.origin.address.region,
|
||||
city: details.origin.address.city,
|
||||
|
|
@ -1213,7 +1211,7 @@ const Shipping: React.FC<{
|
|||
}}
|
||||
/>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
{/* <Col span={12}>
|
||||
<ProFormSelect
|
||||
label="付款方式"
|
||||
name="payment_method_id"
|
||||
|
|
@ -1230,7 +1228,7 @@ const Shipping: React.FC<{
|
|||
return [];
|
||||
}}
|
||||
/>
|
||||
</Col>
|
||||
</Col> */}
|
||||
</Row>
|
||||
<Row gutter={16}>
|
||||
<Col span={12}>
|
||||
|
|
@ -1729,62 +1727,6 @@ const Shipping: React.FC<{
|
|||
}
|
||||
}}
|
||||
</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>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -141,11 +141,6 @@ declare namespace API {
|
|||
email_addresses?: any;
|
||||
};
|
||||
|
||||
type LoginDTO = {
|
||||
username?: string;
|
||||
password?: string;
|
||||
};
|
||||
|
||||
type LoginRes = {
|
||||
/** 状态码 */
|
||||
code?: number;
|
||||
|
|
@ -213,6 +208,7 @@ declare namespace API {
|
|||
externalOrderId?: string;
|
||||
status?: any;
|
||||
orderStatus?: any;
|
||||
shipmentId?: string;
|
||||
currency?: string;
|
||||
currency_symbol?: string;
|
||||
prices_include_tax?: boolean;
|
||||
|
|
@ -343,6 +339,7 @@ declare namespace API {
|
|||
externalOrderId?: string;
|
||||
status?: any;
|
||||
orderStatus?: any;
|
||||
shipmentId?: string;
|
||||
currency?: string;
|
||||
currency_symbol?: string;
|
||||
prices_include_tax?: boolean;
|
||||
|
|
@ -386,7 +383,6 @@ declare namespace API {
|
|||
items?: OrderItem[];
|
||||
sales?: OrderSale[];
|
||||
refundItems?: OrderRefundItem[];
|
||||
trackings?: Tracking[];
|
||||
notes?: OrderNote[];
|
||||
};
|
||||
|
||||
|
|
@ -984,28 +980,11 @@ declare namespace API {
|
|||
|
||||
type ShipmentBookDTO = {
|
||||
sales?: OrderSale[];
|
||||
payment_method_id?: string;
|
||||
service_id?: string;
|
||||
service_type?: string;
|
||||
details?: ShippingDetailsDTO;
|
||||
stockPointId?: 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 = {
|
||||
id?: number;
|
||||
name?: string;
|
||||
|
|
@ -1270,27 +1249,6 @@ declare namespace API {
|
|||
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 = {
|
||||
/** 分类名称 */
|
||||
name?: string;
|
||||
|
|
|
|||
|
|
@ -37,13 +37,13 @@ export async function usercontrollerListusers(options?: {
|
|||
|
||||
/** 此处后端没有提供注释 POST /user/login */
|
||||
export async function usercontrollerLogin(
|
||||
body: API.LoginDTO,
|
||||
body: Record<string, any>,
|
||||
options?: { [key: string]: any },
|
||||
) {
|
||||
return request<API.LoginRes>('/user/login', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Type': 'text/plain',
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
|
|
|
|||
|
|
@ -55,6 +55,12 @@ export function formatShipmentState(state: string) {
|
|||
return '丢失';
|
||||
case 'cancelled':
|
||||
return '取消';
|
||||
case '190': // ORDER_RECEIVED
|
||||
return '订单待发送';
|
||||
case '202': // IN_TRANSIT
|
||||
return '在途中';
|
||||
case '203': // DELIVERED
|
||||
return '订单已送达';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue