From 8f064af023e876db09f061f883f0b98db5521120 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Thu, 17 Jun 2021 16:12:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E5=BC=95=E7=94=A8=E6=A1=88=E4=BE=8B=E4=B8=8D=E5=8B=BE=E9=80=89?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E5=85=A8=E9=80=89=E5=8D=A1=E6=AD=BB=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复场景引用案例不勾选直接全选卡死的问题 --- .../api/service/ApiDefinitionService.java | 3 ++ .../api/service/ApiTestCaseService.java | 7 +++- .../automation/scenario/api/ApiRelevance.vue | 17 +++++++--- .../table/MsTableHeaderSelectPopover.vue | 32 ++++++++----------- 4 files changed, 35 insertions(+), 24 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index 3b876f599b..18868cd24a 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -119,6 +119,9 @@ public class ApiDefinitionService { public List listBatch(ApiBatchRequest request) { ServiceUtils.getSelectAllIds(request, request.getCondition(), (query) -> extApiDefinitionMapper.selectIds(query)); + if(CollectionUtils.isEmpty(request.getIds())){ + return new ArrayList<>(); + } List resList = extApiDefinitionMapper.listByIds(request.getIds()); calculateResult(resList, request.getProjectId()); return resList; diff --git a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java index 57b38e12d9..eac094e788 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java @@ -699,7 +699,12 @@ public class ApiTestCaseService { ids.removeAll(request.getUnSelectIds()); request.setIds(ids); } - List list = extApiTestCaseMapper.getCaseInfo(request); + List list = null; + if(StringUtils.isEmpty(request.getId()) && CollectionUtils.isEmpty(request.getIds())){ + list = new ArrayList<>(); + }else { + list = extApiTestCaseMapper.getCaseInfo(request); + } for (ApiTestCaseInfo model : list) { if (StringUtils.equalsIgnoreCase(model.getApiMethod(), "esb")) { esbApiParamService.handleApiEsbParams(model); diff --git a/frontend/src/business/components/api/automation/scenario/api/ApiRelevance.vue b/frontend/src/business/components/api/automation/scenario/api/ApiRelevance.vue index 17342de729..683a6d2243 100644 --- a/frontend/src/business/components/api/automation/scenario/api/ApiRelevance.vue +++ b/frontend/src/business/components/api/automation/scenario/api/ApiRelevance.vue @@ -92,16 +92,25 @@ export default { let params = this.$refs.apiList.getConditions(); this.result = this.$post("/api/definition/list/batch", params, (response) => { let apis = response.data; - this.$emit('save', apis, 'API', reference); - this.$refs.baseRelevance.close(); + if(apis.length === 0){ + this.$warning('请选择接口'); + }else { + this.$emit('save', apis, 'API', reference); + this.$refs.baseRelevance.close(); + } }); } else { let params = this.$refs.apiCaseList.getConditions(); this.result = this.$post("/api/testcase/get/caseBLOBs/request", params, (response) => { let apiCases = response.data; - this.$emit('save', apiCases, 'CASE', reference); - this.$refs.baseRelevance.close(); + if(apiCases.length === 0) { + this.$warning('请选择案例'); + }else{ + this.$emit('save', apiCases, 'CASE', reference); + this.$refs.baseRelevance.close(); + } + }); } }, diff --git a/frontend/src/business/components/common/components/table/MsTableHeaderSelectPopover.vue b/frontend/src/business/components/common/components/table/MsTableHeaderSelectPopover.vue index c8ef7ad027..995e9544cd 100644 --- a/frontend/src/business/components/common/components/table/MsTableHeaderSelectPopover.vue +++ b/frontend/src/business/components/common/components/table/MsTableHeaderSelectPopover.vue @@ -2,7 +2,6 @@ @@ -13,7 +12,6 @@
@@ -58,7 +56,6 @@ }, data() { return { - selectType: "", isShow: true, selectAllFontColor: { color: "gray", @@ -66,15 +63,14 @@ selectPageFontColor: { color: "gray", }, - + keyIndex:0, }; }, methods: { click(even) { if (even === 'selectPageAll') { - this.selectPageFontColor.color = document.body.style.getPropertyValue("--count_number"); this.selectAllFontColor.color = "gray"; - + this.selectPageFontColor.color = document.body.style.getPropertyValue("--count_number"); } else if (even === 'selectAll') { this.selectAllFontColor.color = document.body.style.getPropertyValue("--count_number"); this.selectPageFontColor.color = "gray"; @@ -84,20 +80,18 @@ this.selectPageFontColor.color = "gray"; } this.$emit(even); - // this.isShow = false; - // this.$nextTick(() => { - // this.isShow = true; - // }); - + //首次渲染之后,该组件不会重新渲染样式,使用keyIndex判断强制刷新一次,激活它的重新渲染功能 + if(this.keyIndex === 0){ + this.keyIndex++; + this.reload(); + } }, - // reload() { - // this.isShow = false; - // this.selectAllLinkType = "info"; - // this.selectPageLinkType = "info"; - // this.$nextTick(() => { - // this.isShow = true; - // }); - // } + reload() { + this.isShow = false; + this.$nextTick(() => { + this.isShow = true; + }); + } } }