shaogen1995 2 роки тому
батько
коміт
2fd404df42

+ 32 - 19
src/pages/A1Project/A1Down/index.tsx

@@ -1,13 +1,15 @@
 import React, { useCallback, useEffect, useState } from "react";
 import styles from "./index.module.scss";
 import { Button, Checkbox, Empty, Modal } from "antd";
-import { A1_APIgetDownList } from "@/store/action/A1Project";
+import { A1_APIdownBtnOk, A1_APIgetDownList } from "@/store/action/A1Project";
 import { A1getStorage, A1setStorage } from "@/utils/storage";
 import { MessageFu } from "@/utils/message";
+import { urlChangeFu } from "@/utils/authFilesLook";
 
 type SelectType = {
-  id: number;
-  label: string;
+  attrId: number;
+  name: string;
+  hasUpload: boolean;
   done: boolean;
 };
 
@@ -20,19 +22,14 @@ function A1Down({ downId, closeFu }: Props) {
   const getInfoFu = useCallback(async (id: number) => {
     const res = await A1_APIgetDownList(id);
     if (res.code === 0) {
-      // setCheckedList(res.data || []);
-      let arr = [
-        { id: 1, label: "需求规格说明书", done: false },
-        { id: 2, label: "重要文件1", done: false },
-        { id: 3, label: "未分类", done: false },
-      ];
+      let arr: SelectType[] = res.data.filter((v: SelectType) => v.hasUpload);
 
       const storeIds = A1getStorage();
 
       if (storeIds) {
         arr = arr.map((v) => ({
           ...v,
-          done: storeIds.includes(v.id) ? true : false,
+          done: storeIds.includes(v.attrId) ? true : false,
         }));
       }
 
@@ -68,7 +65,7 @@ function A1Down({ downId, closeFu }: Props) {
       setCheckedList(
         checkedList.map((v) => ({
           ...v,
-          done: v.id === id ? val : v.done,
+          done: v.attrId === id ? val : v.done,
         }))
       );
     },
@@ -83,13 +80,29 @@ function A1Down({ downId, closeFu }: Props) {
   }, [checkedList]);
 
   // 点击提交
-  const btnOkFu = useCallback(() => {
-    console.log("-------", checkedList);
-  }, [checkedList]);
+  const btnOkFu = useCallback(async () => {
+    const obj = {
+      projectId: downId.id,
+      attrId: checkedList.map((v) => v.attrId),
+    };
+
+    const res = await A1_APIdownBtnOk(obj);
+
+    if (res.code === 0) {
+      urlChangeFu(res.data, true, undefined, downId.txt);
+      // 清空所有选中状态
+      setCheckedList(
+        checkedList.map((v) => ({
+          ...v,
+          done: false,
+        }))
+      );
+    }
+  }, [checkedList, downId.id, downId.txt]);
 
   // 点击保存设置 到 本地
   const clickStoreFu = useCallback(() => {
-    const arr = checkedList.filter((v) => v.done).map((v) => v.id);
+    const arr = checkedList.filter((v) => v.done).map((v) => v.attrId);
     A1setStorage(arr);
     MessageFu.success("保存设置到本地成功!");
   }, [checkedList]);
@@ -99,7 +112,7 @@ function A1Down({ downId, closeFu }: Props) {
       wrapClassName={styles.A1Down}
       destroyOnClose
       open={true}
-      title={downId.txt}
+      title={"下载:" + downId.txt}
       footer={
         [] // 设置footer为空,去掉 取消 确定默认按钮
       }
@@ -121,12 +134,12 @@ function A1Down({ downId, closeFu }: Props) {
         {checkedList.length ? (
           <div className="A1DownMainC">
             {checkedList.map((v) => (
-              <div className="A1DownMainCRow" key={v.id} title={v.label}>
+              <div className="A1DownMainCRow" key={v.attrId} title={v.name}>
                 <Checkbox
-                  onChange={(e) => onChange(e.target.checked, v.id)}
+                  onChange={(e) => onChange(e.target.checked, v.attrId)}
                   checked={v.done}
                 >
-                  {v.label}
+                  {v.name}
                 </Checkbox>
               </div>
             ))}

+ 105 - 29
src/pages/A7Recycled/index.tsx

@@ -8,8 +8,14 @@ import React, {
 import styles from "./index.module.scss";
 import { Button, DatePicker, Input, Popconfirm, Table } from "antd";
 import { useDispatch, useSelector } from "react-redux";
-import { A7_APIgetList } from "@/store/action/A7Recycled";
+import {
+  A7_APIdel,
+  A7_APIgetList,
+  A7_APIrecover,
+} from "@/store/action/A7Recycled";
 import { RootState } from "@/store";
+import { A7tableType } from "@/types";
+import { MessageFu } from "@/utils/message";
 
 const { RangePicker } = DatePicker;
 
@@ -21,8 +27,6 @@ function A7Recycled() {
     userId: "",
     startTime: "",
     endTime: "",
-    sizeMin: "",
-    sizeMax: "",
     pageNum: 1,
     pageSize: 10,
   });
@@ -31,17 +35,7 @@ function A7Recycled() {
   const tableTime = useRef(-1);
 
   const getListFu = useCallback(() => {
-    clearTimeout(tableTime.current);
-
-    tableTime.current = window.setTimeout(() => {
-      const obj = {
-        ...fromData,
-        sizeMin: fromData.sizeMin ? Number(fromData.sizeMin) : null,
-        sizeMax: fromData.sizeMax ? Number(fromData.sizeMax) : null,
-      };
-
-      dispatch(A7_APIgetList(obj));
-    }, 500);
+    dispatch(A7_APIgetList(fromData));
   }, [dispatch, fromData]);
 
   useEffect(() => {
@@ -51,11 +45,14 @@ function A7Recycled() {
   // 输入框的输入
   const tabInputChangeFu = useCallback(
     (e: React.ChangeEvent<HTMLInputElement>, key: "searchKey" | "userId") => {
-      setFromData({
-        ...fromData,
-        [key]: e.target.value,
-        pageNum: 1,
-      });
+      clearTimeout(tableTime.current);
+      tableTime.current = window.setTimeout(() => {
+        setFromData({
+          ...fromData,
+          [key]: e.target.value,
+          pageNum: 1,
+        });
+      }, 500);
     },
     [fromData]
   );
@@ -88,19 +85,89 @@ function A7Recycled() {
   const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
 
   // 点击删除
-  const delById = useCallback((ids: string) => {}, []);
+  const delById = useCallback(
+    async (ids: string, flag: boolean) => {
+      const res = await A7_APIdel(ids);
+
+      if (res.code === 0) {
+        MessageFu.success("删除成功!");
+        getListFu();
+        if (flag) {
+          // 清空选中
+          setSelectedRowKeys([]);
+        }
+      }
+    },
+    [getListFu]
+  );
 
   // 点击恢复
-  const restortFu = useCallback((ids: string) => {}, []);
+  const restortFu = useCallback(
+    async (ids: string, flag: boolean) => {
+      const res = await A7_APIrecover(ids);
+
+      if (res.code === 0) {
+        MessageFu.success("恢复成功!");
+        getListFu();
+        if (flag) {
+          // 清空选中
+          setSelectedRowKeys([]);
+        }
+      }
+    },
+    [getListFu]
+  );
 
   const columns = useMemo(() => {
     return [
       {
-        title: "创建用户",
+        title: "文件名称",
+        dataIndex: "fileName",
+      },
+      {
+        title: "删除人",
         dataIndex: "creatorName",
       },
+      {
+        title: "删除日期",
+        dataIndex: "createTime",
+      },
+      {
+        title: "删除原因",
+        dataIndex: "description",
+      },
+      {
+        title: "文件大小(MB)",
+        render: (item: A7tableType) =>
+          (Number(item.fileSize) / 1024).toFixed(2),
+      },
+      {
+        title: "操作",
+        render: (item: A7tableType) => (
+          <>
+            <Button
+              size="small"
+              type="text"
+              onClick={() => restortFu(item.id + "", false)}
+            >
+              恢复
+            </Button>
+            <Popconfirm
+              title="此次为物理删除,无法找回。请谨慎操作"
+              okText="删除"
+              cancelText="取消"
+              onConfirm={() => delById(item.id + "", false)}
+              okButtonProps={{ loading: false }}
+            >
+              <Button size="small" type="text" danger>
+                删除
+              </Button>
+            </Popconfirm>
+          </>
+        ),
+      },
     ];
-  }, []);
+  }, [delById, restortFu]);
 
   return (
     <div className={styles.A7Recycled}>
@@ -134,21 +201,30 @@ function A7Recycled() {
         </div>
 
         <div className="A7TopBtn">
+          <Button
+            disabled={selectedRowKeys.length <= 0}
+            type="primary"
+            onClick={() => restortFu(selectedRowKeys.join(","), true)}
+          >
+            批量恢复
+          </Button>
+          &emsp;
           <Popconfirm
+            disabled={selectedRowKeys.length <= 0}
             title="此次为物理删除,无法找回。请谨慎操作"
             okText="删除"
             cancelText="取消"
-            onConfirm={() => delById("123")}
+            onConfirm={() => delById(selectedRowKeys.join(","), true)}
             okButtonProps={{ loading: false }}
           >
-            <Button type="primary" danger>
+            <Button
+              type="primary"
+              danger
+              disabled={selectedRowKeys.length <= 0}
+            >
               批量删除
             </Button>
           </Popconfirm>
-          &emsp;
-          <Button type="primary" onClick={() => restortFu("123")}>
-            批量恢复
-          </Button>
         </div>
       </div>
 

+ 5 - 7
src/store/action/A1Project.ts

@@ -47,9 +47,9 @@ export const A1_APIgetDownList = (id: number) => {
 /**
  * 下载列表点击确定(外层)
  */
-
-
-
+export const A1_APIdownBtnOk = (data: any) => {
+  return http.post("cms/inside/download/attrIds", data);
+};
 
 // --------------------------  项目文件  --------------------------
 /**
@@ -158,12 +158,11 @@ export const A1_APIUdel = (id: number) => {
 
 // --------------------------  内控文件  --------------------------
 
-
 /**
  * 内控文件---------获取内控文件属性的已过滤的列表
  */
 export const A1_APIIgetIresList = () => {
-  return http.get('cms/inside/getFileAttributeList');
+  return http.get("cms/inside/getFileAttributeList");
 };
 
 /**
@@ -210,10 +209,9 @@ export const A1_APIIupBtnOk = (projectId: number, data: any) => {
   return http.post(`cms/inside/update/${projectId}`, data);
 };
 
-
 /**
  * 内控文件---------批量下载
  */
-export const A1_APIIdowns = (ids:string) => {
+export const A1_APIIdowns = (ids: string) => {
   return http.get(`cms/inside/download/${ids}`);
 };

+ 15 - 1
src/store/action/A7Recycled.ts

@@ -14,4 +14,18 @@ export const A7_APIgetList = (data: any) => {
       dispatch({ type: "A7/getList", payload: obj });
     }
   };
-};
+};
+
+/**
+ * 恢复
+ */
+export const A7_APIrecover = (ids: string) => {
+  return http.get(`cms/recycle/recover/${ids}`);
+};
+
+/**
+ * 删除
+ */
+export const A7_APIdel = (ids: string) => {
+  return http.get(`cms/recycle/remove/${ids}`);
+};