index.jsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import React, { useMemo, useState } from 'react';
  2. import { Table, Popconfirm, Tag, Tooltip, Button } from '@douyinfe/semi-ui/';
  3. export default function Demo(props = {}) {
  4. const dataTotalSize = 46;
  5. const columns = useMemo(
  6. () => [
  7. {
  8. title: 'Name',
  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. align: 'left',
  23. render: (text, record) => (
  24. <Popconfirm title={record.descriptionZh} content={record.descriptionZh} position={'leftTop'}>
  25. <Tag color="green">Show Info</Tag>
  26. </Popconfirm>
  27. ),
  28. width: 350,
  29. },
  30. {
  31. align: 'center',
  32. dataIndex: 'op',
  33. title: '设置',
  34. render: (text, record) => (
  35. <>
  36. <Button icon={'user'} />
  37. <Popconfirm
  38. title={record.descriptionZh}
  39. content={record.descriptionZh}
  40. position="left"
  41. style={{ width: 330 }}
  42. >
  43. <Button type="danger" style={{ position: 'relative' }}>
  44. Show Info
  45. </Button>
  46. </Popconfirm>
  47. </>
  48. ),
  49. width: 150,
  50. },
  51. ],
  52. []
  53. );
  54. const data = useMemo(() => {
  55. const _data = [];
  56. for (let i = 0; i < dataTotalSize; i++) {
  57. let age = 40 + (Math.random() > 0.5 ? 1 : -1) * Math.ceil(i / 3);
  58. let name = `Edward King ${i}`;
  59. _data.push({
  60. key: '' + i,
  61. name,
  62. age,
  63. address: `London, Park Lane no. ${i} Lake Park`,
  64. description: `My name is ${name}, I am ${age} years old, living in New York No. ${i + 1} Lake Park.`,
  65. descriptionZh: `我的名字叫做 ${name},${age}岁,住在中关村大街${i + 1}号`,
  66. });
  67. }
  68. return _data;
  69. }, []);
  70. return <Table columns={columns} dataSource={data} />;
  71. }