Commit c9c0d6b8 authored by chenshouchao's avatar chenshouchao

feat: 数据管理新建文件夹重构

parent 3dc486a5
import React, { useState, useImperativeHandle } from "react"; import React, { useState, useEffect } from "react";
import { TextField } from "@mui/material"; import { TextField, Button } from "@mui/material";
import MyDialog from "@/components/mui/MyDialog"; import MyDialog from "@/components/mui/Dialog";
import { checkIsNumberLetterChinese } from "@/utils/util"; import { checkIsNumberLetterChinese } from "@/utils/util";
import { useMessage } from "@/components/MySnackbar"; import { useMessage } from "@/components/MySnackbar";
import CloudEController from "@/api/fileserver/CloudEController"; import CloudEController from "@/api/fileserver/CloudEController";
import InputAdornment from '@mui/material/InputAdornment'; import usePass from "@/hooks/usePass";
import InputAdornment from "@mui/material/InputAdornment";
const AddFolder = (props: any) => { type IAddFolderProps = {
const { list, path, projectId, fileToken, refresh } = props; list: Array<any>;
path: string;
projectId: string;
fileToken: string;
refresh: any;
selectIds: Array<any>;
};
const AddFolder = (props: IAddFolderProps) => {
const { list, path, projectId, fileToken, refresh, selectIds } = props;
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
const isPass = usePass();
const Message = useMessage(); const Message = useMessage();
let addFolderDialogRef: any = React.createRef();
const [fileName, setFileName] = useState(""); const [fileName, setFileName] = useState("");
const [fileNameCheck, setFileNameCheck] = useState({ const [fileNameCheck, setFileNameCheck] = useState({
error: false, error: false,
help: "", help: "",
}); });
const showDialog = () => { useEffect(() => {
addFolderDialogRef.current.handleClickOpen(); if (deleteDialogOpen) {
initData() setFileName("");
};
const initData = () => {
setFileName('')
setFileNameCheck({ setFileNameCheck({
error: false, error: false,
help: "", help: "",
})
}
useImperativeHandle(props.onRef, () => {
return {
showDialog: showDialog,
};
}); });
}
}, [deleteDialogOpen]);
const handleAddSubmit = () => { const handleAddSubmit = () => {
if (fileName && !fileNameCheck.error) { if (fileName && !fileNameCheck.error) {
...@@ -47,15 +49,14 @@ const AddFolder = (props: any) => { ...@@ -47,15 +49,14 @@ const AddFolder = (props: any) => {
projectId projectId
)?.then((res) => { )?.then((res) => {
Message.success("新建成功"); Message.success("新建成功");
addFolderDialogRef.current.handleClose(); setDeleteDialogOpen(false);
refresh() refresh();
}); });
} else { } else {
Message.info(fileNameCheck.help || "请输入文件夹名称"); Message.info(fileNameCheck.help || "请输入文件夹名称");
} }
}; };
const addFolderSubmitloading = false;
const handleFileNameChange = (e: any) => { const handleFileNameChange = (e: any) => {
const fileName = e.target.value; const fileName = e.target.value;
setFileName(fileName); setFileName(fileName);
...@@ -89,11 +90,23 @@ const AddFolder = (props: any) => { ...@@ -89,11 +90,23 @@ const AddFolder = (props: any) => {
}; };
return ( return (
<>
<Button
color="neutral"
variant="outlined"
size="small"
onClick={() => setDeleteDialogOpen(true)}
disabled={
selectIds.length !== 0 || !isPass("PROJECT_DATA_ADDDIR", "USER")
}
>
新建文件夹
</Button>
<MyDialog <MyDialog
handleSubmit={handleAddSubmit} open={deleteDialogOpen}
onRef={addFolderDialogRef} onClose={() => setDeleteDialogOpen(false)}
onConfirm={handleAddSubmit}
title="新建文件夹" title="新建文件夹"
submitloading={addFolderSubmitloading}
> >
<TextField <TextField
sx={{ sx={{
...@@ -110,11 +123,16 @@ const AddFolder = (props: any) => { ...@@ -110,11 +123,16 @@ const AddFolder = (props: any) => {
onChange={handleFileNameChange} onChange={handleFileNameChange}
helperText={fileNameCheck.help} helperText={fileNameCheck.help}
InputProps={{ InputProps={{
endAdornment: <InputAdornment position="end">{fileName.length}/30</InputAdornment>, endAdornment: (
<InputAdornment position="end">
{fileName.length}/30
</InputAdornment>
),
}} }}
size="small" size="small"
/> />
</MyDialog> </MyDialog>
</>
); );
}; };
......
...@@ -37,6 +37,12 @@ ...@@ -37,6 +37,12 @@
font-weight: 600; font-weight: 600;
} }
.projectDataTabsAndBtton {
display: flex;
justify-content: flex-end;
align-items: center;
}
.folderIconBox { .folderIconBox {
display: flex; display: flex;
justify-content: flex-start; justify-content: flex-start;
......
...@@ -60,14 +60,12 @@ const ProjectData = observer(() => { ...@@ -60,14 +60,12 @@ const ProjectData = observer(() => {
/** 路由信息 */ /** 路由信息 */
const location = useLocation(); const location = useLocation();
// 当前文件路径 // 当前文件路径
const [path, setPath] = useState<String>("/"); const [path, setPath] = useState<string>("/");
const [tableLoadding, setTableLoadding] = useState(false);
// 防止用户连续点击文件夹造成路径显示错误 // 防止用户连续点击文件夹造成路径显示错误
const [debounce, setDebounce] = useState(false); const [debounce, setDebounce] = useState(false);
// 点击操作列中的按钮 会设置当前点击的文件 // 点击操作列中的按钮 会设置当前点击的文件
const [currentOperateFile, setCurrentOperateFile] = useState<any>(null); const [currentOperateFile, setCurrentOperateFile] = useState<any>(null);
// 文件file 数据集dataset // 文件file 数据集dataset
// const [activeTab, setActiveTab] = useState(1);
const [activeTab, setActiveTab] = useState("file"); const [activeTab, setActiveTab] = useState("file");
// 复选框选中的文件名称数组 // 复选框选中的文件名称数组
const [selectIds, setSelectIds] = useState<Array<string>>([]); const [selectIds, setSelectIds] = useState<Array<string>>([]);
...@@ -188,14 +186,12 @@ const ProjectData = observer(() => { ...@@ -188,14 +186,12 @@ const ProjectData = observer(() => {
return; return;
} else if (fileToken && projectId) { } else if (fileToken && projectId) {
if (fileServerEndPoint) { if (fileServerEndPoint) {
setTableLoadding(true);
return CloudEController.JobOutFileList( return CloudEController.JobOutFileList(
path, path,
fileToken, fileToken,
projectId, projectId,
false false
)?.then((res) => { )?.then((res) => {
setTableLoadding(false);
if (Array.isArray(res.data)) { if (Array.isArray(res.data)) {
setList(res.data); setList(res.data);
} else { } else {
...@@ -219,7 +215,6 @@ const ProjectData = observer(() => { ...@@ -219,7 +215,6 @@ const ProjectData = observer(() => {
getList(); getList();
} else { } else {
if (fileToken && projectId) { if (fileToken && projectId) {
setTableLoadding(true);
setPath("/"); setPath("/");
return CloudEController.JobSearchFileList( return CloudEController.JobSearchFileList(
keyWord, keyWord,
...@@ -228,7 +223,6 @@ const ProjectData = observer(() => { ...@@ -228,7 +223,6 @@ const ProjectData = observer(() => {
projectId, projectId,
false false
)?.then((res) => { )?.then((res) => {
setTableLoadding(false);
if (Array.isArray(res.data)) { if (Array.isArray(res.data)) {
setList(res.data); setList(res.data);
} else { } else {
...@@ -273,7 +267,6 @@ const ProjectData = observer(() => { ...@@ -273,7 +267,6 @@ const ProjectData = observer(() => {
} }
}; };
// todo name sort
// table配置 // table配置
const versionsHeadCells = useMemo(() => { const versionsHeadCells = useMemo(() => {
if (showCheckBox) { if (showCheckBox) {
...@@ -441,13 +434,6 @@ const ProjectData = observer(() => { ...@@ -441,13 +434,6 @@ const ProjectData = observer(() => {
UpLoaderFileRef.current.showDialog(); UpLoaderFileRef.current.showDialog();
}; };
// 新增文件
let addFolderRef: any = React.createRef();
const hanleShowAddFolderDialog = () => {
addFolderRef.current.showDialog();
};
// 下载文件 // 下载文件
const hanleDownloadFile = (item: any) => { const hanleDownloadFile = (item: any) => {
const downloadPath = const downloadPath =
...@@ -577,18 +563,14 @@ const ProjectData = observer(() => { ...@@ -577,18 +563,14 @@ const ProjectData = observer(() => {
> >
上传文件 上传文件
</Button> </Button>
<Button <AddFolder
color="neutral" selectIds={selectIds}
variant="outlined" list={allList}
size="small" path={path}
onClick={hanleShowAddFolderDialog} refresh={handleRefresh}
disabled={ fileToken={fileToken as string}
selectIds.length !== 0 || projectId={projectId as string}
!isPass("PROJECT_DATA_ADDDIR", "USER") ></AddFolder>
}
>
新建文件夹
</Button>
</div> </div>
<div className={style.projectDataSearch}> <div className={style.projectDataSearch}>
<InputBase <InputBase
...@@ -631,6 +613,7 @@ const ProjectData = observer(() => { ...@@ -631,6 +613,7 @@ const ProjectData = observer(() => {
size="small" size="small"
onClick={handleRefresh} onClick={handleRefresh}
disabled={!isPass("PROJECT_DATA_REFRESH", "USER")} disabled={!isPass("PROJECT_DATA_REFRESH", "USER")}
sx={{ marginLeft: "17px" }}
> >
<RefreshIcon /> <RefreshIcon />
</IconButton> </IconButton>
...@@ -643,7 +626,6 @@ const ProjectData = observer(() => { ...@@ -643,7 +626,6 @@ const ProjectData = observer(() => {
onRef={tableRef} onRef={tableRef}
nopadding={true} nopadding={true}
stickyheader={true} stickyheader={true}
load={tableLoadding}
initSelected={selectIds} initSelected={selectIds}
headCells={versionsHeadCells} headCells={versionsHeadCells}
rowsPerPage={"99"} rowsPerPage={"99"}
...@@ -704,14 +686,6 @@ const ProjectData = observer(() => { ...@@ -704,14 +686,6 @@ const ProjectData = observer(() => {
path={path} path={path}
list={allList} list={allList}
></UpLoaderFile> ></UpLoaderFile>
<AddFolder
onRef={addFolderRef}
list={allList}
path={path}
refresh={handleRefresh}
fileToken={fileToken}
projectId={projectId}
></AddFolder>
<MoveFile <MoveFile
onRef={moveFileRef} onRef={moveFileRef}
path={path} path={path}
......
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