index.jsx 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. import React, { useState, useMemo } from 'react';
  2. import { Modal, Button, Table } from '@douyinfe/semi-ui';
  3. const types = ['Array', 'String', 'Number', 'Object'];
  4. function ModalTable() {
  5. const dataTotalSize = 46;
  6. const [modalShow, setModalShow] = useState(false);
  7. const [selectedRowKeys, setSelectedRowKeys] = useState([]);
  8. const columns = [
  9. {
  10. title: '名称',
  11. key: 'name',
  12. width: 150,
  13. // render: (text, record) => <span style={{ wordWrap: 'break-word', wordBreak: 'break-word' }}>{text}</span>,
  14. dataIndex: 'name',
  15. fixed: 'left',
  16. },
  17. {
  18. title: 'id',
  19. key: 'id',
  20. width: 150,
  21. // render: (text, record) => <span style={{ wordWrap: 'break-word', wordBreak: 'break-word' }}>{text}</span>,
  22. dataIndex: 'id',
  23. },
  24. {
  25. title: '描述',
  26. key: 'description',
  27. // width: 150,
  28. dataIndex: 'description',
  29. },
  30. {
  31. title: '类型',
  32. key: 'type',
  33. width: 150,
  34. dataIndex: 'type',
  35. fixed: 'right',
  36. },
  37. ];
  38. // const data = [];
  39. // for (let i = 0; i < dataTotalSize; i++) {
  40. // let age = (i * 1000) % 149 ;
  41. // let name = `Edward King ${i}`;
  42. // data.push({
  43. // key: '' + new Date().toString(16),
  44. // name,
  45. // age,
  46. // type: types[i % types.length],
  47. // address: `London, Park Lane no. ${i} Lake Park`,
  48. // description: `My name is ${name}, I am ${age} years old, living in New York No. ${i + 1} Lake Park.`,
  49. // });
  50. // }
  51. const data = [
  52. {
  53. Chinese_description: '认证类型',
  54. Chinese_name: '认证类型',
  55. _tags: null,
  56. default: '-1',
  57. description: '认证类型',
  58. id: 594,
  59. name: 'cert_type',
  60. noaction: 0,
  61. operation: 0,
  62. property_id: 523,
  63. ref_entity_id: 0,
  64. ref_property_id: 0,
  65. ref_type: 0,
  66. type: 'Integer',
  67. },
  68. {
  69. Chinese_description: '粉丝数',
  70. Chinese_name: '粉丝数',
  71. _tags: null,
  72. default: '0',
  73. description: '粉丝数',
  74. id: 595,
  75. name: 'fans_count',
  76. noaction: 0,
  77. operation: 1,
  78. property_id: 524,
  79. ref_entity_id: 0,
  80. ref_property_id: 0,
  81. ref_type: 0,
  82. type: 'Integer',
  83. },
  84. {
  85. Chinese_description: '用户标签',
  86. Chinese_name: '用户标签',
  87. _tags: null,
  88. default: '[]',
  89. description: '用户标签',
  90. id: 596,
  91. items: {
  92. Chinese_description: '用户标签',
  93. Chinese_name: '用户标签',
  94. _tags: null,
  95. default: null,
  96. description: '用户标签',
  97. id: 597,
  98. noaction: 0,
  99. operation: 0,
  100. property_id: 0,
  101. ref_entity_id: 0,
  102. ref_property_id: 0,
  103. ref_type: 0,
  104. type: 'Integer',
  105. },
  106. name: 'hot_user_label',
  107. noaction: 0,
  108. operation: 1,
  109. property_id: 525,
  110. ref_entity_id: 0,
  111. ref_property_id: 0,
  112. ref_type: 0,
  113. type: 'Array',
  114. },
  115. {
  116. Chinese_description: '用户库标签',
  117. Chinese_name: ' 用户库标签',
  118. _tags: null,
  119. default: '0',
  120. description: '用户库标签',
  121. id: 598,
  122. name: 'hot_user_level',
  123. noaction: 0,
  124. operation: 1,
  125. property_id: 526,
  126. ref_entity_id: 0,
  127. ref_property_id: 0,
  128. ref_type: 0,
  129. type: 'Integer',
  130. },
  131. {
  132. Chinese_description: '特效师',
  133. Chinese_name: '特效师',
  134. _tags: null,
  135. default: null,
  136. description: '特效师',
  137. id: 599,
  138. name: 'is_sticker_designer',
  139. noaction: 0,
  140. operation: 1,
  141. property_id: 527,
  142. ref_entity_id: 0,
  143. ref_property_id: 0,
  144. ref_type: 0,
  145. type: 'Boolean',
  146. },
  147. {
  148. Chinese_description: '机构认证细分',
  149. Chinese_name: '机构认证细分',
  150. _tags: null,
  151. default: '-1',
  152. description: '机构认证细分',
  153. id: 600,
  154. name: 'org_type',
  155. noaction: 0,
  156. operation: 1,
  157. property_id: 528,
  158. ref_entity_id: 0,
  159. ref_property_id: 0,
  160. ref_type: 0,
  161. type: 'Integer',
  162. },
  163. {
  164. Chinese_description: '用户名',
  165. Chinese_name: '用户名',
  166. _tags: null,
  167. default: null,
  168. description: '用户名',
  169. id: 602,
  170. name: 'user_name',
  171. noaction: 0,
  172. operation: 1,
  173. property_id: 529,
  174. ref_entity_id: 0,
  175. ref_property_id: 0,
  176. ref_type: 0,
  177. type: 'String',
  178. },
  179. {
  180. Chinese_description: '用户注册省份',
  181. Chinese_name: '用户注册省份',
  182. _tags: null,
  183. default: '',
  184. description: '用户注册省份',
  185. id: 603,
  186. name: 'user_register_province',
  187. noaction: 0,
  188. operation: 1,
  189. property_id: 530,
  190. ref_entity_id: 0,
  191. ref_property_id: 0,
  192. ref_type: 0,
  193. type: 'String',
  194. },
  195. ];
  196. const rowSelection = useMemo(
  197. () => ({
  198. selectedRowKeys,
  199. onChange: (selectedRowKeys, selectedRows) => {
  200. // console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
  201. setSelectedRowKeys([...selectedRowKeys]);
  202. },
  203. getCheckboxProps: record => ({
  204. disabled: record.name === 'Disabled User', // Column configuration not to be checked
  205. name: record.name,
  206. }),
  207. }),
  208. [selectedRowKeys]
  209. );
  210. return (
  211. <div>
  212. <Button onClick={() => setModalShow(true)}>显示浮层</Button>
  213. <Modal visible={modalShow} onCancel={() => setModalShow(false)} width={800}>
  214. <Table dataSource={data} columns={columns} scroll={{ y: 240, x: 1000 }} rowKey={'name'} />
  215. </Modal>
  216. <Table dataSource={data} columns={columns} scroll={{ y: 480 }} rowKey={'name'} />
  217. </div>
  218. );
  219. }
  220. export default ModalTable;