import React, { PureComponent } from "react";
import CustomTable from "../../components/customTable";

class CustomPaginationTable extends PureComponent {
  shouldComponentUpdate(nextProps, nextState, nextContext) {
    return !(nextProps.columnIndex && this.props.columnIndex !== nextProps.columnIndex);
  }

  render() {
    return (
      <CustomTable
        {...this.props}
        pagination={{
          onChange: value => {
            this.props.onPageChange(value);
          },
          total: this.props.total,
          showTotal: total => `共 ${total} 条`,
          current: this.props.current,
          showSizeChanger: true,
          pageSizeOptions: ["10", "20", "50", "100"],
          showQuickJumper: true,
          pageSize: this.props.pageSize,
          onShowSizeChange: (current, pageSize) => {
            this.props.onShowSizeChange &&
            this.props.onShowSizeChange(current, pageSize);
          }
        }}
      />
    );
  }
}

export default CustomPaginationTable;
