diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 323c994914..ca201efe18 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -210,7 +210,6 @@ :scenario="data" :response="response" :currentScenario="currentScenario" - :currentEnvironmentId="currentEnvironmentId" :node="node" :project-list="projectList" :env-map="projectEnvMap" @@ -463,7 +462,6 @@ export default { ], }, environments: [], - currentEnvironmentId: "", maintainerOptions: [], value: API_STATUS[0].id, options: API_STATUS, @@ -1423,16 +1421,6 @@ export default { this.environments.forEach(environment => { parseEnvironment(environment); }); - let hasEnvironment = false; - for (let i in this.environments) { - if (this.environments[i].id === this.currentEnvironmentId) { - hasEnvironment = true; - break; - } - } - if (!hasEnvironment) { - this.currentEnvironmentId = ''; - } //检查场景是否需要先进行保存 this.checkDataIsCopy(); }); @@ -1576,7 +1564,6 @@ export default { if (response.data.scenarioDefinition != null) { let obj = JSON.parse(response.data.scenarioDefinition); if (obj) { - this.currentEnvironmentId = obj.environmentId; if (response.data.environmentJson) { this.projectEnvMap = objToStrMap(JSON.parse(response.data.environmentJson)); } else { diff --git a/frontend/src/business/components/api/automation/scenario/common/JDBCProcessorContent.vue b/frontend/src/business/components/api/automation/scenario/common/JDBCProcessorContent.vue index 343d814e9c..85aeca6825 100644 --- a/frontend/src/business/components/api/automation/scenario/common/JDBCProcessorContent.vue +++ b/frontend/src/business/components/api/automation/scenario/common/JDBCProcessorContent.vue @@ -99,7 +99,7 @@ export default { type: Boolean, default: true, }, - isScenario: String, + scenarioId: String, isReadOnly: { type: Boolean, default: false @@ -117,7 +117,7 @@ export default { } }, created() { - if (!this.isScenario) { + if (!this.scenarioId) { this.request.environmentId = this.$store.state.useEnvironment; } this.getEnvironments(); @@ -135,7 +135,7 @@ export default { deep: true }, '$store.state.useEnvironment': function () { - if (!this.isScenario) { + if (!this.scenarioId) { this.request.environmentId = this.$store.state.useEnvironment; this.getEnvironments(); } @@ -186,15 +186,15 @@ export default { getEnvironments() { let envId = ""; let id = this.request.projectId ? this.request.projectId : this.projectId; - let scenarioEnvId = this.isScenario ? (this.isScenario + "_" + id) : id; + let scenarioEnvId = this.scenarioId ? (this.scenarioId + "_" + id) : id; if (this.$store.state.scenarioEnvMap && this.$store.state.scenarioEnvMap instanceof Map && this.$store.state.scenarioEnvMap.has(scenarioEnvId)) { envId = this.$store.state.scenarioEnvMap.get(scenarioEnvId); } - if (this.request.referenced === 'Created' && this.isScenario && !this.request.isRefEnvironment) { + if (this.request.referenced === 'Created' && this.scenarioId && !this.request.isRefEnvironment) { this.itselfEnvironment(); return; - } else if (!this.isScenario && !this.request.customizeReq) { + } else if (!this.scenarioId && !this.request.customizeReq) { this.itselfEnvironment(); return; } 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 79781ef6c2..89497a4538 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue @@ -84,7 +84,7 @@ :isShowEnable="true" :response="response" :referenced="true" - :isScenario="currentScenario.id" + :scenarioId="currentScenario.id" :headers="request.headers " :is-read-only="isCompReadOnly" :request="request"/> @@ -101,21 +101,21 @@ :is-read-only="isCompReadOnly" :response="response" :show-pre-script="true" - :isScenario="currentScenario.id" + :scenarioId="currentScenario.id" :show-script="true" :request="request"/> @@ -196,7 +196,6 @@ export default { type: Boolean, default: true, }, - currentEnvironmentId: String, projectList: Array, envMap: Map, message: String, @@ -501,17 +500,18 @@ export default { this.reload(); }, run() { + let selectEnvId; + // 自定义请求 if (this.isApiImport || this.request.isRefEnvironment) { if (this.request.type && (this.request.type === "HTTPSamplerProxy" || this.request.type === "JDBCSampler" || this.request.type === "TCPSampler")) { - if (!this.environmentMap || this.environmentMap.size === 0) { + if (this.$store.state.scenarioEnvMap && this.$store.state.scenarioEnvMap instanceof Map + && this.$store.state.scenarioEnvMap.has((this.currentScenario.id + "_" + this.request.projectId))) { + selectEnvId = this.$store.state.scenarioEnvMap.get((this.currentScenario.id + "_" + this.request.projectId)); + this.environmentMap = this.envMap; + } + if (!selectEnvId) { this.$warning(this.$t('api_test.automation.env_message')); return false; - } else if (this.environmentMap && this.environmentMap.size > 0) { - const env = this.environmentMap.get(this.request.projectId); - if (!env) { - this.$warning(this.$t('api_test.automation.env_message')); - return false; - } } } } @@ -523,12 +523,15 @@ export default { this.request.active = true; this.loading = true; this.runData = []; - this.request.useEnvironment = this.currentEnvironmentId; + if (selectEnvId) { + this.request.useEnvironment = selectEnvId; + this.request.environmentId = selectEnvId; + } this.request.customizeReq = this.isCustomizeReq; let debugData = { id: this.currentScenario.id, name: this.currentScenario.name, type: "scenario", variables: this.currentScenario.variables, referenced: 'Created', headers: this.currentScenario.headers, - enableCookieShare: this.enableCookieShare, environmentId: this.currentEnvironmentId, hashTree: [this.request], + enableCookieShare: this.enableCookieShare, environmentId: selectEnvId, hashTree: [this.request], }; this.runData.push(debugData); this.request.requestResult = []; 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 2586e1500c..49a56892e5 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue @@ -93,7 +93,6 @@ export default { type: Boolean, default: false, }, - currentEnvironmentId: String, projectList: Array, environmentType: String, environmentGroupId: String, 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 1b2983690a..63f098a62b 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue @@ -14,7 +14,6 @@ :jsr223-processor="scenario" :request="scenario" :currentScenario="currentScenario" - :currentEnvironmentId="currentEnvironmentId" :node="node" :draggable="draggable" :title="title" @@ -97,7 +96,6 @@ export default { default: true, }, currentScenario: {}, - currentEnvironmentId: String, response: {}, node: {}, projectList: Array, diff --git a/frontend/src/business/components/api/automation/scenario/component/JDBCProcessor.vue b/frontend/src/business/components/api/automation/scenario/component/JDBCProcessor.vue index d66633f2b3..1d9d318ca3 100644 --- a/frontend/src/business/components/api/automation/scenario/component/JDBCProcessor.vue +++ b/frontend/src/business/components/api/automation/scenario/component/JDBCProcessor.vue @@ -15,7 +15,7 @@ @@ -35,7 +35,7 @@ export default { ApiBaseComponent, MsDropdown, MsInstructionsIcon, MsCodeEdit }, props: { - isScenario: String, + scenarioId: String, draggable: { type: Boolean, default: false, diff --git a/frontend/src/business/components/api/automation/scenario/component/LoopController.vue b/frontend/src/business/components/api/automation/scenario/component/LoopController.vue index ec010d7090..c460230a8e 100644 --- a/frontend/src/business/components/api/automation/scenario/component/LoopController.vue +++ b/frontend/src/business/components/api/automation/scenario/component/LoopController.vue @@ -1,7 +1,8 @@