feat: 合并代码,增加分页默认值
This commit is contained in:
@@ -69,6 +69,9 @@ export interface ProTableProps<TData, TValue> {
|
||||
targetId: string | number | null,
|
||||
items: TData[],
|
||||
) => Promise<TData[]>;
|
||||
initialPagination: {
|
||||
initialPageSize: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ProTableActions {
|
||||
@@ -89,6 +92,7 @@ export function ProTable<
|
||||
texts,
|
||||
empty,
|
||||
onSort,
|
||||
initialPagination,
|
||||
}: ProTableProps<TData, TValue>) {
|
||||
const [sorting, setSorting] = useState<SortingState>([]);
|
||||
const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([]);
|
||||
@@ -98,7 +102,7 @@ export function ProTable<
|
||||
const [rowCount, setRowCount] = useState<number>(0);
|
||||
const [pagination, setPagination] = useState({
|
||||
pageIndex: 0,
|
||||
pageSize: 10,
|
||||
pageSize: initialPagination?.initialPageSize ?? 10,
|
||||
});
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
@@ -132,9 +136,9 @@ export function ProTable<
|
||||
header: texts?.actions,
|
||||
cell: ({ row }) => (
|
||||
<div className='flex items-center justify-end gap-2'>
|
||||
{actions
|
||||
?.render?.(row.original)
|
||||
.map((item, index) => <Fragment key={index}>{item}</Fragment>)}
|
||||
{actions?.render?.(row.original).map((item, index) => (
|
||||
<Fragment key={index}>{item}</Fragment>
|
||||
))}
|
||||
</div>
|
||||
),
|
||||
enableSorting: false,
|
||||
@@ -197,6 +201,7 @@ export function ProTable<
|
||||
useImperativeHandle(action, () => ({
|
||||
refresh: fetchData,
|
||||
reset,
|
||||
setPagination,
|
||||
}));
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user