|
@@ -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>
|
|
|
+  
|
|
|
<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>
|
|
|
-  
|
|
|
- <Button type="primary" onClick={() => restortFu("123")}>
|
|
|
- 批量恢复
|
|
|
- </Button>
|
|
|
</div>
|
|
|
</div>
|
|
|
|