加上分页

This commit is contained in:
mmc
2026-04-29 10:00:24 +08:00
parent dcee7c601f
commit e5360f49b6
8 changed files with 166 additions and 43 deletions

View File

@@ -32,18 +32,43 @@ export default function StationManage() {
const [mapVisible, setMapVisible] = useState(false);
const [messageApi, contextHolder] = message.useMessage();
// ====================== 获取场站列表 ======================
// 分页状态
const [pagination, setPagination] = useState({
pageNum: 1,
pageSize: 10,
total: 0
});
// ====================== 获取场站列表(分页) ======================
const getStationData = () => {
getStationList().then(res => {
const params = {
pageNum: pagination.pageNum,
pageSize: pagination.pageSize
};
getStationList(params).then(res => {
if (res.code === 200) {
setStationList(res.rows || []);
setPagination({
...pagination,
total: res.total || res.rows?.length || 0
});
}
});
};
// 切换分页
const handleTableChange = (newPagination) => {
setPagination({
...pagination,
pageNum: newPagination.current,
pageSize: newPagination.pageSize
});
};
useEffect(() => {
getStationData();
}, []);
}, [pagination.pageNum, pagination.pageSize]);
// ====================== 新增 / 编辑 场站 ======================
const handleAdd = () => {
@@ -183,7 +208,14 @@ export default function StationManage() {
rowKey="id"
columns={columns}
dataSource={stationList}
pagination={true}
pagination={{
current: pagination.pageNum,
pageSize: pagination.pageSize,
total: pagination.total,
showSizeChanger: true,
showTotal: (total) => `共 ${total} 条`
}}
onChange={handleTableChange}
bordered
size="middle"
/>