Feature-add-shipment #5

Merged
longbot merged 2 commits from longbot/WEB:Feature-add-shipment into main 2025-08-11 07:20:01 +00:00
2 changed files with 45 additions and 7 deletions

View File

@ -26,6 +26,7 @@
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"print-js": "^1.6.0", "print-js": "^1.6.0",
"react-phone-input-2": "^2.15.1", "react-phone-input-2": "^2.15.1",
"react-toastify": "^11.0.5",
"xlsx": "^0.18.5" "xlsx": "^0.18.5"
}, },
"devDependencies": { "devDependencies": {

View File

@ -5,19 +5,21 @@ import { stockcontrollerGetallstockpoints } from '@/servers/api/stock';
import { formatShipmentState } from '@/utils/format'; import { formatShipmentState } from '@/utils/format';
import { printPDF } from '@/utils/util'; import { printPDF } from '@/utils/util';
import { CopyOutlined } from '@ant-design/icons'; import { CopyOutlined } from '@ant-design/icons';
import { ToastContainer, toast } from 'react-toastify';
import { import {
ActionType, ActionType,
PageContainer, PageContainer,
ProColumns, ProColumns,
ProTable, ProTable,
} from '@ant-design/pro-components'; } from '@ant-design/pro-components';
import { App, Button, Divider } from 'antd'; import { App, Button, Divider, Popconfirm } from 'antd';
import { useRef, useState } from 'react'; import { useRef, useState } from 'react';
const ListPage: React.FC = () => { const ListPage: React.FC = () => {
const actionRef = useRef<ActionType>(); const actionRef = useRef<ActionType>();
const { message } = App.useApp(); const { message } = App.useApp();
const [selectedRows, setSelectedRows] = useState([]); const [selectedRows, setSelectedRows] = useState([]);
const [isLoading, setIsLoading] = useState(false);
const columns: ProColumns<API.Service>[] = [ const columns: ProColumns<API.Service>[] = [
{ {
@ -38,17 +40,21 @@ const ListPage: React.FC = () => {
})); }));
}, },
}, },
{
title: '订单号',
dataIndex: 'externalOrderId',
},
{ {
title: '快递单号', title: '快递单号',
dataIndex: 'primary_tracking_number', dataIndex: 'return_tracking_number',
render(_, record) { render(_, record) {
return ( return (
<> <>
{record.unique_id} {record.return_tracking_number}
<CopyOutlined <CopyOutlined
onClick={async () => { onClick={async () => {
try { try {
await navigator.clipboard.writeText(record.unique_id); await navigator.clipboard.writeText(record.return_tracking_number);
message.success('复制成功!'); message.success('复制成功!');
} catch (err) { } catch (err) {
message.error('复制失败!'); message.error('复制失败!');
@ -82,24 +88,55 @@ const ListPage: React.FC = () => {
<> <>
<Button <Button
type="primary" type="primary"
disabled={isLoading}
onClick={async () => { onClick={async () => {
setIsLoading(true);
const { data } = await logisticscontrollerGetShipmentLabel(record.id); const { data } = await logisticscontrollerGetShipmentLabel(record.id);
const content = data.content; const content = data.content;
printPDF([content]); printPDF([content]);
setIsLoading(false);
}} }}
> >
Label Label
</Button> </Button>
<Divider type="vertical" /> {/* <Divider type="vertical" /> */}
<Button {/* <Button
type="primary" type="primary"
disabled={isLoading}
onClick={async () => { onClick={async () => {
setIsLoading(true);
const { data } = await logisticscontrollerDeleteShipment(record.id); const { data } = await logisticscontrollerDeleteShipment(record.id);
console.log('data', data);// todo 刷新页面 console.log('data', data);// todo 刷新页面
setIsLoading(false);
}} }}
> >
Cancel Cancel
</Button> </Button> */}
<Popconfirm
disabled={isLoading}
title="删除"
description="确认删除?"
onConfirm={async () => {
try {
setIsLoading(true);
const { success, message: errMsg } =
await logisticscontrollerDeleteShipment(record.id);
if (!success) {
throw new Error(errMsg);
}
setIsLoading(false);
actionRef.current?.reload();
} catch (error: any) {
setIsLoading(false);
message.error(error.message);
}
}}
>
<Button type="primary" danger>
Cancel
</Button>
</Popconfirm>
<ToastContainer />
</> </>
); );
}, },