Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
bkunyun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
bkunyun
Commits
50dbbf5f
Commit
50dbbf5f
authored
Jul 20, 2022
by
chenshouchao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 移动文件组件重构
parent
c9c0d6b8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
44 deletions
+43
-44
index.tsx
src/views/Project/ProjectData/MoveFile/index.tsx
+25
-29
index.tsx
src/views/Project/ProjectData/index.tsx
+18
-15
No files found.
src/views/Project/ProjectData/MoveFile/index.tsx
View file @
50dbbf5f
import
React
,
{
import
React
,
{
useState
,
useCallback
,
useMemo
,
useEffect
}
from
"react"
;
useState
,
useImperativeHandle
,
useCallback
,
useMemo
,
useEffect
,
}
from
"react"
;
import
style
from
"./index.module.css"
;
import
style
from
"./index.module.css"
;
import
MyDialog
from
"@/components/mui/
My
Dialog"
;
import
MyDialog
from
"@/components/mui/Dialog"
;
import
folderIcon
from
"@/assets/project/folderIcon.svg"
;
import
folderIcon
from
"@/assets/project/folderIcon.svg"
;
import
bigFolderIcon
from
"@/assets/project/bigFolderIcon.svg"
;
import
bigFolderIcon
from
"@/assets/project/bigFolderIcon.svg"
;
import
{
useMessage
}
from
"@/components/MySnackbar"
;
import
{
useMessage
}
from
"@/components/MySnackbar"
;
...
@@ -18,8 +12,22 @@ import useMyRequest from "@/hooks/useMyRequest";
...
@@ -18,8 +12,22 @@ import useMyRequest from "@/hooks/useMyRequest";
import
classNames
from
"classnames"
;
import
classNames
from
"classnames"
;
import
_
from
"lodash"
;
import
_
from
"lodash"
;
const
MoveFile
=
(
props
:
any
)
=>
{
type
IMoveFileProps
=
{
moveDialogOpen
:
any
;
setMoveDialogOpen
:
any
;
path
:
string
;
projectId
:
string
;
fileToken
:
string
;
refresh
:
any
;
selectIds
:
Array
<
any
>
;
currentOperateFile
:
any
;
showList
:
Array
<
any
>
;
};
const
MoveFile
=
(
props
:
IMoveFileProps
)
=>
{
const
{
const
{
moveDialogOpen
,
setMoveDialogOpen
,
path
,
path
,
projectId
,
projectId
,
fileToken
,
fileToken
,
...
@@ -31,10 +39,8 @@ const MoveFile = (props: any) => {
...
@@ -31,10 +39,8 @@ const MoveFile = (props: any) => {
const
Message
=
useMessage
();
const
Message
=
useMessage
();
const
[
newPath
,
setNewPath
]
=
useState
(
"/"
);
const
[
newPath
,
setNewPath
]
=
useState
(
"/"
);
const
[
rootActive
,
setRootActive
]
=
useState
(
true
);
const
[
rootActive
,
setRootActive
]
=
useState
(
true
);
const
[
moveFileSubmitloading
,
setMoveFileSubmitloading
]
=
useState
(
false
);
const
[
treeData
,
setTreeData
]
=
useState
<
any
>
([]);
const
[
treeData
,
setTreeData
]
=
useState
<
any
>
([]);
const
[
renderTreeData
,
setRenderTreeData
]
=
useState
<
any
>
([]);
const
[
renderTreeData
,
setRenderTreeData
]
=
useState
<
any
>
([]);
const
[
moveFileDialogRef
]
=
useState
<
any
>
(
React
.
createRef
());
// 要移动的文件夹 之后用来隐藏文件夹树中同路径的文件夹
// 要移动的文件夹 之后用来隐藏文件夹树中同路径的文件夹
const
[
moveFolderPathArr
,
setMoveFolderPathArr
]
=
useState
<
Array
<
string
>>
([]);
const
[
moveFolderPathArr
,
setMoveFolderPathArr
]
=
useState
<
Array
<
string
>>
([]);
...
@@ -56,6 +62,10 @@ const MoveFile = (props: any) => {
...
@@ -56,6 +62,10 @@ const MoveFile = (props: any) => {
}
}
},
[
fileToken
,
projectId
]);
},
[
fileToken
,
projectId
]);
useEffect
(()
=>
{
getTree
();
},
[
getTree
]);
const
getDisabledRepeatFolder
=
useCallback
(
const
getDisabledRepeatFolder
=
useCallback
(
(
folderTree
:
any
,
samePathFolederArr
:
Array
<
string
>
)
=>
{
(
folderTree
:
any
,
samePathFolederArr
:
Array
<
string
>
)
=>
{
const
arr
=
_
.
cloneDeep
(
folderTree
);
const
arr
=
_
.
cloneDeep
(
folderTree
);
...
@@ -102,24 +112,12 @@ const MoveFile = (props: any) => {
...
@@ -102,24 +112,12 @@ const MoveFile = (props: any) => {
setMoveFolderPathArr
(
pathArr
);
setMoveFolderPathArr
(
pathArr
);
},
[
selectIds
,
showList
,
currentOperateFile
,
path
]);
},
[
selectIds
,
showList
,
currentOperateFile
,
path
]);
const
showDialog
=
()
=>
{
moveFileDialogRef
.
current
.
handleClickOpen
();
getTree
();
};
useImperativeHandle
(
props
.
onRef
,
()
=>
{
return
{
showDialog
:
showDialog
,
};
});
const
{
run
:
getDataFileMovePackageRun
}
=
useMyRequest
(
const
{
run
:
getDataFileMovePackageRun
}
=
useMyRequest
(
getDataFileMovePackage
,
getDataFileMovePackage
,
{
{
onSuccess
:
()
=>
{
onSuccess
:
()
=>
{
Message
.
success
(
"移动成功!"
);
Message
.
success
(
"移动成功!"
);
setMoveFileSubmitloading
(
false
);
setMoveDialogOpen
(
false
);
moveFileDialogRef
?.
current
?.
handleClose
();
refresh
();
refresh
();
},
},
onError
(
error
:
any
)
{
onError
(
error
:
any
)
{
...
@@ -130,7 +128,6 @@ const MoveFile = (props: any) => {
...
@@ -130,7 +128,6 @@ const MoveFile = (props: any) => {
}
else
{
}
else
{
Message
.
error
(
"文件服务发生错误,数据移动失败。"
);
Message
.
error
(
"文件服务发生错误,数据移动失败。"
);
}
}
setMoveFileSubmitloading
(
false
);
},
},
}
}
);
);
...
@@ -198,7 +195,6 @@ const MoveFile = (props: any) => {
...
@@ -198,7 +195,6 @@ const MoveFile = (props: any) => {
}
else
if
(
newPath
===
path
)
{
}
else
if
(
newPath
===
path
)
{
Message
.
error
(
"指定的目标路径为数据原路径,无需移动。"
);
Message
.
error
(
"指定的目标路径为数据原路径,无需移动。"
);
}
else
{
}
else
{
setMoveFileSubmitloading
(
true
);
moveFileFun
();
moveFileFun
();
}
}
};
};
...
@@ -229,10 +225,10 @@ const MoveFile = (props: any) => {
...
@@ -229,10 +225,10 @@ const MoveFile = (props: any) => {
return
(
return
(
<
MyDialog
<
MyDialog
handleSubmit=
{
handleMoveFileSubmit
}
open=
{
moveDialogOpen
}
onRef=
{
moveFileDialogRef
}
title=
"移动至"
title=
"移动至"
submitloading=
{
moveFileSubmitloading
}
onClose=
{
()
=>
setMoveDialogOpen
(
false
)
}
onConfirm=
{
handleMoveFileSubmit
}
>
>
<
div
<
div
className=
{
classNames
({
className=
{
classNames
({
...
...
src/views/Project/ProjectData/index.tsx
View file @
50dbbf5f
...
@@ -79,6 +79,7 @@ const ProjectData = observer(() => {
...
@@ -79,6 +79,7 @@ const ProjectData = observer(() => {
const
[
showCheckBox
,
setShowCheckBox
]
=
useState
<
boolean
>
(
true
);
const
[
showCheckBox
,
setShowCheckBox
]
=
useState
<
boolean
>
(
true
);
// 文件服务器指向
// 文件服务器指向
const
fileServerEndPoint
=
localStorage
.
getItem
(
"fileServerEndPoint"
);
const
fileServerEndPoint
=
localStorage
.
getItem
(
"fileServerEndPoint"
);
const
[
moveDialogOpen
,
setMoveDialogOpen
]
=
useState
(
false
);
useEffect
(()
=>
{
useEffect
(()
=>
{
const
locationInfo
:
any
=
location
?.
state
;
const
locationInfo
:
any
=
location
?.
state
;
...
@@ -445,12 +446,10 @@ const ProjectData = observer(() => {
...
@@ -445,12 +446,10 @@ const ProjectData = observer(() => {
);
);
};
};
// 文件移动
// 显示移动弹窗
let
moveFileRef
:
any
=
React
.
createRef
();
const
hanleShowMoveFileDialog
=
(
item
:
any
)
=>
{
const
hanleShowMoveFileDialog
=
(
item
:
any
)
=>
{
setCurrentOperateFile
(
item
);
setCurrentOperateFile
(
item
);
moveFileRef
.
current
.
showDialog
(
);
setMoveDialogOpen
(
true
);
};
};
// 删除弹窗
// 删除弹窗
...
@@ -463,7 +462,7 @@ const ProjectData = observer(() => {
...
@@ -463,7 +462,7 @@ const ProjectData = observer(() => {
// 批量移动
// 批量移动
const
handleBatchMove
=
()
=>
{
const
handleBatchMove
=
()
=>
{
setCurrentOperateFile
(
null
);
setCurrentOperateFile
(
null
);
moveFileRef
.
current
.
showDialog
(
);
setMoveDialogOpen
(
true
);
};
};
// 批量删除
// 批量删除
...
@@ -686,16 +685,20 @@ const ProjectData = observer(() => {
...
@@ -686,16 +685,20 @@ const ProjectData = observer(() => {
path=
{
path
}
path=
{
path
}
list=
{
allList
}
list=
{
allList
}
></
UpLoaderFile
>
></
UpLoaderFile
>
<
MoveFile
{
moveDialogOpen
&&
(
onRef=
{
moveFileRef
}
<
MoveFile
path=
{
path
}
// onRef=
{
moveFileRef
}
fileToken=
{
fileToken
}
moveDialogOpen=
{
moveDialogOpen
}
projectId=
{
projectId
}
setMoveDialogOpen=
{
setMoveDialogOpen
}
currentOperateFile=
{
currentOperateFile
}
path=
{
path
}
selectIds=
{
selectIds
}
fileToken=
{
fileToken
as
string
}
refresh=
{
handleRefresh
}
projectId=
{
projectId
as
string
}
showList=
{
showList
}
currentOperateFile=
{
currentOperateFile
}
></
MoveFile
>
selectIds=
{
selectIds
}
refresh=
{
handleRefresh
}
showList=
{
showList
}
></
MoveFile
>
)
}
</
div
>
</
div
>
</
ThemeProvider
>
</
ThemeProvider
>
);
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment