forked from yoone/WEB
1
0
Fork 0

Compare commits

..

No commits in common. "703e2c87cb34ffe8266745ceff3e723651186a70" 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: '物流管理',
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',

View File

@ -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.unique_id}
{record.primary_tracking_number}
<CopyOutlined
onClick={async () => {
try {
await navigator.clipboard.writeText(record.unique_id);
await navigator.clipboard.writeText(record.tracking_url);
message.success('复制成功!');
} catch (err) {
message.error('复制失败!');

View File

@ -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);

View File

@ -1027,6 +1027,7 @@ 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
@ -1075,7 +1076,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: {
@ -1147,6 +1148,7 @@ const Shipping: React.FC<{
await logisticscontrollerCreateshipment(
{ orderId: id },
{
service_type: serviceType,
details,
...data,
},
@ -1159,7 +1161,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,
@ -1211,7 +1213,7 @@ const Shipping: React.FC<{
}}
/>
</Col>
{/* <Col span={12}>
<Col span={12}>
<ProFormSelect
label="付款方式"
name="payment_method_id"
@ -1228,7 +1230,7 @@ const Shipping: React.FC<{
return [];
}}
/>
</Col> */}
</Col>
</Row>
<Row gutter={16}>
<Col span={12}>
@ -1727,6 +1729,62 @@ 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>
);
};

View File

@ -141,6 +141,11 @@ declare namespace API {
email_addresses?: any;
};
type LoginDTO = {
username?: string;
password?: string;
};
type LoginRes = {
/** 状态码 */
code?: number;
@ -208,7 +213,6 @@ declare namespace API {
externalOrderId?: string;
status?: any;
orderStatus?: any;
shipmentId?: string;
currency?: string;
currency_symbol?: string;
prices_include_tax?: boolean;
@ -339,7 +343,6 @@ declare namespace API {
externalOrderId?: string;
status?: any;
orderStatus?: any;
shipmentId?: string;
currency?: string;
currency_symbol?: string;
prices_include_tax?: boolean;
@ -383,6 +386,7 @@ declare namespace API {
items?: OrderItem[];
sales?: OrderSale[];
refundItems?: OrderRefundItem[];
trackings?: Tracking[];
notes?: OrderNote[];
};
@ -980,11 +984,28 @@ 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;
@ -1249,6 +1270,27 @@ 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;

View File

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

View File

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