Commit f8d48b43 authored by chenshouchao's avatar chenshouchao

feat: 文件夹在文件前面显示 文件移动错误提示优化

parent 654a32de
...@@ -138,7 +138,9 @@ const MoveFile = (props: any) => { ...@@ -138,7 +138,9 @@ const MoveFile = (props: any) => {
foldersMove(folderMoveList); foldersMove(folderMoveList);
} }
if (fileMoveList.length > 0) { if (fileMoveList.length > 0) {
filesMove(fileMoveList); filesMove(fileMoveList)?.then((res) => {
successMove();
});
} }
} else { } else {
if (currentOperateFile.type === "dataSet") { if (currentOperateFile.type === "dataSet") {
...@@ -146,7 +148,9 @@ const MoveFile = (props: any) => { ...@@ -146,7 +148,9 @@ const MoveFile = (props: any) => {
} else if (currentOperateFile.type === "directory") { } else if (currentOperateFile.type === "directory") {
folerMove(); folerMove();
} else { } else {
fileMove(); fileMove()?.then((res) => {
successMove();
});
} }
} }
} }
...@@ -155,15 +159,13 @@ const MoveFile = (props: any) => { ...@@ -155,15 +159,13 @@ const MoveFile = (props: any) => {
// 单文件移动 // 单文件移动
const fileMove = () => { const fileMove = () => {
const oldPathToFileServer = `${oldPathProvidedToFileServer}${currentOperateFile.name}`; const oldPathToFileServer = `${oldPathProvidedToFileServer}${currentOperateFile.name}`;
CloudEController.JobFileMove( return CloudEController.JobFileMove(
newPath, newPath,
oldPathToFileServer, oldPathToFileServer,
"", "",
fileToken, fileToken,
projectId projectId
)?.then((res) => { );
successMove();
});
}; };
// 多文件移动 // 多文件移动
...@@ -171,22 +173,28 @@ const MoveFile = (props: any) => { ...@@ -171,22 +173,28 @@ const MoveFile = (props: any) => {
const oldPaths = fileMoveList.map((item: any) => { const oldPaths = fileMoveList.map((item: any) => {
return `${oldPathProvidedToFileServer}${item.name}`; return `${oldPathProvidedToFileServer}${item.name}`;
}); });
CloudEController.JobFileBatchMove( return CloudEController.JobFileBatchMove(
newPath, newPath,
oldPaths, oldPaths,
"", "",
fileToken, fileToken,
projectId projectId
)?.then((res) => { );
successMove();
});
}; };
// 单文件夹移动 // 单文件夹移动
const folerMove = () => { const folerMove = () => {
fileMove(); fileMove()
const names = currentOperateFile.name; ?.then((res) => {
dataSetInFolerMove(names); const names = currentOperateFile.name;
dataSetInFolerMove(names);
})
.catch((error) => {
console.log(error);
if (error?.response?.status === 405) {
Message.error("因目标路径存在同名文件,数据移动失败。");
}
});
}; };
// 移动文件夹中的数据集 // 移动文件夹中的数据集
...@@ -201,9 +209,17 @@ const MoveFile = (props: any) => { ...@@ -201,9 +209,17 @@ const MoveFile = (props: any) => {
// 多文件夹移动 // 多文件夹移动
const foldersMove = (folderMoveList: Array<any>) => { const foldersMove = (folderMoveList: Array<any>) => {
filesMove(folderMoveList); filesMove(folderMoveList)
const names = folderMoveList.map((item: any) => item.name).join(","); ?.then((res) => {
dataSetInFolerMove(names); const names = folderMoveList.map((item: any) => item.name).join(",");
dataSetInFolerMove(names);
})
.catch((error) => {
console.log(error);
if (error?.response?.status === 405) {
Message.error("因目标路径存在同名文件,数据移动失败。");
}
});
}; };
// 单数据集移动 // 单数据集移动
......
...@@ -88,13 +88,22 @@ const ProjectData = observer(() => { ...@@ -88,13 +88,22 @@ const ProjectData = observer(() => {
useEffect(() => { useEffect(() => {
const locationInfo: any = location?.state; const locationInfo: any = location?.state;
setPath(locationInfo?.pathName || ""); setPath(locationInfo?.pathName || "");
handleRefresh();
}, [location]); }, [location]);
// 列表展示的数据 // 列表展示的数据
const showList = useMemo(() => { const showList = useMemo(() => {
if (activeTab === 1) { if (activeTab === 1) {
return list; // 做排序 文件夹在前
let folderList: any = [];
let fileList: any = [];
list.forEach((item: any) => {
if (item.type === "directory") {
folderList.push(item);
} else {
fileList.push(item);
}
});
return [...folderList, ...fileList];
} else { } else {
const folderList = list.filter((item: any) => { const folderList = list.filter((item: any) => {
return item.type === "directory"; return item.type === "directory";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment