controlledSelection.jsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import React from 'react';
  2. import { Table } from '../../../../index';
  3. class App extends React.Component {
  4. constructor(props = {}) {
  5. super(props);
  6. this.state = {
  7. selectedRowKeys: [],
  8. };
  9. this.columns = [
  10. {
  11. title: '需求标题',
  12. dataIndex: 'featureTitle',
  13. },
  14. {
  15. title: '文档',
  16. dataIndex: 'doc',
  17. },
  18. {
  19. title: '需求状态',
  20. dataIndex: 'featureStatus',
  21. },
  22. {
  23. title: '优先级',
  24. dataIndex: 'priority',
  25. },
  26. {
  27. title: 'PM',
  28. dataIndex: 'pm',
  29. },
  30. {
  31. title: '产品线',
  32. dataIndex: 'productLine',
  33. },
  34. {
  35. title: '前端',
  36. dataIndex: 'fe',
  37. },
  38. {
  39. title: '服务端',
  40. dataIndex: 'server',
  41. },
  42. {
  43. title: '创建时间',
  44. dataIndex: 'createTime',
  45. },
  46. {
  47. title: '完成时间',
  48. dataIndex: 'completeTime',
  49. },
  50. ];
  51. this.data = Array.from(
  52. {
  53. length: 200,
  54. },
  55. (_, key) => {
  56. const rowRandom = Math.round(Math.random() * 1000);
  57. const prioritySet = ['P0', 'P1', 'P2'];
  58. const priority = prioritySet[Math.round(Math.random() * 2)];
  59. const featureStatusSet = ['待埋点', '开始', '待需详评', '测试', '已完成'];
  60. const featureStatus = featureStatusSet[Math.round(Math.random() * 4)];
  61. const doc = 'https://semi.design';
  62. const createTime = new Date().valueOf();
  63. return ({
  64. key,
  65. featureTitle: `需求-${rowRandom}`,
  66. doc,
  67. featureStatus,
  68. priority,
  69. pm: 'Li',
  70. productLine: 'Hotsoon',
  71. fe: '石嘉',
  72. server: 'ZhuYi',
  73. createTime,
  74. completeTime: createTime + rowRandom,
  75. });
  76. }
  77. );
  78. this.scroll = { y: 300, x: '100vw' };
  79. }
  80. render() {
  81. const { selectedRowKeys } = this.state;
  82. return (
  83. <Table
  84. rowSelection={{
  85. onChange: keys => {
  86. this.setState({ selectedRowKeys: keys });
  87. },
  88. selectedRowKeys,
  89. }}
  90. pagination={false}
  91. columns={this.columns}
  92. dataSource={this.data}
  93. />
  94. );
  95. }
  96. }
  97. export default App;