Commit c5517fd8 authored by chenshouchao's avatar chenshouchao

feat: 完成上传文件、新建文件夹 搜索 目录路径自测

parent 23b809bd
...@@ -50,8 +50,8 @@ class CloudEController { ...@@ -50,8 +50,8 @@ class CloudEController {
// }); // });
} }
} }
// 文件列表 // 文件
static JobOutFileList( static JobOutFileDirtree(
url: any, url: any,
filetoken: string, filetoken: string,
projectId: string, projectId: string,
...@@ -60,20 +60,19 @@ class CloudEController { ...@@ -60,20 +60,19 @@ class CloudEController {
) { ) {
if (ApiUtils.getAuthorizationHeaders(headers)) { if (ApiUtils.getAuthorizationHeaders(headers)) {
headers["Cache-Control"] = "no-cache"; headers["Cache-Control"] = "no-cache";
// headers['parentName'] = ''
if (getLoaclStorageOfKey("userinfo")) { if (getLoaclStorageOfKey("userinfo")) {
url += urlToken(filetoken, projectId); url += urlToken(filetoken, projectId);
} }
return axios.get( return axios.get(
APIOPTION() + "/list" + url + "&showhidden=" + showHide, APIOPTION() + "/dirtree" + url + "&showhidden=" + showHide,
{ {
headers: headers, headers: headers,
} }
); );
} }
} }
// 文件 // 文件列表
static JobOutFileDirtree( static JobOutFileList(
url: any, url: any,
filetoken: string, filetoken: string,
projectId: string, projectId: string,
...@@ -82,11 +81,12 @@ class CloudEController { ...@@ -82,11 +81,12 @@ class CloudEController {
) { ) {
if (ApiUtils.getAuthorizationHeaders(headers)) { if (ApiUtils.getAuthorizationHeaders(headers)) {
headers["Cache-Control"] = "no-cache"; headers["Cache-Control"] = "no-cache";
// headers['parentName'] = ''
if (getLoaclStorageOfKey("userinfo")) { if (getLoaclStorageOfKey("userinfo")) {
url += urlToken(filetoken, projectId); url += urlToken(filetoken, projectId);
} }
return axios.get( return axios.get(
APIOPTION() + "/dirtree" + url + "&showhidden=" + showHide, APIOPTION() + "/list" + url + "&showhidden=" + showHide,
{ {
headers: headers, headers: headers,
} }
...@@ -106,16 +106,10 @@ class CloudEController { ...@@ -106,16 +106,10 @@ class CloudEController {
if (getLoaclStorageOfKey("userinfo")) { if (getLoaclStorageOfKey("userinfo")) {
url = urlToken(filetoken, projectId) + "&q=" + url; url = urlToken(filetoken, projectId) + "&q=" + url;
} }
axios return axios
.get(APIOPTION() + "/search" + base + url + "&showhidden=" + showHide, { .get(APIOPTION() + "/search" + base + url + "&showhidden=" + showHide, {
headers: headers, headers: headers,
}) })
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
} }
} }
......
...@@ -7,7 +7,7 @@ import { useMessage } from "@/components/MySnackbar"; ...@@ -7,7 +7,7 @@ import { useMessage } from "@/components/MySnackbar";
import CloudEController from "@/api/fileserver/CloudEController"; import CloudEController from "@/api/fileserver/CloudEController";
const AddFolder = (props: any) => { const AddFolder = (props: any) => {
const { list, path, projectId, fileToken } = props; const { list, path, projectId, fileToken, refresh } = props;
const Message = useMessage(); const Message = useMessage();
let addFolderDialogRef: any = React.createRef(); let addFolderDialogRef: any = React.createRef();
...@@ -31,9 +31,9 @@ const AddFolder = (props: any) => { ...@@ -31,9 +31,9 @@ const AddFolder = (props: any) => {
fileToken, fileToken,
projectId projectId
)?.then((res) => { )?.then((res) => {
console.log(res);
Message.success("新建成功"); Message.success("新建成功");
addFolderDialogRef.current.handleClose(); addFolderDialogRef.current.handleClose();
refresh()
}); });
} else { } else {
Message.info(fileNameCheck.help || "请输入文件夹名称"); Message.info(fileNameCheck.help || "请输入文件夹名称");
......
import React, { import React, {
useState, useState,
useImperativeHandle, useImperativeHandle,
useEffect,
useCallback, useCallback,
} from "react"; } from "react";
import style from "./index.module.css"; import style from "./index.module.css";
import { TextField } from "@mui/material";
import MyDialog from "@/components/mui/MyDialog"; import MyDialog from "@/components/mui/MyDialog";
import { checkIsNumberLetterChinese } from "@/utils/util";
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";
...@@ -16,7 +13,7 @@ import MyTreeView from "@/components/mui/MyTreeView"; ...@@ -16,7 +13,7 @@ import MyTreeView from "@/components/mui/MyTreeView";
import CloudEController from "@/api/fileserver/CloudEController"; import CloudEController from "@/api/fileserver/CloudEController";
const MoveFile = (props: any) => { const MoveFile = (props: any) => {
const { path, projectId, fileToken, currentOperateFile, selectIds } = props; const { path, projectId, fileToken, currentOperateFile, selectIds, refresh } = props;
const Message = useMessage(); const Message = useMessage();
const [newPath, setNewPath] = useState(""); const [newPath, setNewPath] = useState("");
...@@ -30,27 +27,15 @@ const MoveFile = (props: any) => { ...@@ -30,27 +27,15 @@ const MoveFile = (props: any) => {
projectId, projectId,
false false
)?.then((res) => { )?.then((res) => {
console.log("tree");
console.log(res);
if (Array.isArray(res.data)) { if (Array.isArray(res.data)) {
setTreeData(res.data); setTreeData(res.data);
} else { } else {
setTreeData([]); setTreeData([]);
} }
// setTableLoadding(false);
// if (Array.isArray(res.data)) {
// setList(res.data);
// } else {
// setList([]);
// }
}); });
} }
}, [fileToken, projectId]); }, [fileToken, projectId]);
// useEffect(() => {
// getTree();
// }, [getTree]);
let moveFileDialogRef: any = React.createRef(); let moveFileDialogRef: any = React.createRef();
const showDialog = () => { const showDialog = () => {
...@@ -78,16 +63,13 @@ const MoveFile = (props: any) => { ...@@ -78,16 +63,13 @@ const MoveFile = (props: any) => {
fileToken, fileToken,
projectId projectId
)?.then((res) => { )?.then((res) => {
console.log("批量移动"); Message.success('移动成功!')
console.log(res); refresh()
}); });
} else { } else {
const oldPath = `${path}${path === "/" ? "" : "/"}${ const oldPath = `${path}${path === "/" ? "" : "/"}${
currentOperateFile.name currentOperateFile.name
}`; }`;
console.log("submit");
console.log(newPath);
console.log(oldPath);
if (oldPath === newPath) { if (oldPath === newPath) {
Message.info("当前目录和目标目录一致,请重新选择目标目录"); Message.info("当前目录和目标目录一致,请重新选择目标目录");
return; return;
...@@ -126,6 +108,7 @@ const MoveFile = (props: any) => { ...@@ -126,6 +108,7 @@ const MoveFile = (props: any) => {
const idFunc = (item: any) => { const idFunc = (item: any) => {
return `${item.dir.substr(1)}${item.name}`; return `${item.dir.substr(1)}${item.name}`;
}; };
return ( return (
<MyDialog <MyDialog
handleSubmit={handleMoveFileSubmit} handleSubmit={handleMoveFileSubmit}
......
...@@ -88,3 +88,27 @@ ...@@ -88,3 +88,27 @@
justify-content: flex-end; justify-content: flex-end;
align-items: center; align-items: center;
} }
.showPathSpan{
cursor: pointer;
line-height: 22px;
font-size: 14px;
color: #1E2633;
/* display: flex;
align-items: center; */
}
.showPathI{
margin: 0 10px;
line-height: 22px;
font-size: 20px;
color: #C2C6CC;
cursor: default ;
}
.showPathSpan:hover{
color: #1370FF;
}
.showPathSpanActive{
color: #1370FF;
}
\ No newline at end of file
...@@ -30,12 +30,7 @@ import DialogActions from "@mui/material/DialogActions"; ...@@ -30,12 +30,7 @@ import DialogActions from "@mui/material/DialogActions";
import DialogContent from "@mui/material/DialogContent"; import DialogContent from "@mui/material/DialogContent";
import DialogContentText from "@mui/material/DialogContentText"; import DialogContentText from "@mui/material/DialogContentText";
import DialogTitle from "@mui/material/DialogTitle"; import DialogTitle from "@mui/material/DialogTitle";
// import TreeView from '@mui/lab/TreeView'; import usePass from "@/hooks/usePass";
// import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
// import ChevronRightIcon from '@mui/icons-material/ChevronRight';
// import ArrowRightIcon from '@mui/icons-material/ArrowRight';
// import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
// import TreeItem from '@mui/lab/TreeItem';
const theme = createTheme({ const theme = createTheme({
palette: { palette: {
...@@ -50,13 +45,11 @@ declare module "@mui/material/styles" { ...@@ -50,13 +45,11 @@ declare module "@mui/material/styles" {
neutral: Palette["primary"]; neutral: Palette["primary"];
} }
// allow configuration using `createTheme`
interface PaletteOptions { interface PaletteOptions {
neutral?: PaletteOptions["primary"]; neutral?: PaletteOptions["primary"];
} }
} }
// Update the Button's color prop options
declare module "@mui/material/Button" { declare module "@mui/material/Button" {
interface ButtonPropsColorOverrides { interface ButtonPropsColorOverrides {
neutral: true; neutral: true;
...@@ -64,18 +57,43 @@ declare module "@mui/material/Button" { ...@@ -64,18 +57,43 @@ declare module "@mui/material/Button" {
} }
const ProjectData = observer(() => { const ProjectData = observer(() => {
const isPass = usePass();
const Message = useMessage()
const { currentProjectStore } = useStores(); const { currentProjectStore } = useStores();
const [tableLoadding, setTableLoadding] = useState(false); const [tableLoadding, setTableLoadding] = useState(false);
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false); const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
const [currentOperateFile, setCurrentOperateFile] = useState<any>(null); const [currentOperateFile, setCurrentOperateFile] = useState<any>(null);
const [deleteloading, setDeleteloading] = useState(false); const [deleteloading, setDeleteloading] = useState(false);
// const [path, setPath] = useState("/ProjectData");
const [path, setPath] = useState("/"); const [path, setPath] = useState("/");
const showPath = useMemo(() => { const showPath = useMemo(() => {
if (path === "/") { if (path === "/") {
return "ProjectData"; // return "ProjectData";
return <span className={style.showPathSpan}>ProjectData</span>
} else {
console.log(path)
console.log(path.split('/'))
const pathArr = path.split('/')
if (pathArr.length <= 4) {
return (pathArr.map((item, index) => {
return (<span onClick={()=>setPath(pathArr.slice(0, index + 1).join('/') === '' ? '' : pathArr.slice(0, index + 1).join('/'))} className={classnames({
[style.showPathSpan]: true,
[style.showPathSpanActive]: index === pathArr.length - 1
})}>{index === 0 ? 'ProjectData' :item} {index === pathArr.length - 1 ? null : <i className={style.showPathI}>{'>'}</i>}</span>)
}))
} else {
return (pathArr.map((item, index) => {
return (<span onClick={()=>setPath(pathArr.slice(0, index + 1).join('/') === '' ? '' : pathArr.slice(0, index + 1).join('/'))} className={classnames({
[style.showPathSpan]: true,
[style.showPathSpanActive]: index === pathArr.length - 1
})}>
{index === 0 ? 'ProjectData' : index > pathArr.length - 4 ? item : '' }
{/* && index > pathArr.length - 4 */}
{index === pathArr.length - 1 || (index <= pathArr.length - 4 && index > 0) ? null : <i className={style.showPathI}>{'>'}</i>}
{index === 1 && '...'}{index === 1 && <i className={style.showPathI}>{'>'}</i>}
</span>)
}))
}
} }
return `ProjectData${path}`;
}, [path]); }, [path]);
const [activeTab, setActiveTab] = useState(1); const [activeTab, setActiveTab] = useState(1);
const [keyWord, setKeyWord] = useState(""); const [keyWord, setKeyWord] = useState("");
...@@ -94,16 +112,6 @@ const ProjectData = observer(() => { ...@@ -94,16 +112,6 @@ const ProjectData = observer(() => {
return toJS(currentProjectStore.currentProjectInfo.id); return toJS(currentProjectStore.currentProjectInfo.id);
}, [currentProjectStore]); }, [currentProjectStore]);
// useEffect(() => {
// if (fileToken && projectId) {
// CloudEController.JobOutFileList(path, fileToken, projectId, false)?.then(
// (res) => {
// console.log(res);
// setList(res.data);
// }
// );
// }
// }, [fileToken, path, projectId]);
const getList = useCallback(() => { const getList = useCallback(() => {
if (fileToken && projectId) { if (fileToken && projectId) {
setTableLoadding(true); setTableLoadding(true);
...@@ -113,7 +121,6 @@ const ProjectData = observer(() => { ...@@ -113,7 +121,6 @@ const ProjectData = observer(() => {
projectId, projectId,
false false
)?.then((res) => { )?.then((res) => {
console.log(res);
setTableLoadding(false); setTableLoadding(false);
if (Array.isArray(res.data)) { if (Array.isArray(res.data)) {
setList(res.data); setList(res.data);
...@@ -126,9 +133,35 @@ const ProjectData = observer(() => { ...@@ -126,9 +133,35 @@ const ProjectData = observer(() => {
useEffect(() => { useEffect(() => {
getList(); getList();
}, [getList]); }, [getList]);
// 全局搜索文件列表
const searchFileList = useCallback(() => {
if (fileToken && projectId) {
setTableLoadding(true);
return CloudEController.JobSearchFileList(
keyWord,
path,
fileToken,
projectId,
false
)?.then((res) => {
setTableLoadding(false);
if (Array.isArray(res.data)) {
setList(res.data);
} else {
setList([]);
}
});
}
}, [fileToken, path, projectId, keyWord]);
const handleRefresh = () => { const handleRefresh = () => {
getList(); if (keyWord) {
searchFileList()
} else {
getList();
}
setSelectIds([])
}; };
useEffect(() => { useEffect(() => {
...@@ -138,9 +171,19 @@ const ProjectData = observer(() => { ...@@ -138,9 +171,19 @@ const ProjectData = observer(() => {
}, [getDataFileTokenRun, currentProjectStore]); }, [getDataFileTokenRun, currentProjectStore]);
const handleKeyWordChange = (e: any) => { const handleKeyWordChange = (e: any) => {
if (e.target.value.length > 30) {
return
}
setKeyWord(e.target.value); setKeyWord(e.target.value);
}; };
const handleKeyWordChangeKeyUp = (e: any) => {
if (e.keyCode === 13) {
searchFileList()
console.log('搜索')
}
}
const [selectIds, setSelectIds] = useState([]); const [selectIds, setSelectIds] = useState([]);
const versionsHeadCells = [ const versionsHeadCells = [
...@@ -159,7 +202,11 @@ const ProjectData = observer(() => { ...@@ -159,7 +202,11 @@ const ProjectData = observer(() => {
const handleViewFolders = (item: any) => { const handleViewFolders = (item: any) => {
console.log("handleViewFolders"); console.log("handleViewFolders");
console.log(item); console.log(item);
setPath(`${path}${item.name}`); if (path === '/') {
setPath(`/${item.name}`)
} else {
setPath(`${path}/${item.name}`);
}
}; };
const hanleDeleteFile = (item: any) => { const hanleDeleteFile = (item: any) => {
...@@ -254,17 +301,23 @@ const ProjectData = observer(() => { ...@@ -254,17 +301,23 @@ const ProjectData = observer(() => {
}; };
const handleDelete = () => { const handleDelete = () => {
const deletePath = let deletePath = ''
path === "/" if (currentOperateFile) {
? `${path}${currentOperateFile.name}` deletePath =
: `${path}/${currentOperateFile.name}`; path === "/"
? `${path}${currentOperateFile.name}`
: `${path}/${currentOperateFile.name}`;
} else {
deletePath = selectIds.map((name: any) => {
return `${path}${path === "/" ? "" : "/"}${name}`;
}).join(' ');
}
CloudEController.JobOutFileDel( CloudEController.JobOutFileDel(
deletePath, deletePath,
fileToken, fileToken,
projectId as string projectId as string
)?.then((res) => { )?.then((res) => {
console.log("handleDelete"); Message.success('删除成功')
console.log(res);
setDeleteloading(false); setDeleteloading(false);
setDeleteDialogOpen(false); setDeleteDialogOpen(false);
handleRefresh(); handleRefresh();
...@@ -276,6 +329,11 @@ const ProjectData = observer(() => { ...@@ -276,6 +329,11 @@ const ProjectData = observer(() => {
moveFileRef.current.showDialog(); moveFileRef.current.showDialog();
}; };
const handleBatchDelete = () => {
setCurrentOperateFile(null);
setDeleteDialogOpen(true)
}
return ( return (
<ThemeProvider theme={theme}> <ThemeProvider theme={theme}>
<div className={style.projectData}> <div className={style.projectData}>
...@@ -290,7 +348,9 @@ const ProjectData = observer(() => { ...@@ -290,7 +348,9 @@ const ProjectData = observer(() => {
size="small" size="small"
style={{ marginRight: "12px" }} style={{ marginRight: "12px" }}
onClick={hanleShowUpLoaderFileDialog} onClick={hanleShowUpLoaderFileDialog}
disabled={selectIds.length !== 0 || !isPass("PROJECT_DATA_UPLOAD")}
> >
{/* todo 项目权限 */}
上传文件 上传文件
</Button> </Button>
<Button <Button
...@@ -298,7 +358,9 @@ const ProjectData = observer(() => { ...@@ -298,7 +358,9 @@ const ProjectData = observer(() => {
variant="outlined" variant="outlined"
size="small" size="small"
onClick={hanleShowAddFolderDialog} onClick={hanleShowAddFolderDialog}
> disabled={selectIds.length !== 0 || !isPass("PROJECT_DATA_ADDDIR")}
>
{/* todo 项目权限 */}
新建文件夹 新建文件夹
</Button> </Button>
</div> </div>
...@@ -310,6 +372,7 @@ const ProjectData = observer(() => { ...@@ -310,6 +372,7 @@ const ProjectData = observer(() => {
value={keyWord} value={keyWord}
onChange={handleKeyWordChange} onChange={handleKeyWordChange}
style={{ width: "280px", fontSize: "14px" }} style={{ width: "280px", fontSize: "14px" }}
onKeyUp={handleKeyWordChangeKeyUp}
/> />
<IconButton <IconButton
type="submit" type="submit"
...@@ -387,6 +450,7 @@ const ProjectData = observer(() => { ...@@ -387,6 +450,7 @@ const ProjectData = observer(() => {
variant="outlined" variant="outlined"
size="small" size="small"
style={{ marginRight: "12px" }} style={{ marginRight: "12px" }}
onClick={handleBatchDelete}
> >
批量删除({selectIds.length} 批量删除({selectIds.length}
</Button> </Button>
...@@ -410,7 +474,7 @@ const ProjectData = observer(() => { ...@@ -410,7 +474,7 @@ const ProjectData = observer(() => {
<DialogTitle id="alert-dialog-title">{"提示"}</DialogTitle> <DialogTitle id="alert-dialog-title">{"提示"}</DialogTitle>
<DialogContent> <DialogContent>
<DialogContentText id="alert-dialog-description"> <DialogContentText id="alert-dialog-description">
确认要删除“{currentOperateFile ? currentOperateFile.name : ""} 确认要删除“{currentOperateFile ? currentOperateFile.name : selectIds.join('”,“')}
”吗? ”吗?
</DialogContentText> </DialogContentText>
</DialogContent> </DialogContent>
...@@ -429,15 +493,10 @@ const ProjectData = observer(() => { ...@@ -429,15 +493,10 @@ const ProjectData = observer(() => {
onClick={handleDelete} onClick={handleDelete}
color="primary" color="primary"
variant="contained" variant="contained"
// style={submitStyle}
size="small" size="small"
> >
确认 确认
</LoadingButton> </LoadingButton>
{/* <Button onClick={handleDeleteDialogClose}>取消</Button>
<Button onClick={handleDelete} autoFocus>
确认
</Button> */}
</DialogActions> </DialogActions>
</Dialog> </Dialog>
<UpLoaderFile <UpLoaderFile
...@@ -449,6 +508,7 @@ const ProjectData = observer(() => { ...@@ -449,6 +508,7 @@ const ProjectData = observer(() => {
onRef={addFolderRef} onRef={addFolderRef}
list={list} list={list}
path={path} path={path}
refresh={handleRefresh}
fileToken={fileToken} fileToken={fileToken}
projectId={projectId} projectId={projectId}
></AddFolder> ></AddFolder>
...@@ -459,6 +519,7 @@ const ProjectData = observer(() => { ...@@ -459,6 +519,7 @@ const ProjectData = observer(() => {
projectId={projectId} projectId={projectId}
currentOperateFile={currentOperateFile} currentOperateFile={currentOperateFile}
selectIds={selectIds} selectIds={selectIds}
refresh={handleRefresh}
></MoveFile> ></MoveFile>
</div> </div>
</ThemeProvider> </ThemeProvider>
......
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