Commit f213250b authored by chenshouchao's avatar chenshouchao

feat: 优化基础信息修改提示

parent cac0bab4
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
outline: none; outline: none;
} }
.projectInfoListLiValue:focus { .projectInfoListLiValue:focus {
border: 1px solid #136efa; border: 2px solid #136efa;
} }
.projectInfoTextarea { .projectInfoTextarea {
line-height: 22px; line-height: 22px;
......
...@@ -21,7 +21,7 @@ import { toJS } from "mobx"; ...@@ -21,7 +21,7 @@ import { toJS } from "mobx";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
import InformationDisplay from "@/components/InformationDisplay"; import InformationDisplay from "@/components/InformationDisplay";
import classnames from "classnames"; import classnames from "classnames";
import { Button } from "@mui/material"; import { Button, TextField } from "@mui/material";
import LoadingButton from "@mui/lab/LoadingButton"; import LoadingButton from "@mui/lab/LoadingButton";
import { useMessage } from "@/components/MySnackbar"; import { useMessage } from "@/components/MySnackbar";
import Loading from "@/views/Loading"; import Loading from "@/views/Loading";
...@@ -40,6 +40,10 @@ const BaseInfo = observer(() => { ...@@ -40,6 +40,10 @@ const BaseInfo = observer(() => {
const { currentProjectStore } = useStores(); const { currentProjectStore } = useStores();
const [projectInfo, setProjectInfo] = useState<any>({}); const [projectInfo, setProjectInfo] = useState<any>({});
const [deleteProjectName, setDeleteProjectName] = useState(""); const [deleteProjectName, setDeleteProjectName] = useState("");
const [nameCheck, setNameCheck] = useState({
error: false,
help: "",
});
const currentUserName = JSON.parse( const currentUserName = JSON.parse(
localStorage.getItem("userInfo") || "{}" localStorage.getItem("userInfo") || "{}"
).name; ).name;
...@@ -98,11 +102,50 @@ const BaseInfo = observer(() => { ...@@ -98,11 +102,50 @@ const BaseInfo = observer(() => {
]; ];
}, [projectInfo, zoneIdMap]); }, [projectInfo, zoneIdMap]);
const checkName = (name: string, showMessage = false) => {
let help = "";
if (name) {
if (name.length > 30) {
help = "格式不正确,必须在30字符以内,仅限大小写字母、数字、中文";
setNameCheck({
error: true,
help,
});
showMessage && message.error(help);
return false;
} else if (checkIsNumberLetterChinese(name)) {
setNameCheck({
error: false,
help: "",
});
return true;
} else {
help = "格式不正确,必须在30字符以内,仅限大小写字母、数字、中文";
setNameCheck({
error: true,
help,
});
showMessage && message.error(help);
return false;
}
} else {
help = "项目名称不能为空";
setNameCheck({
error: true,
help,
});
showMessage && message.error(help);
return false;
}
};
const nameChange = (e: any) => { const nameChange = (e: any) => {
setProjectInfo({ setProjectInfo({
...projectInfo, ...projectInfo,
name: e.target.value, name: e.target.value,
}); });
checkName(e.target.value);
// setNameCheck
}; };
const descChange = (e: any) => { const descChange = (e: any) => {
...@@ -126,16 +169,10 @@ const BaseInfo = observer(() => { ...@@ -126,16 +169,10 @@ const BaseInfo = observer(() => {
// 修改项目 // 修改项目
const handleClickUpdate = () => { const handleClickUpdate = () => {
if (projectInfo.name) { if (checkName(projectInfo.name, true)) {
if (checkIsNumberLetterChinese(projectInfo.name)) { updateProjectRun({ ...projectInfo, product: "CADD" });
updateProjectRun({ ...projectInfo, product: "CADD" });
} else {
message.info(
"格式不正确,必须在30字符以内,仅限大小写字母、数字、中文"
);
}
} else { } else {
message.info("项目名称不能为空"); return;
} }
}; };
...@@ -195,13 +232,26 @@ const BaseInfo = observer(() => { ...@@ -195,13 +232,26 @@ const BaseInfo = observer(() => {
> >
项目名称 项目名称
</div> </div>
<input <TextField
required
error={nameCheck.error}
id="name"
variant="outlined"
value={projectInfo.name}
onChange={nameChange}
helperText={nameCheck.help}
size="small"
sx={{
width: "560px",
}}
/>
{/* <input
value={projectInfo.name} value={projectInfo.name}
className={style.projectInfoListLiValue} className={style.projectInfoListLiValue}
onChange={nameChange} onChange={nameChange}
maxLength={30} maxLength={30}
placeholder="请输入项目名称" placeholder="请输入项目名称"
></input> ></input> */}
</div> </div>
<div className={style.projectInfoListLi}> <div className={style.projectInfoListLi}>
<div className={style.projectInfoListLiLabel}>项目描述</div> <div className={style.projectInfoListLiLabel}>项目描述</div>
......
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