import './index.less';
import {Pagination as TPagination} from 'tdesign-react';
import {Component} from "react";
import {isMobile} from '@/js/utils/tool'

class Pagination extends Component<any, any> {
    constructor(props) {
        super(props);
    }

    pageChange = ({current, pageSize}: any) => {
        // 通知父组件
        this.props.onChange(current);
    }

    render() {
        const props = this.props;
        return (
            <div className={['reset-t-pagination-box', isMobile() ? 'reset-t-pagination__mobile' : ''].join(' ')}>
                <TPagination
                    foldedMaxPageBtn={2}
                    maxPageBtn={3}
                    className={['reset-t-pagination'].join(' ')}
                    defaultCurrent={props.pageNum}
                    defaultPageSize={props.pageSize}
                    pageSizeOptions={[]}
                    pageEllipsisMode="mid"
                    showFirstAndLastPageBtn={false}
                    showJumper={false}
                    showPageNumber
                    showPreviousAndNextBtn
                    size="medium"
                    theme="default"
                    total={props.total}
                    totalContent
                    onChange={this.pageChange}
                />
            </div>

        )
    }
}

export default Pagination;

