|
@@ -1,4 +1,4 @@
|
|
|
-import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
|
+import { useCallback, useMemo, useRef, useState } from "react";
|
|
|
import styles from "./index.module.scss";
|
|
|
|
|
|
import { InboxOutlined } from "@ant-design/icons";
|
|
@@ -19,11 +19,7 @@ import history from "@/utils/history";
|
|
|
import React from "react";
|
|
|
import { getTokenFu } from "@/utils/storage";
|
|
|
import { MessageFu } from "@/utils/message";
|
|
|
-import {
|
|
|
- A1_APIIupBtnOk,
|
|
|
- A1_APIIupIsList,
|
|
|
- A1_APIremoveSure,
|
|
|
-} from "@/store/action/A1Project";
|
|
|
+import { A1_APIIupBtnOk, A1_APIremoveSure } from "@/store/action/A1Project";
|
|
|
import { authFilesLookFu, urlChangeFu } from "@/utils/authFilesLook";
|
|
|
import { useSelector } from "react-redux";
|
|
|
import { RootState } from "@/store";
|
|
@@ -49,20 +45,6 @@ type props = {
|
|
|
};
|
|
|
|
|
|
function A1IupFile({ myUrl, closeFu, upFileFu, myTitle, projectId }: props) {
|
|
|
- // 获取回显列表,重命名的时候使用
|
|
|
- const [isFileList, setIsFileList] = useState<string[]>([]);
|
|
|
-
|
|
|
- const getIsFileListFu = useCallback(async () => {
|
|
|
- const res = await A1_APIIupIsList(projectId);
|
|
|
- if (res.code === 0) {
|
|
|
- setIsFileList(res.data.map((v: any) => v.fileName));
|
|
|
- }
|
|
|
- }, [projectId]);
|
|
|
-
|
|
|
- useEffect(() => {
|
|
|
- getIsFileListFu();
|
|
|
- }, [getIsFileListFu]);
|
|
|
-
|
|
|
const [modal, contextHolder] = Modal.useModal();
|
|
|
|
|
|
const [fileList, setFileList] = useState<UploadFile[]>([]);
|
|
@@ -82,32 +64,7 @@ function A1IupFile({ myUrl, closeFu, upFileFu, myTitle, projectId }: props) {
|
|
|
const idName = info.name;
|
|
|
|
|
|
// 如果已经有相同的重命名
|
|
|
- let resName = myTitle + "_" + idName;
|
|
|
-
|
|
|
- const isArr = fileList.find((v) => v.mySelect.resName === resName);
|
|
|
-
|
|
|
- const nameArr = fileList.filter((v) =>
|
|
|
- v.mySelect.resName.includes(resName)
|
|
|
- );
|
|
|
-
|
|
|
- if (isFileList.length) {
|
|
|
-
|
|
|
- console.log(isFileList);
|
|
|
-
|
|
|
-
|
|
|
- const isArr2 = isFileList.find((v) => v === resName);
|
|
|
- const nameArr2 = isFileList.filter((v) => v.includes(resName));
|
|
|
-
|
|
|
- if (nameArr.length > 0 && nameArr2.length > 0 && isArr && isArr2) {
|
|
|
- resName = `${myTitle}_${idName}(${
|
|
|
- nameArr.length + nameArr2.length + 1
|
|
|
- })`;
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (nameArr.length > 0 && isArr) {
|
|
|
- resName = `${myTitle}_${idName}(${nameArr.length + 1})`;
|
|
|
- }
|
|
|
- }
|
|
|
+ const resName = myTitle + "_" + idName;
|
|
|
|
|
|
setFileList(
|
|
|
fileList.map((v) => ({
|
|
@@ -125,7 +82,7 @@ function A1IupFile({ myUrl, closeFu, upFileFu, myTitle, projectId }: props) {
|
|
|
}))
|
|
|
);
|
|
|
},
|
|
|
- [fileList, isFileList, myTitle, typeData]
|
|
|
+ [fileList, myTitle, typeData]
|
|
|
);
|
|
|
|
|
|
// 重命名的文件后缀
|