From 1f84e55ce780f42013401e3e246ea43d3aa6d098 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Fri, 29 May 2020 16:46:32 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=85=A8=E5=B1=8F=E5=AF=B9?= =?UTF-8?q?=E8=AF=9D=E6=A1=86=E6=B5=8F=E8=A7=88=E5=99=A8=E5=9B=9E=E9=80=80?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/service/ProjectService.java | 16 +++++++++------- .../track/service/TestCaseService.java | 16 +++++++++------- .../track/service/TestPlanService.java | 16 +++++++++------- .../view/comonents/TestPlanTestCaseEdit.vue | 17 +++++++++++++++-- .../report/TestCaseReportTemplateEdit.vue | 14 +++++++++++++- .../comonents/report/TestCaseReportView.vue | 12 ++++++++++++ 6 files changed, 67 insertions(+), 24 deletions(-) diff --git a/backend/src/main/java/io/metersphere/service/ProjectService.java b/backend/src/main/java/io/metersphere/service/ProjectService.java index 95b64a776..cd1df1f0e 100644 --- a/backend/src/main/java/io/metersphere/service/ProjectService.java +++ b/backend/src/main/java/io/metersphere/service/ProjectService.java @@ -130,13 +130,15 @@ public class ProjectService { } private void checkProjectExist (Project project) { - ProjectExample example = new ProjectExample(); - example.createCriteria() - .andNameEqualTo(project.getName()) - .andWorkspaceIdEqualTo(SessionUtils.getCurrentWorkspaceId()) - .andIdNotEqualTo(project.getId()); - if (projectMapper.selectByExample(example).size() > 0) { - MSException.throwException(Translator.get("project_name_already_exists")); + if (project.getName() != null) { + ProjectExample example = new ProjectExample(); + example.createCriteria() + .andNameEqualTo(project.getName()) + .andWorkspaceIdEqualTo(SessionUtils.getCurrentWorkspaceId()) + .andIdNotEqualTo(project.getId()); + if (projectMapper.selectByExample(example).size() > 0) { + MSException.throwException(Translator.get("project_name_already_exists")); + } } } diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java index a2ff41200..ca4743eff 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -97,13 +97,15 @@ public class TestCaseService { } private void checkTestCaseExist (TestCaseWithBLOBs testCase) { - TestCaseExample example = new TestCaseExample(); - example.createCriteria() - .andNameEqualTo(testCase.getName()) - .andProjectIdEqualTo(testCase.getProjectId()) - .andIdNotEqualTo(testCase.getId()); - if (testCaseMapper.selectByExample(example).size() > 0) { - MSException.throwException(Translator.get("test_case_already_exists")); + if (testCase.getName() != null) { + TestCaseExample example = new TestCaseExample(); + example.createCriteria() + .andNameEqualTo(testCase.getName()) + .andProjectIdEqualTo(testCase.getProjectId()) + .andIdNotEqualTo(testCase.getId()); + if (testCaseMapper.selectByExample(example).size() > 0) { + MSException.throwException(Translator.get("test_case_already_exists")); + } } } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index ed18d8fa9..df1ea35dd 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -95,13 +95,15 @@ public class TestPlanService { } private void checkTestPlanExist (TestPlan testPlan) { - TestPlanExample example = new TestPlanExample(); - example.createCriteria() - .andNameEqualTo(testPlan.getName()) - .andWorkspaceIdEqualTo(SessionUtils.getCurrentWorkspaceId()) - .andIdNotEqualTo(testPlan.getId()); - if (testPlanMapper.selectByExample(example).size() > 0) { - MSException.throwException(Translator.get("plan_name_already_exists")); + if (testPlan.getName() != null) { + TestPlanExample example = new TestPlanExample(); + example.createCriteria() + .andNameEqualTo(testPlan.getName()) + .andWorkspaceIdEqualTo(SessionUtils.getCurrentWorkspaceId()) + .andIdNotEqualTo(testPlan.getId()); + if (testPlanMapper.selectByExample(example).size() > 0) { + MSException.throwException(Translator.get("plan_name_already_exists")); + } } } diff --git a/frontend/src/business/components/track/plan/view/comonents/TestPlanTestCaseEdit.vue b/frontend/src/business/components/track/plan/view/comonents/TestPlanTestCaseEdit.vue index 6145eabf2..37bbdeebe 100644 --- a/frontend/src/business/components/track/plan/view/comonents/TestPlanTestCaseEdit.vue +++ b/frontend/src/business/components/track/plan/view/comonents/TestPlanTestCaseEdit.vue @@ -232,11 +232,23 @@ } }, methods: { - handleClose(done) { + listenGoBack() { + //监听浏览器返回操作,关闭该对话框 + if (window.history && window.history.pushState) { + history.pushState(null, null, document.URL); + window.addEventListener('popstate', this.goBack, false); + } + }, + goBack() { + this.handleClose(); + }, + handleClose() { + //移除监听,防止监听其他页面 + window.removeEventListener('popstate', this.goBack, false); this.showDialog = false; }, cancel() { - this.showDialog = false; + this.handleClose(); this.$emit('refreshTable'); }, statusChange(status) { @@ -299,6 +311,7 @@ }, openTestCaseEdit(testCase) { this.showDialog = true; + this.listenGoBack(); this.initData(testCase); }, initTest() { diff --git a/frontend/src/business/components/track/plan/view/comonents/report/TestCaseReportTemplateEdit.vue b/frontend/src/business/components/track/plan/view/comonents/report/TestCaseReportTemplateEdit.vue index ad2aa547f..a303bfb5b 100644 --- a/frontend/src/business/components/track/plan/view/comonents/report/TestCaseReportTemplateEdit.vue +++ b/frontend/src/business/components/track/plan/view/comonents/report/TestCaseReportTemplateEdit.vue @@ -91,6 +91,16 @@ } }, methods: { + listenGoBack() { + //监听浏览器返回操作,关闭该对话框 + if (window.history && window.history.pushState) { + history.pushState(null, null, document.URL); + window.addEventListener('popstate', this.goBack, false); + } + }, + goBack() { + this.handleClose(); + }, open(id, isReport) { if (isReport) { this.isReport = isReport; @@ -112,6 +122,7 @@ this.initComponents(); } this.showDialog = true; + this.listenGoBack(); }, initComponents() { this.componentMap.forEach((value, key) =>{ @@ -134,6 +145,7 @@ }); }, handleClose() { + window.removeEventListener('popstate', this.goBack, false); this.showDialog = false; }, change(evt) { @@ -221,7 +233,7 @@ } this.$post(url + this.type, param, () =>{ this.$success(this.$t('commons.save_success')); - this.showDialog = false; + this.handleClose(); this.$emit('refresh'); }); }, diff --git a/frontend/src/business/components/track/plan/view/comonents/report/TestCaseReportView.vue b/frontend/src/business/components/track/plan/view/comonents/report/TestCaseReportView.vue index ad79e5fd1..87f9250ba 100644 --- a/frontend/src/business/components/track/plan/view/comonents/report/TestCaseReportView.vue +++ b/frontend/src/business/components/track/plan/view/comonents/report/TestCaseReportView.vue @@ -78,12 +78,23 @@ } }, methods: { + listenGoBack() { + //监听浏览器返回操作,关闭该对话框 + if (window.history && window.history.pushState) { + history.pushState(null, null, document.URL); + window.addEventListener('popstate', this.goBack, false); + } + }, + goBack() { + this.handleClose(); + }, open(id) { if (id) { this.reportId = id; } this.getReport(); this.showDialog = true; + this.listenGoBack(); }, getReport() { this.result = this.$get('/case/report/get/' + this.reportId, response => { @@ -113,6 +124,7 @@ }); }, handleClose() { + window.removeEventListener('popstate', this.goBack, false); this.showDialog = false; }, handleEdit() { -- GitLab