GroupFile.tsx 2.5 KB

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