From 34811a96136f61e19722684332874abae0f58aa1 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 21 Jul 2021 11:26:36 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BF=AE=E5=A4=8D=E5=9C=BA=E6=99=AF=E8=B0=83?= =?UTF-8?q?=E8=AF=95=E6=97=A0=E7=8E=AF=E5=A2=83=E6=8A=A5=E9=94=99=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20#09e9b5b7=20--bug=3D1005268=20--user=3D=E8=B5=B5?= =?UTF-8?q?=E5=8B=87=20=E3=80=90=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96=E3=80=91=E7=BC=96=E8=BE=91=E5=9C=BA...=20https://www.?= =?UTF-8?q?tapd.cn/55049933/s/1026836?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/service/ApiAutomationService.java | 8 +- .../automation/report/SysnApiReportDetail.vue | 4 +- .../automation/scenario/EditApiScenario.vue | 94 +++++++------------ .../scenario/component/ApiComponent.vue | 29 +++--- .../component/ApiScenarioComponent.vue | 9 +- .../scenario/component/ComponentConfig.vue | 3 +- .../scenario/component/IfController.vue | 15 ++- .../component/JmeterElementComponent.vue | 19 +++- .../scenario/component/LoopController.vue | 8 +- .../component/TransactionController.vue | 15 ++- 10 files changed, 114 insertions(+), 90 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index 3fc87894f6..218968ca34 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -1393,9 +1393,11 @@ public class ApiAutomationService { if (map != null) { map.keySet().forEach(id -> { ApiTestEnvironmentWithBLOBs environment = environmentService.get(map.get(id)); - EnvironmentConfig env = JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class); - env.setApiEnvironmentid(environment.getId()); - envConfig.put(id, env); + if (environment != null && environment.getConfig() != null) { + EnvironmentConfig env = JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class); + env.setApiEnvironmentid(environment.getId()); + envConfig.put(id, env); + } }); } try { diff --git a/frontend/src/business/components/api/automation/report/SysnApiReportDetail.vue b/frontend/src/business/components/api/automation/report/SysnApiReportDetail.vue index d94630e130..232036a4de 100644 --- a/frontend/src/business/components/api/automation/report/SysnApiReportDetail.vue +++ b/frontend/src/business/components/api/automation/report/SysnApiReportDetail.vue @@ -449,7 +449,9 @@ export default { .report-header { font-size: 15px; } - +/deep/ .el-card__body{ + padding: 0px; +} .report-header a { text-decoration: none; } diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 07820a5870..50e397037a 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -195,7 +195,7 @@ :allow-drop="allowDrop" @node-drag-end="allowDrag" @node-click="nodeClick" v-if="!loading" draggable ref="stepTree"> - @@ -416,6 +416,7 @@ export default { stopDebug: "", isTop: false, stepSize: 0, + message: "", } }, created() { @@ -509,6 +510,7 @@ export default { if (e.data) { let data = JSON.parse(e.data); this.formatResult(data); + this.message = getUUID(); if (data.end) { this.removeReport(); this.debugLoading = false; @@ -561,7 +563,7 @@ export default { } this.debugResult = resMap; this.sort(); - this.reload(); + // this.reload(); this.reloadDebug = getUUID(); }, removeReport() { @@ -709,72 +711,42 @@ export default { this.isBtnHide = true; this.$refs.scenarioApiRelevance.open(); }, - recursiveSorting(arr, scenarioProjectId) { - for (let i in arr) { - arr[i].index = Number(i) + 1; - if (!arr[i].resourceId) { - arr[i].resourceId = getUUID(); - } - if (arr[i].type === ELEMENT_TYPE.LoopController && arr[i].loopType === "LOOP_COUNT" && arr[i].hashTree && arr[i].hashTree.length > 1) { - arr[i].countController.proceed = true; - } - if (!arr[i].projectId) { - // 如果自身没有ID并且场景有ID则赋值场景ID,否则赋值当前项目ID - arr[i].projectId = scenarioProjectId ? scenarioProjectId : this.projectId; - } else { - const project = this.projectList.find(p => p.id === arr[i].projectId); - if (!project) { - arr[i].projectId = scenarioProjectId ? scenarioProjectId : this.projectId; - } - } - // 添加debug结果 - let key = arr[i].resourceId; - if (this.debugResult && this.debugResult.get(key)) { - arr[i].requestResult = this.debugResult.get(key); - arr[i].result = null; - arr[i].debug = this.debug; - this.findNode(key, arr[i].requestResult[0].success); - } - if (arr[i].hashTree && arr[i].hashTree.length > 0) { - this.stepSize += arr[i].hashTree.length; - this.recursiveSorting(arr[i].hashTree, arr[i].projectId); - } + sort(stepArray, scenarioProjectId) { + if (!stepArray) { + stepArray = this.scenarioDefinition; } - }, - sort() { - this.stepSize = this.scenarioDefinition.length; - for (let i in this.scenarioDefinition) { - // 排序 - this.scenarioDefinition[i].index = Number(i) + 1; - if (!this.scenarioDefinition[i].resourceId) { - this.scenarioDefinition[i].resourceId = getUUID(); + for (let i in stepArray) { + stepArray[i].index = Number(i) + 1; + if (!stepArray[i].resourceId) { + stepArray[i].resourceId = getUUID(); } - // 设置循环控制 - if (this.scenarioDefinition[i].type === ELEMENT_TYPE.LoopController && this.scenarioDefinition[i].hashTree - && this.scenarioDefinition[i].hashTree.length > 1) { - this.scenarioDefinition[i].countController.proceed = true; + if (stepArray[i].type === ELEMENT_TYPE.LoopController + && stepArray[i].loopType === "LOOP_COUNT" + && stepArray[i].hashTree + && stepArray[i].hashTree.length > 1) { + stepArray[i].countController.proceed = true; } - // 设置项目ID - if (!this.scenarioDefinition[i].projectId) { - this.scenarioDefinition[i].projectId = this.projectId; + if (!stepArray[i].projectId) { + // 如果自身没有ID并且场景有ID则赋值场景ID,否则赋值当前项目ID + stepArray[i].projectId = scenarioProjectId ? scenarioProjectId : this.projectId; } else { - const project = this.projectList.find(p => p.id === this.scenarioDefinition[i].projectId); + const project = this.projectList.find(p => p.id === stepArray[i].projectId); if (!project) { - this.scenarioDefinition[i].projectId = this.projectId; + stepArray[i].projectId = scenarioProjectId ? scenarioProjectId : this.projectId; } } - - if (this.scenarioDefinition[i].hashTree !== undefined && this.scenarioDefinition[i].hashTree.length > 0) { - this.stepSize += this.scenarioDefinition[i].hashTree.length; - this.recursiveSorting(this.scenarioDefinition[i].hashTree, this.scenarioDefinition[i].projectId); - } // 添加debug结果 - if (this.debugResult && this.debugResult.get(this.scenarioDefinition[i].resourceId)) { - this.scenarioDefinition[i].result = null; - this.scenarioDefinition[i].requestResult = this.debugResult.get(this.scenarioDefinition[i].resourceId); - this.scenarioDefinition[i].debug = this.debug; + let key = stepArray[i].resourceId; + if (this.debugResult && this.debugResult.get(key)) { + stepArray[i].requestResult = this.debugResult.get(key); + stepArray[i].result = null; + stepArray[i].debug = this.debug; + this.findNode(key, stepArray[i].requestResult[0].success); + } + if (stepArray[i].hashTree && stepArray[i].hashTree.length > 0) { + this.stepSize += stepArray[i].hashTree.length; + this.sort(stepArray[i].hashTree, stepArray[i].projectId); } - } }, addCustomizeApi(request) { @@ -970,7 +942,6 @@ export default { }); } }, - checkDataIsCopy() { // 如果是复制按钮创建的场景,直接进行保存 if (this.currentScenario.copy) { @@ -1148,8 +1119,7 @@ export default { this.currentScenario.apiScenarioModuleId = this.currentModule.id; } this.currentScenario.projectId = this.projectId; - } - , + }, runRefresh() { if (!this.debug) { this.debugVisible = true; 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 6934a02347..0c9c03e346 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue @@ -23,7 +23,7 @@ {{ $t('api_test.scenario.reference') }} @@ -133,7 +133,8 @@ export default { currentEnvironmentId: String, projectList: Array, expandedNode: Array, - envMap: Map + envMap: Map, + message: String }, components: { TemplateComponent, @@ -188,6 +189,9 @@ export default { envMap() { this.getEnvironments(); }, + message() { + this.reload(); + }, }, computed: { displayColor() { @@ -264,7 +268,7 @@ export default { if (this.request.protocol === 'SQL' || this.request.type === 'JDBCSampler') { if (this.environment && this.environment.config) { let config = JSON.parse(this.environment.config); - if(config && config.databaseConfigs) { + if (config && config.databaseConfigs) { config.databaseConfigs.forEach(item => { databaseConfigsOptions.push(item); }); @@ -337,7 +341,10 @@ export default { }) } }, - recursiveSorting(arr) { + sort(arr) { + if (!arr) { + arr = this.request.hashTree; + } for (let i in arr) { arr[i].disabled = true; arr[i].index = Number(i) + 1; @@ -345,19 +352,7 @@ export default { arr[i].resourceId = getUUID(); } if (arr[i].hashTree != undefined && arr[i].hashTree.length > 0) { - this.recursiveSorting(arr[i].hashTree); - } - } - }, - sort() { - for (let i in this.request.hashTree) { - if (!this.request.hashTree[i].resourceId) { - this.request.hashTree[i].resourceId = getUUID(); - } - this.request.hashTree[i].disabled = true; - this.request.hashTree[i].index = Number(i) + 1; - if (this.request.hashTree[i].hashTree != undefined && this.request.hashTree[i].hashTree.length > 0) { - this.recursiveSorting(this.request.hashTree[i].hashTree); + this.sort(arr[i].hashTree); } } }, 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 2fb68febaa..d98d858c32 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiScenarioComponent.vue @@ -23,7 +23,7 @@ {{ getProjectName(scenario.projectId) }} @@ -43,6 +43,7 @@ export default { name: "ApiScenarioComponent", props: { scenario: {}, + message: String, node: {}, isMax: { type: Boolean, @@ -59,7 +60,11 @@ export default { currentEnvironmentId: String, projectList: Array }, - watch: {}, + watch: { + message() { + this.reload(); + }, + }, created() { if (!this.scenario.projectId) { this.scenario.projectId = getCurrentProjectID(); 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 eaa4dd073f..30bcfb2785 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue @@ -4,7 +4,7 @@ + @remove="remove" @copyRow="copyRow" @refReload="refReload" @openScenario="openScenario" :project-list="projectList" :env-map="envMap" :message="message"/> @@ -28,6 +28,7 @@ components: {MsConstantTimer, MsIfController, MsTransactionController, MsJsr233Processor, MsApiAssertions, MsApiExtract, MsApiComponent, MsLoopController, MsApiScenarioComponent, MsJdbcProcessor,JmeterElementComponent}, props: { type: String, + message: String, scenario: {}, draggable: { type: Boolean, diff --git a/frontend/src/business/components/api/automation/scenario/component/IfController.vue b/frontend/src/business/components/api/automation/scenario/component/IfController.vue index b3c6785e94..77134af11f 100644 --- a/frontend/src/business/components/api/automation/scenario/component/IfController.vue +++ b/frontend/src/business/components/api/automation/scenario/component/IfController.vue @@ -27,7 +27,7 @@ @@ -43,6 +43,7 @@ props: { controller: {}, node: {}, + message: String, isMax: { type: Boolean, default: false, @@ -59,6 +60,7 @@ }, data() { return { + loading: false, operators: { EQ: { label: "commons.adv_search.operators.equals", @@ -95,7 +97,18 @@ } } }, + watch: { + message() { + this.reload(); + }, + }, methods: { + reload() { + this.loading = true + this.$nextTick(() => { + this.loading = false + }) + }, getCode() { if (this.node && this.node.data.debug) { if (this.node.data.code && this.node.data.code === 'error') { diff --git a/frontend/src/business/components/api/automation/scenario/component/JmeterElementComponent.vue b/frontend/src/business/components/api/automation/scenario/component/JmeterElementComponent.vue index 10fa84ecdb..6c67cbbb22 100644 --- a/frontend/src/business/components/api/automation/scenario/component/JmeterElementComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/JmeterElementComponent.vue @@ -15,7 +15,7 @@ @@ -38,6 +38,7 @@ type: Boolean, default: false, }, + message: String, isReadOnly: { type: Boolean, default: @@ -59,7 +60,23 @@ defBackgroundColor: {type: String, default: "#F4F4FF"}, node: {}, }, + data() { + return { + loading: false, + } + }, + watch: { + message() { + this.reload(); + }, + }, methods: { + reload() { + this.loading = true + this.$nextTick(() => { + this.loading = false + }) + }, getCode() { if (this.node && this.node.data.debug) { if (this.node.data.code && this.node.data.code === 'error') { 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 40e5d7442f..7d075fc711 100644 --- a/frontend/src/business/components/api/automation/scenario/component/LoopController.vue +++ b/frontend/src/business/components/api/automation/scenario/component/LoopController.vue @@ -71,7 +71,7 @@ @@ -95,6 +95,7 @@ export default { currentEnvironmentId: String, currentScenario: {}, node: {}, + message: String, isMax: { type: Boolean, default: false, @@ -156,6 +157,11 @@ export default { }, }; }, + watch: { + message() { + this.reload(); + }, + }, methods: { getCode() { if (this.node && this.node.data.debug) { diff --git a/frontend/src/business/components/api/automation/scenario/component/TransactionController.vue b/frontend/src/business/components/api/automation/scenario/component/TransactionController.vue index 0b8d5e0e30..523466a363 100644 --- a/frontend/src/business/components/api/automation/scenario/component/TransactionController.vue +++ b/frontend/src/business/components/api/automation/scenario/component/TransactionController.vue @@ -11,7 +11,7 @@ background-color="#FCF6EE" :title="$t('api_test.automation.transcation_controller')"> @@ -34,6 +34,7 @@ export default { props: { controller: {}, node: {}, + message: String, isMax: { type: Boolean, default: false, @@ -48,6 +49,11 @@ export default { default: false, }, }, + watch: { + message() { + this.reload(); + }, + }, created() { if (this.controller.generateParentSample == null) { this.controller.generateParentSample = true; @@ -58,6 +64,7 @@ export default { }, data() { return { + loading: false, operators: { EQ: { label: "commons.adv_search.operators.equals", @@ -95,6 +102,12 @@ export default { } }, methods: { + reload() { + this.loading = true; + this.$nextTick(() => { + this.loading = false; + }); + }, getCode() { if (this.node && this.node.data.debug) { if (this.node.data.code && this.node.data.code === 'error') {