From 8ba7b8b704cb5837ba96fca8e29fc514586da9bb Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Tue, 8 Nov 2022 16:36:40 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=9D=83=E9=99=90=E7=9A=84case?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E6=97=B6=E6=8F=90=E7=A4=BA=E6=9C=AA=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E7=8E=AF=E5=A2=83=E7=9A=84=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1019502 --user=王孝刚 【接口测试】导入的场景-编辑保存运行环境后,列表中执行仍提示未选择运行环境 https://www.tapd.cn/55049933/s/1292309 --- .../scenario/component/ApiComponent.vue | 115 ++++++++++-------- api-test/frontend/src/i18n/lang/en-US.js | 3 + api-test/frontend/src/i18n/lang/zh-CN.js | 3 + api-test/frontend/src/i18n/lang/zh-TW.js | 3 + 4 files changed, 70 insertions(+), 54 deletions(-) diff --git a/api-test/frontend/src/business/automation/scenario/component/ApiComponent.vue b/api-test/frontend/src/business/automation/scenario/component/ApiComponent.vue index d9cdd3ebd2..7963f00e38 100644 --- a/api-test/frontend/src/business/automation/scenario/component/ApiComponent.vue +++ b/api-test/frontend/src/business/automation/scenario/component/ApiComponent.vue @@ -495,64 +495,71 @@ export default { run() { this.currentScenarioData = undefined; this.getParentVariables(this.node); - 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 (store.scenarioEnvMap && store.scenarioEnvMap instanceof Map - && store.scenarioEnvMap.has((this.currentScenario.id + "_" + this.request.projectId))) { - selectEnvId = store.scenarioEnvMap.get((this.currentScenario.id + "_" + this.request.projectId)); - this.environmentMap = this.envMap; + getOwnerProjectIds().then(res => { + const project = res.data.find(p => p === resource.projectId); + if (!project) { + this.$warning(this.$t('automation.project_no_permission')); + } else { + 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 (store.scenarioEnvMap && store.scenarioEnvMap instanceof Map + && store.scenarioEnvMap.has((this.currentScenario.id + "_" + this.request.projectId))) { + selectEnvId = store.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; + } + } } - if (!selectEnvId) { - this.$warning(this.$t('api_test.automation.env_message')); + if (!this.request.enable) { + this.$warning(this.$t('api_test.automation.debug_message')); return false; } + this.request.debug = true; + this.request.active = true; + this.loading = true; + this.runData = []; + if (selectEnvId) { + this.request.useEnvironment = selectEnvId; + this.request.environmentId = selectEnvId; + } + this.request.customizeReq = this.isCustomizeReq; + // 场景变量 + let variables = []; + if (this.currentScenario && this.currentScenario.variables) { + variables = JSON.parse(JSON.stringify(this.currentScenario.variables)); + } + let debugData = { + id: this.currentScenario.id, name: this.currentScenario.name, type: "scenario", + variables: variables, referenced: 'Created', headers: this.currentScenario.headers, + enableCookieShare: this.enableCookieShare, environmentId: selectEnvId, hashTree: [this.request], + }; + // 合并自身依赖场景变量 + if (this.currentScenarioData && this.currentScenarioData.variableEnable && this.currentScenarioData.variables) { + if (!debugData.variables || debugData.variables.length === 0) { + debugData.variables = this.currentScenarioData.variables; + } else if (this.currentScenarioData.variables) { + // 同名合并 + debugData.variables.forEach(data => { + this.currentScenarioData.variables.forEach(item => { + if (data.type === item.type && data.name === item.name) { + Object.assign(data, item); + } + }) + }); + } + } + this.runData.push(debugData); + this.request.requestResult = []; + this.request.result = undefined; + /*触发执行操作*/ + this.reportId = getUUID(); } - } - if (!this.request.enable) { - this.$warning(this.$t('api_test.automation.debug_message')); - return false; - } - this.request.debug = true; - this.request.active = true; - this.loading = true; - this.runData = []; - if (selectEnvId) { - this.request.useEnvironment = selectEnvId; - this.request.environmentId = selectEnvId; - } - this.request.customizeReq = this.isCustomizeReq; - // 场景变量 - let variables = []; - if (this.currentScenario && this.currentScenario.variables) { - variables = JSON.parse(JSON.stringify(this.currentScenario.variables)); - } - let debugData = { - id: this.currentScenario.id, name: this.currentScenario.name, type: "scenario", - variables: variables, referenced: 'Created', headers: this.currentScenario.headers, - enableCookieShare: this.enableCookieShare, environmentId: selectEnvId, hashTree: [this.request], - }; - // 合并自身依赖场景变量 - if (this.currentScenarioData && this.currentScenarioData.variableEnable && this.currentScenarioData.variables) { - if (!debugData.variables || debugData.variables.length === 0) { - debugData.variables = this.currentScenarioData.variables; - } else if (this.currentScenarioData.variables) { - // 同名合并 - debugData.variables.forEach(data => { - this.currentScenarioData.variables.forEach(item => { - if (data.type === item.type && data.name === item.name) { - Object.assign(data, item); - } - }) - }); - } - } - this.runData.push(debugData); - this.request.requestResult = []; - this.request.result = undefined; - /*触发执行操作*/ - this.reportId = getUUID(); + }) }, getParentVariables(node) { if (!this.currentScenarioData) { diff --git a/api-test/frontend/src/i18n/lang/en-US.js b/api-test/frontend/src/i18n/lang/en-US.js index ceb3d40b8b..6a21b98235 100644 --- a/api-test/frontend/src/i18n/lang/en-US.js +++ b/api-test/frontend/src/i18n/lang/en-US.js @@ -48,6 +48,9 @@ const message = { relation_case: "Relation CASE", relation_scenario: "Relation Scenario" }, + }, + automation:{ + project_no_permission: "The current person does not have the operation permission for this step", } } export default { diff --git a/api-test/frontend/src/i18n/lang/zh-CN.js b/api-test/frontend/src/i18n/lang/zh-CN.js index ab33b8c999..17c68db070 100644 --- a/api-test/frontend/src/i18n/lang/zh-CN.js +++ b/api-test/frontend/src/i18n/lang/zh-CN.js @@ -48,6 +48,9 @@ const message = { relation_case: "关联CASE", relation_scenario: "关联场景" }, + }, + automation:{ + project_no_permission: "当前操作人无此步骤的操作权限", } } diff --git a/api-test/frontend/src/i18n/lang/zh-TW.js b/api-test/frontend/src/i18n/lang/zh-TW.js index 847aae9618..5155637b23 100644 --- a/api-test/frontend/src/i18n/lang/zh-TW.js +++ b/api-test/frontend/src/i18n/lang/zh-TW.js @@ -48,6 +48,9 @@ const message = { relation_case: "關聯CASE", relation_scenario: "關聯場景" }, + }, + automation:{ + project_no_permission: "當前人操作無此步驟的操作權限", } }