diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 18bd0ca762..25caf7618a 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -149,7 +149,7 @@ @@ -300,7 +300,8 @@ export default { }, response: {}, projectIds: new Set, - projectEnvMap: new Map + projectEnvMap: new Map, + projectList: [] } }, created() { @@ -309,6 +310,7 @@ export default { } this.projectId = getCurrentProjectID(); this.operatingElements = ELEMENTS.get("ALL"); + this.getWsProjects(); this.getMaintainerOptions(); this.getApiScenario(); this.addListener(); // 添加 ctrl s 监听 @@ -1031,7 +1033,12 @@ export default { }, setProjectEnvMap(projectEnvMap) { this.projectEnvMap = projectEnvMap; - } + }, + getWsProjects() { + this.$get("/project/listAll", res => { + this.projectList = res.data; + }) + }, } } diff --git a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue index 8b8c8ca40e..2d8644c056 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue @@ -84,6 +84,7 @@ default: false, }, currentEnvironmentId: String, + projectList: Array }, components: { CustomizeReqInfo, @@ -96,7 +97,6 @@ reportId: "", runData: [], isShowInput: false, - projects: [] } }, created() { @@ -106,7 +106,6 @@ this.request.projectId = getCurrentProjectID(); // 加载引用对象数据 this.getApiInfo(); - this.getWsProjects(); if (this.request.protocol === 'HTTP') { this.setUrl(this.request.url); this.setUrl(this.request.path); @@ -279,17 +278,9 @@ this.loading = false }) }, - getWsProjects() { - this.$get("/project/listAll", res => { - this.projects = res.data; - }) - }, getProjectName(id) { - const project = this.projects.find(p => p.id === id); - if (project) { - return project.name; - } - return ''; + const project = this.projectList.find(p => p.id === id); + return project ? project.name : ""; } } } diff --git a/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue b/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue index 4b072a7bd9..9658c5a521 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue @@ -42,11 +42,13 @@ default: false, }, currentEnvironmentId: String, + projectList: Array }, watch: {}, created() { - this.getWsProjects(); - this.scenario.projectId = getCurrentProjectID(); + if (!this.scenario.projectId) { + this.scenario.projectId = getCurrentProjectID(); + } getProject.$emit('addProjectEnv', this.scenario.projectId, this.currentEnvironmentId); if (this.scenario.id && this.scenario.referenced === 'REF' && !this.scenario.loaded) { this.result = this.$get("/api/automation/getApiScenario/" + this.scenario.id, response => { @@ -76,7 +78,6 @@ return { loading: false, isShowInput: false, - projects: [] } }, computed: { @@ -122,17 +123,9 @@ } } }, - getWsProjects() { - this.$get("/project/listAll", res => { - this.projects = res.data; - }) - }, getProjectName(id) { - const project = this.projects.find(p => p.id === id); - if (project) { - return project.name; - } - return ''; + const project = this.projectList.find(p => p.id === id) ; + return project ? project.name : ""; } } } diff --git a/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue b/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue index e2375c5c8b..12ed422f4e 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue @@ -2,7 +2,7 @@
+ @remove="remove" @copyRow="copyRow" @refReload="refReload" :project-list="projectList"/>
@@ -28,6 +28,7 @@ currentEnvironmentId: String, response: {}, node: {}, + projectList: Array }, data() { return {