Recently.tsx 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. import React, { useEffect, useState } from "react";
  2. import { ProTable, PageContainer } from "@ant-design/pro-components";
  3. import {
  4. Col,
  5. Row,
  6. Button,
  7. Input,
  8. Breadcrumb,
  9. Empty,
  10. Pagination,
  11. Dropdown,
  12. Modal,
  13. Tree,
  14. } from "antd";
  15. import { useRequest } from "umi";
  16. import { AppstoreOutlined, MenuOutlined } from "@ant-design/icons";
  17. import { RecentFile } from "@/api/systemDesigner";
  18. import ProjectCard from "./ProjectCard";
  19. import { graphOptions } from "./data";
  20. import { GraphType } from "@/enum";
  21. export default function Recently(
  22. {
  23. updateKey,
  24. }: {
  25. updateKey: number;
  26. }
  27. ) {
  28. const [display, setDisplay] = useState("card");
  29. const [dataSource, setDataSource] = useState<any[]>([]);
  30. const [total, setTotal] = useState(0);
  31. const [searchName, setSearchName] = useState("");
  32. const [currentPage, setCurrentPage] = useState(1);
  33. const [open, setOpen] = useState(false);
  34. const { loading, run, refresh } = useRequest(RecentFile, {
  35. onSuccess: (res) => {
  36. const list = res?.result || []
  37. setDataSource(list);
  38. setTotal(list.length);
  39. },
  40. });
  41. useEffect(() => {
  42. run();
  43. }, [updateKey]);
  44. const FolderIcon = function () {
  45. return (
  46. <svg className="icon" aria-hidden="true">
  47. <use xlinkHref="#icon-weibiaoti-_huabanfuben"></use>
  48. </svg>
  49. );
  50. };
  51. const folderTreeData = [
  52. {
  53. key: "1",
  54. title: (
  55. <span>
  56. 我的文件<span className="text-12px color-#999">(当前)</span>
  57. </span>
  58. ),
  59. icon: <FolderIcon />,
  60. children: [
  61. {
  62. key: "1-1",
  63. title: "文件夹1",
  64. icon: <FolderIcon />,
  65. },
  66. ],
  67. },
  68. ];
  69. // 搜索文件
  70. const handleSearch = () => {
  71. setCurrentPage(1);
  72. run();
  73. };
  74. // 搜索图形类型
  75. const setSearchGraphType = (type: GraphType) => {};
  76. return (
  77. <>
  78. <PageContainer
  79. extra={[
  80. <Button
  81. key="2"
  82. onClick={() => {
  83. setDisplay(display === "card" ? "list" : "card");
  84. }}
  85. icon={display === "card" ? <MenuOutlined /> : <AppstoreOutlined />}
  86. />,
  87. ]}
  88. title={''}
  89. footer={[]}
  90. >
  91. <Breadcrumb
  92. items={[
  93. {
  94. title: "最近",
  95. },
  96. ]}
  97. ></Breadcrumb>
  98. {display === "card" ? (
  99. <>
  100. <div className="text-12px color-#999 my-8px">文件</div>
  101. <Row gutter={[8, 16]}>
  102. {dataSource.map((item, index) => {
  103. return (
  104. <Col xs={12} sm={8} md={6} lg={6} xl={6} xxl={6} key={index}>
  105. <ProjectCard
  106. record={item}
  107. onFresh={refresh}
  108. onDelete={refresh}
  109. onChangeLocation={() => {}}
  110. />
  111. </Col>
  112. );
  113. })}
  114. </Row>
  115. {dataSource.length == 0 ? <Empty description="暂无数据" /> : null}
  116. </>
  117. ) : (
  118. <ProTable
  119. loading={loading}
  120. columns={[
  121. {
  122. title: "名称",
  123. dataIndex: "name",
  124. },
  125. {
  126. title: "类型",
  127. dataIndex: "type",
  128. },
  129. {
  130. title: "修改时间",
  131. dataIndex: "updatedTime",
  132. sorter: (a, b) => a.updateTime - b.updateTime,
  133. },
  134. ]}
  135. dataSource={dataSource}
  136. rowKey={"id"}
  137. search={false}
  138. pagination={{
  139. total: total,
  140. pageSize: 10,
  141. current: currentPage,
  142. pageSizeOptions: ["12", "24", "36"],
  143. onChange: (page, pageSize) => {
  144. setCurrentPage(page);
  145. },
  146. }}
  147. />
  148. )}
  149. </PageContainer>
  150. <Modal
  151. title="移动/复制到"
  152. width={440}
  153. open={open}
  154. onCancel={() => setOpen(false)}
  155. centered
  156. footer={
  157. <div>
  158. <Button className="m-r-8px" onClick={() => setOpen(false)}>
  159. 取消
  160. </Button>
  161. <Button
  162. className="m-r-8px"
  163. type="primary"
  164. onClick={() => setOpen(false)}
  165. >
  166. 移动
  167. </Button>
  168. <Button type="primary" onClick={() => setOpen(false)}>
  169. 复制
  170. </Button>
  171. </div>
  172. }
  173. >
  174. <div className="min-h-300px">
  175. <Tree treeData={folderTreeData} showIcon blockNode />
  176. </div>
  177. </Modal>
  178. </>
  179. );
  180. }