import React, { useContext } from 'react'; import classNames from 'classnames'; import PropTypes from 'prop-types'; import { Table, ConfigProvider } from 'antd'; import './index.less'; const BasicTable = (props) => { const { getPrefixCls } = useContext(ConfigProvider.ConfigContext); const prefixCls = getPrefixCls('basic-table'); const pagination = typeof props.pagination !== 'undefined' ? props.pagination : {}; const showTotal = (total) => { return `共 ${Math.ceil( total / (props.pagination ? props.pagination.pageSize || 10 : 10), )} 页 / 共 ${total} 条记录`; }; return ( <Table className={classNames(prefixCls)} scroll={{ y: 'calc(100% - 40px)' }} {...props} pagination={pagination ? { showTotal, ...pagination } : pagination} /> ); }; BasicTable.defaultProps = { columns: [], dataSource: [], }; BasicTable.propTypes = { columns: PropTypes.array, dataSource: PropTypes.array, }; export default BasicTable;