From 75084e97b2f111bca61a1dba381a54e9d70020dc Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Wed, 12 May 2021 16:03:32 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BF=AE=E5=A4=8D=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E5=9C=BA=E6=99=AF=E6=89=B9=E9=87=8F=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复测试场景批量修改环境的问题 --- .../controller/ApiAutomationController.java | 8 +++++ .../api/service/ApiAutomationService.java | 7 +++++ .../base/mapper/ext/ExtApiScenarioMapper.java | 2 ++ .../base/mapper/ext/ExtApiScenarioMapper.xml | 7 +++++ .../automation/scenario/ApiScenarioList.vue | 15 +++++++++- .../track/case/components/BatchEdit.vue | 29 ++++++++++++++----- 6 files changed, 60 insertions(+), 8 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java b/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java index 42f56dd20c..d1695856ef 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java @@ -51,6 +51,14 @@ public class ApiAutomationController { return apiAutomationService.listAll(request); } + @PostMapping("/listWithIds/all") + @RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR) + public List listWithIds(@RequestBody ApiScenarioBatchRequest request) { + return apiAutomationService.listWithIds(request); + } + + + @PostMapping("/id/all") @RequiresRoles(value = {RoleConstants.TEST_MANAGER, RoleConstants.TEST_USER, RoleConstants.TEST_VIEWER}, logical = Logical.OR) public List idAll(@RequestBody ApiScenarioBatchRequest request) { 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 7b88f07940..70fcbc0720 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -1767,4 +1767,11 @@ public class ApiAutomationService { public void updateCustomNumByProjectId(String id) { extApiScenarioMapper.updateCustomNumByProjectId(id); } + + public List listWithIds(ApiScenarioBatchRequest request) { + ServiceUtils.getSelectAllIds(request, request.getCondition(), + (query) -> extApiScenarioMapper.selectIdsByQuery((ApiScenarioRequest) query)); + List list = extApiScenarioMapper.listWithIds(request.getIds()); + return list; + } } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.java index 826797085f..7288d21e3e 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.java @@ -43,4 +43,6 @@ public interface ExtApiScenarioMapper { List selectIdsByQuery(@Param("request") ApiScenarioRequest request); void updateCustomNumByProjectId(@Param("projectId") String projectId); + + List listWithIds(@Param("ids") List ids); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml index fd5b67a1ba..f1284d8b6d 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml @@ -257,6 +257,13 @@ + + diff --git a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue index 5e6390db99..0b1f7b8fdf 100644 --- a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue +++ b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue @@ -520,8 +520,21 @@ this.planVisible = true; }, handleBatchEdit() { - this.$refs.batchEdit.open(this.selectDataCounts); this.$refs.batchEdit.setScenarioSelectRows(this.selectRows, "scenario"); + if(this.condition.selectAll){ + this.condition.ids = []; + let param = {}; + this.buildBatchParam(param); + this.$post('/api/automation/listWithIds/all', param, response => { + let dataRows = response.data; + this.$refs.batchEdit.open(dataRows.size); + this.$refs.batchEdit.setAllDataRows(dataRows); + this.$refs.batchEdit.open(this.selectDataCounts); + }); + }else { + this.$refs.batchEdit.setAllDataRows(new Set()); + this.$refs.batchEdit.open(this.selectDataCounts); + } }, handleBatchMove() { this.$refs.testBatchMove.open(this.moduleTree, [], this.moduleOptions); diff --git a/frontend/src/business/components/track/case/components/BatchEdit.vue b/frontend/src/business/components/track/case/components/BatchEdit.vue index ff2f165f6b..142780eea3 100644 --- a/frontend/src/business/components/track/case/components/BatchEdit.vue +++ b/frontend/src/business/components/track/case/components/BatchEdit.vue @@ -72,6 +72,7 @@ projectList: [], projectIds: new Set(), selectRows: new Set(), + allDataRows:new Set(), projectEnvMap: new Map(), map: new Map(), isScenario: '', @@ -121,6 +122,9 @@ this.selectRows = rows; this.isScenario = sign; }, + setAllDataRows(rows){ + this.allDataRows = rows; + }, handleClose() { this.form = {}; this.options = []; @@ -131,14 +135,25 @@ if (val === 'projectEnv' && this.isScenario !== '') { this.projectIds.clear(); this.map.clear(); - this.selectRows.forEach(row => { - let id = this.isScenario === 'scenario' ? row.id : row.caseId; - this.result = this.$get('/api/automation/getApiScenarioProjectId/' + id, res => { - let data = res.data; - data.projectIds.forEach(d => this.projectIds.add(d)); - this.map.set(row.id, data.projectIds); + if(this.allDataRows != null && this.allDataRows.length > 0){ + this.allDataRows.forEach(row => { + let id = this.isScenario === 'scenario' ? row.id : row.caseId; + this.result = this.$get('/api/automation/getApiScenarioProjectId/' + id, res => { + let data = res.data; + data.projectIds.forEach(d => this.projectIds.add(d)); + this.map.set(row.id, data.projectIds); + }) }) - }) + }else{ + this.selectRows.forEach(row => { + let id = this.isScenario === 'scenario' ? row.id : row.caseId; + this.result = this.$get('/api/automation/getApiScenarioProjectId/' + id, res => { + let data = res.data; + data.projectIds.forEach(d => this.projectIds.add(d)); + this.map.set(row.id, data.projectIds); + }) + }) + } } this.filterable = val === "maintainer" || val === "executor"; this.options = this.valueArr[val];