index.jsx 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import { getPostsFilesList, deletePostsFiles } from "@/services/posts";
  2. import { queryTable } from "@/utils/request";
  3. import { PageContainer, ProTable, ProList } from "@ant-design/pro-components";
  4. import { useNavigate } from "react-router-dom";
  5. import { Button, message, Popconfirm } from "antd";
  6. import { useRef, useState, useEffect } from "react";
  7. import { floatMultiply, floatDivide } from "@/utils";
  8. import AddFiles from "./addFiles";
  9. const FilesList = (props) => {
  10. const [showDetail, setShowDetail] = useState(false);
  11. const [activeKey, setActiveKey] = useState("");
  12. const actionRef = useRef();
  13. const navigate = useNavigate();
  14. const handleDelete = (id) => {
  15. if (id) {
  16. deletePostsFiles(id).then((res) => {
  17. actionRef.current.reload();
  18. });
  19. }
  20. };
  21. return (
  22. <PageContainer>
  23. <ProList
  24. toolBarRender={() => {
  25. return [
  26. <AddFiles
  27. onsuccess={() => {
  28. actionRef.current.reload();
  29. }}
  30. />,
  31. ];
  32. }}
  33. actionRef={actionRef}
  34. request={queryTable(getPostsFilesList)}
  35. search={{}}
  36. rowKey="id"
  37. // headerTitle="基础列表"
  38. pagination={true}
  39. // showActions="hover"
  40. metas={{
  41. title: {
  42. dataIndex: "fileName",
  43. title: "文件名称",
  44. },
  45. actions: {
  46. render: (text, row) => [
  47. <a href={row.fileAddr} download>
  48. 下载
  49. </a>,
  50. <Popconfirm
  51. key={3}
  52. title="您是否确认删除 ?"
  53. onConfirm={() => handleDelete(row.id)}
  54. okText="确定"
  55. cancelText="取消"
  56. >
  57. {/* manualPush */}
  58. <Button style={{ padding: 0 }} type="link">
  59. 删除
  60. </Button>
  61. </Popconfirm>,
  62. ],
  63. search: false,
  64. },
  65. }}
  66. />
  67. </PageContainer>
  68. );
  69. };
  70. export default FilesList;