table.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import React, { PureComponent } from 'react';
  2. import moment from 'moment';
  3. import queryString from 'query-string';
  4. import { Modal, Table, Badge } from 'antd';
  5. import { statuses, productType, Codes } from '../../../utils/config';
  6. export default class TableList extends PureComponent {
  7. render() {
  8. const { onViewItem, pagination, ...tableProps } = this.props;
  9. const columns = [{
  10. title: '产品编号',
  11. dataIndex: 'code',
  12. key: 'code',
  13. width: '30%',
  14. }, {
  15. title: '产品名称',
  16. dataIndex: 'name',
  17. key: 'name',
  18. width: '35%',
  19. }, {
  20. title: '产品类型',
  21. dataIndex: 'type',
  22. key: 'type',
  23. render: text => productType[text],
  24. width: '25%',
  25. }, {
  26. title: '产品状态',
  27. dataIndex: 'status',
  28. key: 'status',
  29. render: (text, record) => {
  30. const statusMap = {[Codes.CODE_NORMAL]: 'success', [Codes.CODE_DELETE]: 'error'};
  31. return (<Badge status={statusMap[record.status]} text={statuses[record.status]} />);
  32. },
  33. width: '15%',
  34. // }, {
  35. // title: '操作',
  36. // dataIndex: 'operation',
  37. // key: 'operation',
  38. // render: (text, record) => <a onClick={() => onViewItem(record)}>查看</a>,
  39. // width: '5%',
  40. }];
  41. // 配置分页
  42. tableProps.pagination = !!pagination && { ...pagination, showSizeChanger: true, showQuickJumper: true, showTotal: total => `共 ${total} 条`};
  43. return (
  44. <Table
  45. simple
  46. bordered
  47. { ...tableProps }
  48. columns={columns}
  49. rowKey={record => record.id}
  50. />
  51. );
  52. }
  53. }