import React, { Component } from 'react'; import './index.less'; import Assets from '@src/components/Assets'; import CheckboxItem from '../CheckboxItem'; import Icon from '../Icon'; import UserPagination from '../UserPagination'; export default class UserTable extends Component { onSort(key, value) { const { sortMap = {}, onSort } = this.props; sortMap[key] = value; if (onSort) onSort(sortMap); } onSelect(checked, key) { const { selectList = [] } = this.props; if (checked) { selectList.push(key); } else { selectList.splice(selectList.indexOf(key), 1); } if (this.props.onSelect) this.props.onSelect(selectList); } render() { const { columns = [], rowKey = 'key', data = [], select, selectList = [], current, total, size = 'basic', even = 'even', theme = 'defalut', border = true, header = true, sortMap = {}, maxHeight, onChange, } = this.props; return (
{header && ( {columns.map((item, i) => { return ( ); })} )} {data.map(row => { const checked = selectList.indexOf(row[rowKey]) >= 0; return ( {columns.map((item, i) => { return ( ); })} ); })}
{item.title} {item.fixSort && (sortMap[item.key] ? ( this.onSort(item.key, '')} /> ) : ( this.onSort(item.key, 'desc')} /> ))} {item.sort && (sortMap[item.key] ? ( this.onSort(item.key, sortMap[item.key] === 'asc' ? 'desc' : '')} /> ) : ( this.onSort(item.key, 'asc')} /> ))}
{i === 0 && select && ( this.onSelect(value, row[rowKey])} /> )} {item.render ? item.render(row[item.key], row) : row[item.key]}
{data.length === 0 &&
暂无数据
} {total && data.length > 0 && }
); } }