diff --git a/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java b/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java index a63fe9b120..955b80b97b 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java @@ -493,7 +493,9 @@ public class TestPlanScenarioCaseService { if (envMap != null && !envMap.isEmpty()) { List list = mapping.get(id); list.forEach(l -> { - newEnvMap.put(l, envMap.get(l)); + if (envMap.containsKey(l) && StringUtils.isNotBlank(envMap.get(l))) { + newEnvMap.put(l, envMap.get(l)); + } }); } if (!newEnvMap.isEmpty()) { diff --git a/test-track/frontend/src/business/plan/env/EnvSelect.vue b/test-track/frontend/src/business/plan/env/EnvSelect.vue index 5f3ef3d194..ef1034c617 100644 --- a/test-track/frontend/src/business/plan/env/EnvSelect.vue +++ b/test-track/frontend/src/business/plan/env/EnvSelect.vue @@ -160,23 +160,19 @@ export default { }, handleConfirm() { let map = new Map(); - let sign = true; let projectEnvDesc = {}; + let selectEnv = this.data.filter((dt) => dt.selectEnv); + if (selectEnv.length === 0) { + this.$warning("请为当前场景选择一个运行环境!"); + return false; + } this.data.forEach((dt) => { - if (!dt.selectEnv) { - sign = false; - return; - } map.set(dt.id, dt.selectEnv); let filteredEnv = dt.envs.filter((e) => e.id === dt.selectEnv); if (filteredEnv.length > 0) { projectEnvDesc[this.getProjectName(dt.id)] = filteredEnv[0].name; } }); - if (!sign) { - this.$warning("请为当前场景选择一个运行环境!"); - return; - } this.$emit("setProjectEnvMap", map, projectEnvDesc); this.$emit("close"); }, @@ -199,15 +195,8 @@ export default { return false; } }); - } else { - sign = false; } } - - if (!sign) { - this.$warning("请为当前场景选择一个运行环境!"); - return false; - } return true; }, environmentConfigClose() {