import React, { PureComponent } from 'react'; import moment from 'moment'; import { Table, Alert, Badge } from 'antd'; import styles from './index.less'; class StandardTable extends PureComponent { state = { selectedRowKeys: [], selectedRows: [], totalCallNo: 0, loading: false, }; componentWillReceiveProps(nextProps) { // clean state if (nextProps.selectedRows.length === 0) { this.setState({ selectedRows: [], selectedRowKeys: [], totalCallNo: 0, }); } } handleRowSelectChange = (selectedRowKeys, selectedRows) => { const totalCallNo = selectedRows.reduce((sum, val) => { return sum + parseFloat(val.callNo, 10); }, 0); if (this.props.onSelectRow) { this.props.onSelectRow(selectedRows); } this.setState({ selectedRowKeys, selectedRows, totalCallNo }); } handleTableChange = (pagination, filters, sorter) => { this.props.onChange(pagination, filters, sorter); } cleanSelectedKeys = () => { this.handleRowSelectChange([], []); } render() { const { selectedRowKeys, totalCallNo } = this.state; const { data: { list, pagination }, loading } = this.props; const status = ['关闭', '运行中']; const columns = [ { title: '规则编号', dataIndex: 'no', }, { title: '描述', dataIndex: 'description', }, { title: '服务调用次数', dataIndex: 'callNo', sorter: true, render: val => (

{val} 万

), }, { title: '状态', dataIndex: 'status', filters: [ { text: status[0], value: 0, }, { text: status[1], value: 1, }, ], render(val) { if (val === 0) { return ; } else { return ; } }, }, { title: '更新时间', dataIndex: 'updatedAt', sorter: true, render: val => {moment(val).format('YYYY-MM-DD HH:mm:ss')}, }, { title: '操作', render: () => (

配置 订阅警报

), }, ]; const paginationProps = { showSizeChanger: true, showQuickJumper: true, ...pagination, }; const rowSelection = { selectedRowKeys, onChange: this.handleRowSelectChange, }; return (
已选择 {selectedRowKeys.length} 项   服务调用总计 {totalCallNo}清空

)} type="info" showIcon />
record.key} rowSelection={rowSelection} dataSource={list} columns={columns} pagination={paginationProps} onChange={this.handleTableChange} /> ); } } export default StandardTable;