index.jsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import React, { useEffect, useState } from 'react';
  2. import { Tabs, Tooltip, Tag, Table } from '@douyinfe/semi-ui';
  3. const { TabPane } = Tabs;
  4. function AsyncTable(props = {}) {
  5. const dataTotalSize = 46;
  6. const [columns, setColumns] = useState([
  7. {
  8. title: <span>Name</span>,
  9. dataIndex: 'name',
  10. width: 150,
  11. },
  12. {
  13. title: 'Age',
  14. dataIndex: 'age',
  15. width: 150,
  16. },
  17. {
  18. title: 'Address',
  19. dataIndex: 'address',
  20. },
  21. {
  22. render: (text, record) => (
  23. <Tooltip content={record.description}>
  24. <Tag color="green">Show Info</Tag>
  25. </Tooltip>
  26. ),
  27. width: 150,
  28. },
  29. ]);
  30. const [data, setData] = useState([]);
  31. const [loading, setLoading] = useState(true);
  32. useEffect(() => {
  33. setLoading(true);
  34. setTimeout(() => {
  35. const _data = [];
  36. for (let i = 0; i < dataTotalSize; i++) {
  37. let age = (i * 1000) % 149 ;
  38. let name = `Edward King ${i}`;
  39. _data.push({
  40. key: '' + i,
  41. name,
  42. age,
  43. address: `London, Park Lane no. ${i} Lake Park`,
  44. description: `My name is ${name}, I am ${age} years old, living in New York No. ${i +
  45. 1} Lake Park.`,
  46. });
  47. }
  48. setData(_data);
  49. setLoading(false);
  50. }, 1000);
  51. }, []);
  52. return <Table columns={columns} dataSource={data} loading={loading} />;
  53. }
  54. function TabsTable(props = {}) {
  55. return (
  56. <Tabs>
  57. {Array(10)
  58. .fill(1)
  59. .map((ee, e) => (
  60. <TabPane itemKey={e + ''} tab={e} key={e}>
  61. <Table dataSource={[]}>
  62. <Table.Column title={<span>1</span>} />
  63. </Table>
  64. </TabPane>
  65. ))}
  66. </Tabs>
  67. );
  68. }
  69. export default TabsTable;