Commit a426fddc authored by chenshouchao's avatar chenshouchao

fix: 当前项目高亮通过ID判断, 新增项目增加loading

parent df2eeacb
......@@ -42,6 +42,7 @@ const AddProject = (props: IAddProjectProps) => {
});
const [zoneId, setZoneId] = useState("");
const [zoneIdOptions, setZoneIdOptions] = useState<Array<zoneIdOption>>([]);
const [loading, setLoading] = useState(false);
// 设置计算区
const { run } = useMyRequest(hpczone, {
......@@ -51,9 +52,13 @@ const AddProject = (props: IAddProjectProps) => {
},
});
const { run: addProjectRun } = useMyRequest(addProject, {
onBefore: () => {
setLoading(true);
},
onSuccess: async (result: any) => {
if (result.data) {
setAddOpen(false);
setLoading(false);
message.success("新建项目成功");
const projectList = await getProjectList();
currentProjectStore.setProjectList(projectList);
......@@ -72,7 +77,7 @@ const AddProject = (props: IAddProjectProps) => {
}
},
onError: () => {
setAddOpen(false);
setLoading(false);
},
});
......@@ -84,6 +89,7 @@ const AddProject = (props: IAddProjectProps) => {
if (addOpen) {
setName("");
setDesc("");
setLoading(false);
if (zoneIdOptions.length > 0) {
setZoneId(zoneIdOptions[0].id);
}
......@@ -166,6 +172,7 @@ const AddProject = (props: IAddProjectProps) => {
onConfirm={handleSubmit}
onClose={() => setAddOpen(false)}
title="新建项目"
loading={loading}
>
<div className={style.formBox} onClick={handleFromBox}>
<MyInput
......
......@@ -14,7 +14,7 @@ const ProjectListPopper = observer((props: any) => {
const { handleChangeCurrentProject, handleClickOpen } = props;
const { currentProjectStore } = useStores();
const projectList = toJS(currentProjectStore.projectList);
const currentProjectName = toJS(currentProjectStore.currentProjectInfo.name);
const currentProjectId = toJS(currentProjectStore.currentProjectInfo.id);
// 通过名称本地搜索
const [name, setName] = useState("");
const nameChange = (e: any) => {
......@@ -66,7 +66,7 @@ const ProjectListPopper = observer((props: any) => {
<div
className={classNames({
[style.projectli]: true,
[style.projectliActive]: item.name === currentProjectName,
[style.projectliActive]: item.id === currentProjectId,
})}
key={item.id}
onClick={() => handleChangeCurrentProject(item)}
......
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