GroupFile.tsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import { useIntl } from "react-intl";
  2. import { useState } from 'react';
  3. import { ProList } from '@ant-design/pro-components';
  4. import { Space, Tag, Button, Layout } from 'antd';
  5. const { Content } = Layout;
  6. const defaultData = [
  7. {
  8. id: '1',
  9. name: '庄春江工作站',
  10. tag:[{title:"可编辑",color:"success"}],
  11. image:
  12. 'https://gw.alipayobjects.com/zos/antfincdn/efFD%24IOql2/weixintupian_20170331104822.jpg',
  13. description: 'IAPT|2022-1-3',
  14. },
  15. {
  16. id: '2',
  17. name: '元亨寺·CBETA',
  18. tag:[{title:"可编辑",color:"success"}],
  19. image:
  20. 'https://gw.alipayobjects.com/zos/antfincdn/efFD%24IOql2/weixintupian_20170331104822.jpg',
  21. description: '我是一条测试的描述',
  22. },
  23. {
  24. id: '3',
  25. name: '叶均居士',
  26. tag:[{title:"只读",color:"default"}],
  27. image:
  28. 'https://gw.alipayobjects.com/zos/antfincdn/efFD%24IOql2/weixintupian_20170331104822.jpg',
  29. description: '我是一条测试的描述',
  30. },
  31. {
  32. id: '4',
  33. name: '玛欣德尊者',
  34. tag:[{title:"只读",color:"default"}],
  35. image:
  36. 'https://gw.alipayobjects.com/zos/antfincdn/efFD%24IOql2/weixintupian_20170331104822.jpg',
  37. description: '我是一条测试的描述',
  38. },
  39. ];
  40. type DataItem = typeof defaultData[number];
  41. type IWidgetGroupFile ={
  42. groupid?: string
  43. }
  44. const Widget = ({groupid = ''}: IWidgetGroupFile) => {
  45. const intl = useIntl();//i18n
  46. const [dataSource, setDataSource] = useState<DataItem[]>(defaultData);
  47. return (
  48. <Content>
  49. <Space>{groupid}</Space>
  50. <ProList<DataItem>
  51. rowKey="id"
  52. headerTitle={intl.formatMessage({ id: "group.files" })}
  53. dataSource={dataSource}
  54. showActions="hover"
  55. onDataSourceChange={setDataSource}
  56. metas={{
  57. title: {
  58. dataIndex: 'name',
  59. },
  60. avatar: {
  61. dataIndex: 'image',
  62. editable: false,
  63. },
  64. description: {
  65. dataIndex: 'description',
  66. },
  67. content: {
  68. dataIndex: 'content',
  69. editable: false,
  70. },
  71. subTitle: {
  72. render: (text, row, index, action) => {
  73. const showtag = row.tag.map((item,key) => {
  74. return <Tag color={item.color}>{item.title}</Tag>
  75. });
  76. return (
  77. <Space size={0}>
  78. {showtag}
  79. </Space>
  80. );
  81. },
  82. },
  83. actions: {
  84. render: (text, row, index, action) => [
  85. <Button
  86. onClick={() => {
  87. action?.startEditable(row.id);
  88. }}
  89. key="link"
  90. >
  91. 删除
  92. </Button>,
  93. ],
  94. },
  95. }}
  96. pagination={{
  97. showQuickJumper: true,
  98. showSizeChanger: true,
  99. }}
  100. />
  101. </Content>
  102. );
  103. };
  104. export default Widget;