Commit 73134aed authored by chenshouchao's avatar chenshouchao

feat: 完成新建文件夹功能

parent af103dad
...@@ -3577,6 +3577,11 @@ ...@@ -3577,6 +3577,11 @@
"resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz",
"integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==" "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg=="
}, },
"attr-accept": {
"version": "2.2.2",
"resolved": "https://registry.npmmirror.com/attr-accept/-/attr-accept-2.2.2.tgz",
"integrity": "sha512-7prDjvt9HmqiZ0cl5CRjtS84sEyhsHP2coDkaZKRKVfCDo9s7iw7ChVmar78Gu9pC4SoR/28wFu/G5JJhTnqEg=="
},
"autoprefixer": { "autoprefixer": {
"version": "10.4.7", "version": "10.4.7",
"resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.7.tgz", "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.7.tgz",
...@@ -5749,6 +5754,14 @@ ...@@ -5749,6 +5754,14 @@
"schema-utils": "^3.0.0" "schema-utils": "^3.0.0"
} }
}, },
"file-selector": {
"version": "0.6.0",
"resolved": "https://registry.npmmirror.com/file-selector/-/file-selector-0.6.0.tgz",
"integrity": "sha512-QlZ5yJC0VxHxQQsQhXvBaC7VRJ2uaxTf+Tfpu4Z/OcVQJVpZO+DGU0rkoVW5ce2SccxugvpBJoMvUs59iILYdw==",
"requires": {
"tslib": "^2.4.0"
}
},
"filelist": { "filelist": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.3.tgz", "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.3.tgz",
...@@ -10109,6 +10122,16 @@ ...@@ -10109,6 +10122,16 @@
"scheduler": "^0.22.0" "scheduler": "^0.22.0"
} }
}, },
"react-dropzone": {
"version": "14.2.1",
"resolved": "https://registry.npmmirror.com/react-dropzone/-/react-dropzone-14.2.1.tgz",
"integrity": "sha512-jzX6wDtAjlfwZ+Fbg+G17EszWUkQVxhMTWMfAC9qSUq7II2pKglHA8aarbFKl0mLpRPDaNUcy+HD/Sf4gkf76Q==",
"requires": {
"attr-accept": "^2.2.2",
"file-selector": "^0.6.0",
"prop-types": "^15.8.1"
}
},
"react-error-overlay": { "react-error-overlay": {
"version": "6.0.11", "version": "6.0.11",
"resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.11.tgz", "resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.11.tgz",
...@@ -11681,7 +11704,7 @@ ...@@ -11681,7 +11704,7 @@
}, },
"webpack-dev-server": { "webpack-dev-server": {
"version": "4.9.0", "version": "4.9.0",
"resolved": "https://registry.npmjs.org/webpack-dev-server/-/webpack-dev-server-4.9.0.tgz", "resolved": "https://registry.npmmirror.com/webpack-dev-server/-/webpack-dev-server-4.9.0.tgz",
"integrity": "sha512-+Nlb39iQSOSsFv0lWUuUTim3jDQO8nhK3E68f//J2r5rIcp4lULHXz2oZ0UVdEeWXEh5lSzYUlzarZhDAeAVQw==", "integrity": "sha512-+Nlb39iQSOSsFv0lWUuUTim3jDQO8nhK3E68f//J2r5rIcp4lULHXz2oZ0UVdEeWXEh5lSzYUlzarZhDAeAVQw==",
"requires": { "requires": {
"@types/bonjour": "^3.5.9", "@types/bonjour": "^3.5.9",
......
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
"react-app-polyfill": "^3.0.0", "react-app-polyfill": "^3.0.0",
"react-dev-utils": "^12.0.1", "react-dev-utils": "^12.0.1",
"react-dom": "^18.1.0", "react-dom": "^18.1.0",
"react-dropzone": "^14.2.1",
"react-refresh": "^0.11.0", "react-refresh": "^0.11.0",
"react-router-dom": "^6.3.0", "react-router-dom": "^6.3.0",
"resolve": "^1.20.0", "resolve": "^1.20.0",
......
...@@ -52,12 +52,13 @@ const MyDialog = (props: any) => { ...@@ -52,12 +52,13 @@ const MyDialog = (props: any) => {
<CloseIcon style={{ color: "#C2C6CC" }} /> <CloseIcon style={{ color: "#C2C6CC" }} />
</IconButton> </IconButton>
</DialogContent> </DialogContent>
<DialogActions style={{ padding: "24px" }}> <DialogActions style={{ padding: "16px 24px" }}>
<Button <Button
onClick={handleClose} onClick={handleClose}
color="inherit" color="inherit"
variant="contained" variant="contained"
style={{ color: "#1E2633", backgroundColor: "#fff" }} style={{ color: "#1E2633", backgroundColor: "#fff" }}
size="small"
> >
取消 取消
</Button> </Button>
...@@ -67,6 +68,7 @@ const MyDialog = (props: any) => { ...@@ -67,6 +68,7 @@ const MyDialog = (props: any) => {
color="primary" color="primary"
variant="contained" variant="contained"
style={submitStyle} style={submitStyle}
size="small"
> >
确认 确认
</LoadingButton> </LoadingButton>
......
...@@ -6,14 +6,18 @@ ...@@ -6,14 +6,18 @@
* @FilePath: /bkunyun/src/utils/util.ts * @FilePath: /bkunyun/src/utils/util.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
export const isProjectOwner = (name: string)=>{ export const isProjectOwner = (name: string) => {
let localName ='' let localName = "";
try{ try {
localName = JSON.parse( localName = JSON.parse(localStorage.getItem("userInfo") || "{}")?.name;
localStorage.getItem("userInfo") || "{}"
)?.name
} catch { } catch {
console.error('获取localStorage出错') console.error("获取localStorage出错");
} }
return localName === name return localName === name;
} };
\ No newline at end of file
const IsNumberLetterChineseReg = new RegExp("^[A-Za-z0-9\u4e00-\u9fa5]+$");
export const checkIsNumberLetterChinese = (string: string) => {
return IsNumberLetterChineseReg.test(string);
};
import React, { useState, useImperativeHandle } from "react";
import { TextField } from "@mui/material";
import MyDialog from "@/components/mui/MyDialog";
import { checkIsNumberLetterChinese } from "@/utils/util";
import { useMessage } from "@/components/MySnackbar";
const AddFolder = (props: any) => {
const { list } = props;
const Message = useMessage();
let addFolderDialogRef: any = React.createRef();
const showDialog = () => {
addFolderDialogRef.current.handleClickOpen();
};
useImperativeHandle(props.onRef, () => {
return {
showDialog: showDialog,
};
});
const handleAddSubmit = () => {
if (fileName && !fileNameCheck.error) {
// 请求接口
} else {
Message.info(fileNameCheck.help || "请输入文件夹名称");
}
};
const addFolderSubmitloading = false;
const [fileName, setFileName] = useState("");
const [fileNameCheck, setFileNameCheck] = useState({
error: false,
help: "",
});
const handleFileNameChange = (e: any) => {
const fileName = e.target.value;
setFileName(fileName);
// 1.“格式不正确,必须在30字符以内,仅限大小写字母、数字、中文”
// 2. “文件夹名称不能为空”
// 3. “已存在同名文件夹”
if (!fileName) {
setFileNameCheck({
error: true,
help: "文件夹名称不能为空",
});
} else if (!checkIsNumberLetterChinese(fileName) || fileName.length > 30) {
setFileNameCheck({
error: true,
help: "格式不正确,必须在30字符以内,仅限大小写字母、数字、中文",
});
} else if (isRepeat(fileName)) {
setFileNameCheck({
error: true,
help: "已存在同名文件夹",
});
} else {
setFileNameCheck({
error: false,
help: "",
});
}
};
const isRepeat = (fileName: string) => {
return list.some((item: any) => {
return item.name === fileName;
});
};
return (
<MyDialog
handleSubmit={handleAddSubmit}
onRef={addFolderDialogRef}
title="新建文件夹"
submitloading={addFolderSubmitloading}
>
<TextField
sx={{
width: "388px",
border: "1px solide #E6E8EB",
marginTop: "12px",
}}
required
error={fileNameCheck.error}
id="fileName"
label="名称"
variant="outlined"
value={fileName}
onChange={handleFileNameChange}
helperText={fileNameCheck.help}
size="small"
/>
</MyDialog>
);
};
export default AddFolder;
import React, { useState, useImperativeHandle } from "react";
import { TextField } from "@mui/material";
import MyDialog from "@/components/mui/MyDialog";
import { checkIsNumberLetterChinese } from "@/utils/util";
import { useMessage } from "@/components/MySnackbar";
const UpLoaderFolder = (props: any) => {
const { path } = props;
const submitloading = false;
let dialogRef: any = React.createRef();
const handleSubmit = () => {
console.log("handleSubmit");
};
const showDialog = () => {
dialogRef.current.handleClickOpen();
};
useImperativeHandle(props.onRef, () => {
return {
showDialog: showDialog,
};
});
const handleFileChange = (e: any) => {
console.log(e);
};
return (
<MyDialog
handleSubmit={handleSubmit}
onRef={dialogRef}
title="上传文件"
submitloading={submitloading}
>
<input onChange={(e) => handleFileChange(e)} type="file" multiple />
</MyDialog>
);
};
export default UpLoaderFolder;
...@@ -80,8 +80,8 @@ ...@@ -80,8 +80,8 @@
.projectDataStickyBox { .projectDataStickyBox {
height: 64px; height: 64px;
position: sticky; position: sticky;
bottom: 0; bottom: -1px;
border-top: 1px solid #ebedf0; border: 1px solid #ebedf0;
z-index: 100; z-index: 100;
background-color: #fff; background-color: #fff;
display: flex; display: flex;
......
import React, { useState } from "react"; import React, { useState, useCallback } from "react";
import style from "./index.module.css"; import style from "./index.module.css";
import classnames from "classnames"; import classnames from "classnames";
import { Button, InputBase, IconButton } from "@mui/material"; import { Button, InputBase, IconButton, TextField } from "@mui/material";
import { createTheme, ThemeProvider } from "@mui/material/styles"; import { createTheme, ThemeProvider } from "@mui/material/styles";
import SearchIcon from "@mui/icons-material/Search"; import SearchIcon from "@mui/icons-material/Search";
import RefreshIcon from "@mui/icons-material/Refresh"; import RefreshIcon from "@mui/icons-material/Refresh";
...@@ -12,6 +12,12 @@ import dataSetIcon from "@/assets/project/dataSetIcon.svg"; ...@@ -12,6 +12,12 @@ import dataSetIcon from "@/assets/project/dataSetIcon.svg";
import fileIcon from "@/assets/project/fileIcon.svg"; import fileIcon from "@/assets/project/fileIcon.svg";
import folderIcon from "@/assets/project/folderIcon.svg"; import folderIcon from "@/assets/project/folderIcon.svg";
import noFile from "@/assets/project/noFile.svg"; import noFile from "@/assets/project/noFile.svg";
import MyDialog from "@/components/mui/MyDialog";
import { checkIsNumberLetterChinese } from "@/utils/util";
import { useMessage } from "@/components/MySnackbar";
import AddFolder from "./AddFolder";
import UpLoaderFolder from "./UpLoaderFolder";
const theme = createTheme({ const theme = createTheme({
palette: { palette: {
neutral: { neutral: {
...@@ -49,7 +55,7 @@ const ProjectData = () => { ...@@ -49,7 +55,7 @@ const ProjectData = () => {
const [selectIds, setSelectIds] = useState([]); const [selectIds, setSelectIds] = useState([]);
const list = [ const [list, setList] = useState([
{ {
id: 123, id: 123,
name: "name", name: "name",
...@@ -63,7 +69,7 @@ const ProjectData = () => { ...@@ -63,7 +69,7 @@ const ProjectData = () => {
size: 6, size: 6,
mtime: new Date().getTime(), mtime: new Date().getTime(),
}, },
]; ]);
const versionsHeadCells = [ const versionsHeadCells = [
{ id: "checkbox" }, { id: "checkbox" },
...@@ -107,19 +113,43 @@ const ProjectData = () => { ...@@ -107,19 +113,43 @@ const ProjectData = () => {
const renderButtons = (item: any) => { const renderButtons = (item: any) => {
return ( return (
<span> <span>
<Button sx={{position: 'relative', left: '-18px'}} variant="text" size="small"> <Button
sx={{ position: "relative", left: "-18px" }}
variant="text"
size="small"
>
下载 下载
</Button> </Button>
<Button sx={{position: 'relative', left: '-18px'}} variant="text" size="small"> <Button
sx={{ position: "relative", left: "-18px" }}
variant="text"
size="small"
>
移动至 移动至
</Button> </Button>
<Button sx={{position: 'relative', left: '-18px'}} variant="text" size="small" color="error"> <Button
sx={{ position: "relative", left: "-18px" }}
variant="text"
size="small"
color="error"
>
删除 删除
</Button> </Button>
</span> </span>
); );
}; };
let uploaderFolderRef: any = React.createRef();
const hanleShowUploaderFolderDialog = () => {
uploaderFolderRef.current.showDialog();
};
let addFolderRef: any = React.createRef();
const hanleShowAddFolderDialog = () => {
addFolderRef.current.showDialog();
};
return ( return (
<ThemeProvider theme={theme}> <ThemeProvider theme={theme}>
<div className={style.projectData}> <div className={style.projectData}>
...@@ -133,10 +163,16 @@ const ProjectData = () => { ...@@ -133,10 +163,16 @@ const ProjectData = () => {
variant="contained" variant="contained"
size="small" size="small"
style={{ marginRight: "12px" }} style={{ marginRight: "12px" }}
onClick={hanleShowUploaderFolderDialog}
> >
上传文件 上传文件
</Button> </Button>
<Button color="neutral" variant="outlined" size="small"> <Button
color="neutral"
variant="outlined"
size="small"
onClick={hanleShowAddFolderDialog}
>
新建文件夹 新建文件夹
</Button> </Button>
</div> </div>
...@@ -232,6 +268,8 @@ const ProjectData = () => { ...@@ -232,6 +268,8 @@ const ProjectData = () => {
</Button> </Button>
</div> </div>
)} )}
<UpLoaderFolder onRef={uploaderFolderRef} path={path}></UpLoaderFolder>
<AddFolder onRef={addFolderRef} list={list}></AddFolder>
</div> </div>
</ThemeProvider> </ThemeProvider>
); );
......
...@@ -27,8 +27,7 @@ import { useMessage } from "@/components/MySnackbar"; ...@@ -27,8 +27,7 @@ import { useMessage } from "@/components/MySnackbar";
import Loading from "@/views/Loading"; import Loading from "@/views/Loading";
import MyDialog from "@/components/mui/MyDialog"; import MyDialog from "@/components/mui/MyDialog";
import { getProjectList } from "../../project"; import { getProjectList } from "../../project";
import { checkIsNumberLetterChinese } from "@/utils/util";
const reg = new RegExp("^[A-Za-z0-9\u4e00-\u9fa5]+$");
type zoneIdOption = { type zoneIdOption = {
id: string; id: string;
...@@ -127,7 +126,7 @@ const BaseInfo = observer(() => { ...@@ -127,7 +126,7 @@ const BaseInfo = observer(() => {
// 修改项目 // 修改项目
const handleClickUpdate = () => { const handleClickUpdate = () => {
if (projectInfo.name) { if (projectInfo.name) {
if (reg.test(projectInfo.name)) { if (checkIsNumberLetterChinese(projectInfo.name)) {
updateProjectRun({ ...projectInfo, product: "CADD" }); updateProjectRun({ ...projectInfo, product: "CADD" });
} else { } else {
message.info( message.info(
......
...@@ -7,8 +7,7 @@ import { hpczone, addProject } from "@/api/project_api"; ...@@ -7,8 +7,7 @@ import { hpczone, addProject } from "@/api/project_api";
import { useMessage } from "@/components/MySnackbar"; import { useMessage } from "@/components/MySnackbar";
import { getProjectList } from "../../project"; import { getProjectList } from "../../project";
import { useStores } from "@/store"; import { useStores } from "@/store";
import { checkIsNumberLetterChinese } from "@/utils/util";
const reg = new RegExp("^[A-Za-z0-9\u4e00-\u9fa5]+$");
type zoneIdOption = { type zoneIdOption = {
id: string; id: string;
...@@ -79,7 +78,7 @@ const AddProject = (props: any) => { ...@@ -79,7 +78,7 @@ const AddProject = (props: any) => {
error: true, error: true,
help: "格式不正确,必须在30字符以内,仅限大小写字母、数字、中文", help: "格式不正确,必须在30字符以内,仅限大小写字母、数字、中文",
}); });
} else if (reg.test(name)) { } else if (checkIsNumberLetterChinese(name)) {
setNameCheck({ setNameCheck({
error: false, error: false,
help: "", help: "",
...@@ -159,6 +158,7 @@ const AddProject = (props: any) => { ...@@ -159,6 +158,7 @@ const AddProject = (props: any) => {
value={name} value={name}
onChange={handleNameChange} onChange={handleNameChange}
helperText={nameCheck.help} helperText={nameCheck.help}
size="small"
/> />
<TextField <TextField
id="zoneId" id="zoneId"
...@@ -169,6 +169,7 @@ const AddProject = (props: any) => { ...@@ -169,6 +169,7 @@ const AddProject = (props: any) => {
onChange={handleZoneIdChange} onChange={handleZoneIdChange}
variant="outlined" variant="outlined"
onClick={handleFromBox} onClick={handleFromBox}
size="small"
> >
{zoneIdOptions && {zoneIdOptions &&
zoneIdOptions.map((option) => ( zoneIdOptions.map((option) => (
...@@ -187,6 +188,7 @@ const AddProject = (props: any) => { ...@@ -187,6 +188,7 @@ const AddProject = (props: any) => {
placeholder="请输入项目描述" placeholder="请输入项目描述"
onChange={handleDescChange} onChange={handleDescChange}
helperText={descCheck.help} helperText={descCheck.help}
size="small"
/> />
</div> </div>
</MyDialog> </MyDialog>
......
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