complex.jsx 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /* eslint-disable max-lines-per-function */
  2. import React from 'react';
  3. import { Table, Typography, Tag, Popover } from '../../../../index';
  4. const { Text } = Typography;
  5. const src = 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/bag.jpeg';
  6. class App extends React.Component {
  7. constructor(props) {
  8. super(props);
  9. this.columns = [
  10. {
  11. title: '需求标题',
  12. dataIndex: 'featureTitle',
  13. render: (text, record, index) => <a rel="noreferrer" href="https://semi.design/zh-CN/show/table" target="_blank">{text}</a>,
  14. },
  15. {
  16. title: '文档',
  17. dataIndex: 'doc',
  18. width: 150,
  19. render: (text, record, index) => (
  20. <Text link ellipsis={{ showTooltip: true }} style={{ width: 150, breakWord: 'break-all' }}>
  21. {text}
  22. </Text>
  23. ),
  24. },
  25. {
  26. title: '需求状态',
  27. dataIndex: 'featureStatus',
  28. width: 100,
  29. render: (text, record, index) => (
  30. <Tag style={{ width: 50 }}>
  31. <Text ellipsis={{ showTooltip: true }} style={{ width: 50 }}>
  32. {text}
  33. </Text>
  34. </Tag>
  35. ),
  36. },
  37. {
  38. title: '优先级',
  39. dataIndex: 'priority',
  40. render: (text, record, index) => (
  41. <Tag>
  42. {text}
  43. </Tag>
  44. ),
  45. },
  46. {
  47. title: 'PM',
  48. dataIndex: 'pm',
  49. render: (text, record, index) => (
  50. <Popover
  51. showArrow
  52. content={(
  53. <article>
  54. Hi ByteDancer, this is a popover.
  55. <br /> We have 2 lines.
  56. </article>
  57. )}
  58. key={index}
  59. >
  60. <Tag avatarSrc={src} avatarShape="circle">{text}</Tag>
  61. </Popover>
  62. ),
  63. },
  64. {
  65. title: '产品线',
  66. dataIndex: 'productLine',
  67. render: (text, record, index) => (
  68. <Tag>
  69. <Text ellipsis={{ showTooltip: true }} style={{ width: 50 }}>
  70. {text}
  71. </Text>
  72. </Tag>
  73. ),
  74. },
  75. {
  76. title: '前端',
  77. dataIndex: 'fe',
  78. render: (text, record, index) => (
  79. <Popover
  80. showArrow
  81. content={(
  82. <article>
  83. Hi ByteDancer, this is a popover.
  84. <br /> We have 2 lines.
  85. </article>
  86. )}
  87. key={index}
  88. >
  89. <Tag color="blue">{text}</Tag>
  90. </Popover>
  91. ),
  92. },
  93. {
  94. title: '服务端',
  95. dataIndex: 'server',
  96. render: (text, record, index) => (
  97. <Popover
  98. showArrow
  99. content={(
  100. <article>
  101. Hi ByteDancer, this is a popover.
  102. <br /> We have 2 lines.
  103. </article>
  104. )}
  105. key={index}
  106. >
  107. <Tag avatarSrc={src}>{text}</Tag>
  108. </Popover>
  109. ),
  110. },
  111. {
  112. title: '创建时间',
  113. dataIndex: 'createTime',
  114. render: (text, record, index) => (
  115. <Text
  116. ellipsis={{ showTooltip: true }}
  117. style={{ width: 50 }}
  118. onClick={() => {
  119. console.log('click createTime', record);
  120. }}
  121. >
  122. {text}
  123. </Text>
  124. ),
  125. },
  126. {
  127. title: '完成时间',
  128. dataIndex: 'completeTime',
  129. render: (text, record, index) => (
  130. <Text
  131. ellipsis={{ showTooltip: true }}
  132. style={{ width: 50 }}
  133. onClick={() => {
  134. console.log('click completeTime', record);
  135. }}
  136. >
  137. {text}
  138. </Text>
  139. ),
  140. },
  141. ];
  142. this.data = Array.from(
  143. {
  144. length: 200,
  145. },
  146. (_, key) => {
  147. const rowRandom = Math.round(Math.random() * 1000);
  148. const prioritySet = ['P0', 'P1', 'P2'];
  149. const priority = prioritySet[Math.round(Math.random() * 2)];
  150. const featureStatusSet = ['待埋点', '开始', '待需详评', '测试', '已完成'];
  151. const featureStatus = featureStatusSet[Math.round(Math.random() * 4)];
  152. const doc = 'https://semi.design';
  153. const createTime = new Date().valueOf();
  154. return ({
  155. key,
  156. featureTitle: `需求-${rowRandom}`,
  157. doc,
  158. featureStatus,
  159. priority,
  160. pm: 'Li',
  161. productLine: 'Hotsoon',
  162. fe: '石嘉',
  163. server: 'ZhuYi',
  164. createTime,
  165. completeTime: createTime + rowRandom,
  166. });
  167. }
  168. );
  169. this.scroll = { y: 500 };
  170. }
  171. render() {
  172. return (
  173. <>
  174. <Table
  175. title={`数据条数:${this.data.length}`}
  176. rowSelection
  177. columns={this.columns}
  178. dataSource={this.data}
  179. pagination={false}
  180. scroll={this.scroll}
  181. />
  182. </>
  183. );
  184. }
  185. }
  186. export default App;