67 lines
1.8 KiB
TypeScript
67 lines
1.8 KiB
TypeScript
|
|
import { ReactComponentProps } from '../../types/Page';
|
|
import { ED } from '../../types/AbstractComponent';
|
|
|
|
export default OakComponent({
|
|
entity() {
|
|
return this.props.entity!;
|
|
},
|
|
properties: {
|
|
entity: '',
|
|
},
|
|
isList: true,
|
|
lifetimes: {
|
|
ready() {
|
|
const { oakPagination } = this.state;
|
|
const { total } = oakPagination || {};
|
|
if (total) {
|
|
this.setState({ newTotal: total });
|
|
}
|
|
},
|
|
},
|
|
listeners: {
|
|
oakPagination(prev, next) {
|
|
if (
|
|
!prev.oakPagination &&
|
|
prev.oakPagination !== next.oakPagination
|
|
) {
|
|
const { total, pageSize, currentPage, more } = next.oakPagination || {};
|
|
if (total) {
|
|
this.setState({ newTotal: total });
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
async setTotal() {
|
|
const { oakPagination, newTotal } = this.state;
|
|
const { pageSize, total, currentPage, more } = oakPagination || {};
|
|
if (total && pageSize) {
|
|
if (Math.ceil(newTotal / pageSize) === currentPage) {
|
|
console.log(newTotal + pageSize);
|
|
this.setState({ newTotal: newTotal + pageSize });
|
|
}
|
|
}
|
|
},
|
|
},
|
|
}) as <ED2 extends ED, T2 extends keyof ED2>(
|
|
props: ReactComponentProps<
|
|
ED2,
|
|
T2,
|
|
false,
|
|
{
|
|
entity: T2;
|
|
style?: React.CSSProperties;
|
|
className?: string;
|
|
showQuickJumper?: boolean;
|
|
size?: 'default' | 'small';
|
|
showSizeChanger?: boolean;
|
|
showTotal?: (
|
|
total: number,
|
|
range: [number, number]
|
|
) => React.ReactNode;
|
|
}
|
|
>
|
|
) => React.ReactElement;
|
|
|