From b9586a2b5db749ab3f1bf6428748b7c6f739037c Mon Sep 17 00:00:00 2001 From: q4speed Date: Thu, 16 Jul 2020 13:09:40 +0800 Subject: [PATCH 1/2] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/test/model/ScenarioModel.js | 48 ++++++++----------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/frontend/src/business/components/api/test/model/ScenarioModel.js b/frontend/src/business/components/api/test/model/ScenarioModel.js index afa0c5b2ca..19f8d1a21b 100644 --- a/frontend/src/business/components/api/test/model/ScenarioModel.js +++ b/frontend/src/business/components/api/test/model/ScenarioModel.js @@ -400,12 +400,12 @@ class JMXRequest { this.pathname = decodeURIComponent(url.pathname); this.port = url.port; this.protocol = url.protocol.split(":")[0]; - this.pathname = this.getPostQueryParameters(request, this.pathname); + this.pathname = this.getPostQueryParameters(request, this.pathname); } else { this.environment = request.environment; this.port = request.environment.port; this.path = decodeURIComponent(request.path); - this.path = this.getPostQueryParameters(request, this.path); + this.path = this.getPostQueryParameters(request, this.path); } } } @@ -485,22 +485,26 @@ class JMXGenerator { }) } - addScenarioVariables(threadGroup, scenario) { - let scenarioVariableKeys = new Set(); - scenario.variables.forEach(item => { - scenarioVariableKeys.add(item.name); + addEnvironments(environments, target) { + let keys = new Set(); + target.forEach(item => { + keys.add(item.name); }); + let envArray = environments; + if (!(envArray instanceof Array)) { + envArray = JSON.parse(environments); + envArray.forEach(item => { + if (item.name && !keys.has(item.name)) { + target.push(new KeyValue(item.name, item.value)); + } + }) + } + } + + addScenarioVariables(threadGroup, scenario) { let environment = scenario.environment; if (environment) { - let envVariables = environment.variables; - if (!(envVariables instanceof Array)) { - envVariables = JSON.parse(environment.variables); - envVariables.forEach(item => { - if (item.name && !scenarioVariableKeys.has(item.name)) { - scenario.variables.push(new KeyValue(item.name, item.value)); - } - }) - } + this.addEnvironments(environment.variables, scenario.variables) } let args = this.filterKV(scenario.variables); if (args.length > 0) { @@ -510,21 +514,9 @@ class JMXGenerator { } addScenarioHeaders(threadGroup, scenario) { - let scenarioHeaderKeys = new Set(); - scenario.headers.forEach(item => { - scenarioHeaderKeys.add(item.name); - }); let environment = scenario.environment; if (environment) { - let envHeaders = environment.headers; - if (!(envHeaders instanceof Array)) { - envHeaders = JSON.parse(environment.headers); - envHeaders.forEach(item => { - if (item.name && !scenarioHeaderKeys.has(item.name)) { - scenario.headers.push(new KeyValue(item.name, item.value)); - } - }) - } + this.addEnvironments(environment.headers, scenario.headers) } let headers = this.filterKV(scenario.headers); if (headers.length > 0) { From ff42d6c96ef3a0be80474a5b37d8304db5109201 Mon Sep 17 00:00:00 2001 From: q4speed Date: Fri, 17 Jul 2020 10:59:26 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=AB=98=E7=BA=A7?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E8=BE=93=E5=85=A5=E6=A1=86=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/components/search/MsTableAdvSearchBar.vue | 10 +++++++--- .../common/components/search/search-components.js | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/frontend/src/business/components/common/components/search/MsTableAdvSearchBar.vue b/frontend/src/business/components/common/components/search/MsTableAdvSearchBar.vue index add1b2f22e..280852ed60 100644 --- a/frontend/src/business/components/common/components/search/MsTableAdvSearchBar.vue +++ b/frontend/src/business/components/common/components/search/MsTableAdvSearchBar.vue @@ -72,9 +72,13 @@ reset() { let source = this.condition.components; this.config.components.forEach((component, index) => { - let operator = source[index].operator.value; - component.operator.value = operator === undefined ? component.operator.options[0].value : operator; - component.value = source[index].value; + if (component.operator.value !== undefined) { + let operator = source[index].operator.value; + component.operator.value = operator === undefined ? component.operator.options[0].value : operator; + } + if (component.value !== undefined) { + component.value = source[index].value; + } }) }, open() { diff --git a/frontend/src/business/components/common/components/search/search-components.js b/frontend/src/business/components/common/components/search/search-components.js index 5010e134f2..4e30c4ec1b 100644 --- a/frontend/src/business/components/common/components/search/search-components.js +++ b/frontend/src/business/components/common/components/search/search-components.js @@ -215,8 +215,8 @@ export const MODULE = { name: 'MsTableSearchInput', label: "test_track.case.module", operator: { - value: OPERATORS.LIKE.value, // 如果未设置value初始值,则value初始值为options[0] - options: [OPERATORS.LIKE, OPERATORS.NOT_LIKE] // 运算符候选项 + value: OPERATORS.LIKE.value, + options: [OPERATORS.LIKE, OPERATORS.NOT_LIKE] }, }