From 7fa1011ffd0dcd458685298e1478b69d06af3a1c Mon Sep 17 00:00:00 2001 From: dengqichen Date: Fri, 10 Jan 2025 16:02:58 +0800 Subject: [PATCH] 1 --- .../List/components/ApplicationModal.tsx | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/frontend/src/pages/Deploy/Application/List/components/ApplicationModal.tsx b/frontend/src/pages/Deploy/Application/List/components/ApplicationModal.tsx index 9cc6cca5..6fcbb907 100644 --- a/frontend/src/pages/Deploy/Application/List/components/ApplicationModal.tsx +++ b/frontend/src/pages/Deploy/Application/List/components/ApplicationModal.tsx @@ -105,6 +105,7 @@ const ApplicationModal: React.FC = ({ useEffect(() => { if (initialValues) { + // 设置表单初始值 form.reset({ appCode: initialValues.appCode, appName: initialValues.appName, @@ -112,17 +113,23 @@ const ApplicationModal: React.FC = ({ language: initialValues.language, enabled: initialValues.enabled, sort: initialValues.sort, + projectGroupId: initialValues.projectGroupId, externalSystemId: initialValues.externalSystemId, repoGroupId: initialValues.repoGroupId, - repoProjectId: initialValues.repoProjectId, - projectGroupId: initialValues.projectGroupId, + repoProjectId: initialValues.repoProjectId }); - const externalSystem = externalSystems.find(system => system.id === initialValues.externalSystemId); - if (externalSystem) { - setSelectedExternalSystem(externalSystem); + + // 如果有外部系统ID,加载仓库组 + if (initialValues.externalSystemId) { + fetchRepositoryGroups(initialValues.externalSystemId); + } + + // 如果有仓库组ID,加载仓库项目 + if (initialValues.repoGroupId) { + fetchRepositoryProjects(initialValues.repoGroupId); } } - }, [initialValues, form, externalSystems]); + }, [initialValues]); // 当选择外部系统时,获取对应的仓库组列表 const handleExternalSystemChange = (externalSystemId: number) => { @@ -412,7 +419,7 @@ const ApplicationModal: React.FC = ({ > {field.value ? repositoryProjects.find( - (project) => project.projectId === field.value + (project) => project.id === field.value )?.name : !form.watch('repoGroupId') ? "请先选择代码仓库组" @@ -441,13 +448,13 @@ const ApplicationModal: React.FC = ({ ) : ( filteredProjects.map((project) => (
{ - form.setValue("repoProjectId", project.projectId); + form.setValue("repoProjectId", project.id); setSearchValue(""); setOpen(false); }} @@ -459,7 +466,7 @@ const ApplicationModal: React.FC = ({ }} > {project.name} - {project.projectId === field.value && ( + {project.id === field.value && ( )}