import React, { Fragment } from 'react'; import { Spin, Popover, Checkbox, Pagination } from 'antd'; import cx from 'classnames'; import styles from './index.less'; import { ArrowUpOutlined, ArrowDownOutlined, CheckSquareOutlined } from '@ant-design/icons'; export default ({ pagination = true, loading, columns, dataSource, rowKey, page, total, rowSelection, showRowSelection, minHeight = 200, onRowClick, expandable = function () {}, onPageChange, onSortChange, onFilterChange, classname = '', }) => { return (
{columns.map((col) => { return ( ); })} {loading && dataSource.length === 0 && ( )} {dataSource.map((item, index) => { return ( onRowClick && onRowClick(item)} className={cx({ [styles.canClick]: !!onRowClick })} > {columns.map((col) => { return ( ); })} {expandable(item)} ); })}
{col.sorter && ( { onSortChange(col, col.sortered === 'DESC' ? 'ASC' : 'DESC'); }} > {col.title} {/* */} {col.sortered === 'DESC' ? ( ) : ( )} )} {col.filters && ( {col.filters.map((f) => { return (
{ let newList = [...col.filteredValue]; if (col.filteredValue.includes(f.value)) { if (col.single) { newList = []; } else { newList = col.filteredValue.filter( (item) => item !== f.value, ); } } else { if (col.single) { newList = [f.value]; } else { newList.push(f.value); } } onFilterChange(col.dataIndex, newList); }} > {f.label}
); })} } > {col.filteredValue.length > 0 && ( )} {col.filteredValue.length == 0 && ( )} {col.title}
)} {!col.sorter && !col.filters && {col.title}}
{col.render && col.render(item[col.dataIndex], item, index)} {!col.render && (item[col.dataIndex] === undefined ? '-' : item[col.dataIndex])}
{pagination && (
{ if (t === 'prev') { return 上一页; } if (t === 'next') { return 下一页; } return o; }} onChange={(current, pageSize) => { window.scrollTo(0, 0); onPageChange({ pageNum: current, pageSize, }); }} />
)}
); };