import React, { PureComponent } from 'react'; import moment from 'moment'; import queryString from 'query-string'; import { Divider, Modal, Table, Badge } from 'antd'; import { statuses, Codes } from '../../../utils/config'; export default class TableList extends PureComponent { handleDeleteItem = (record) => { const { onDeleteItem } = this.props; Modal.confirm({ title: `您确定要删除该课件?`, okText: '确定', cancelText: '取消', onOk: () => onDeleteItem({id: record.id}), }); } render() { const { curStatus, onDeleteItem, onEditItem, location, pagination, ...tableProps } = this.props; const columns = [{ title: '课件编号', dataIndex: 'code', key: 'code', width: '28%', },{ title: '课件名称', dataIndex: 'name', key: 'name', width: '28%', },{ title: '状态', dataIndex: 'status', key: 'status', render: (text, record) => { const statusMap = {[Codes.CODE_NORMAL]: 'success', [Codes.CODE_DELETE]: 'error'}; return (); }, filters: Object.keys(statuses).map(key => ({ text: statuses[key], value: key })), filterMultiple: false, filteredValue: [curStatus], width: '12%', },{ title: '修改时间', dataIndex: 'gmtModified', key: 'gmtModified', render: (text, record) => (
{moment(text).format('YYYY-MM-DD HH:mm:ss')}
), width: '20%', },{ title: '操作', dataIndex: 'operation', key: 'operation', render: (text, record) => (
onEditItem(record)}>编辑 this.handleDeleteItem(record)}>删除
), width: '12%', }]; columns.map(item => { item.dataIndex == 'status' && !curStatus ? delete item.filteredValue : null; }); tableProps.pagination = !!pagination && { ...pagination, showSizeChanger: true, showQuickJumper: true, showTotal: total => `共 ${total} 条`}; return ( record.id} /> ); } }