From 73a4ee5d125eb903a5f8920ad637569d4472061f Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Wed, 22 Jul 2020 20:42:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=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 --- .../components/track/case/TestCase.vue | 4 +- .../track/case/components/TestCaseEdit.vue | 15 ++++++- .../track/head/TrackHeaderMenus.vue | 45 ++++++++++++++----- .../view/comonents/TestPlanTestCaseEdit.vue | 1 - 4 files changed, 50 insertions(+), 15 deletions(-) diff --git a/frontend/src/business/components/track/case/TestCase.vue b/frontend/src/business/components/track/case/TestCase.vue index 5bde9fc007..58f3c0b6c0 100644 --- a/frontend/src/business/components/track/case/TestCase.vue +++ b/frontend/src/business/components/track/case/TestCase.vue @@ -107,7 +107,7 @@ } let caseId = this.$route.params.caseId; this.openRecentTestCaseEditDialog(caseId); - this.$router.push('/track/case/all'); + // this.$router.push('/track/case/all'); } else if (route.params.projectId){ this.getProjects(); this.getProjectById(route.params.projectId); @@ -205,7 +205,7 @@ this.$get('/project/get/' + id, response => { let project = response.data; this.setCurrentProject(project); - this.$router.push('/track/case/all'); + // this.$router.push('/track/case/all'); }); } if (id === 'all') { diff --git a/frontend/src/business/components/track/case/components/TestCaseEdit.vue b/frontend/src/business/components/track/case/components/TestCaseEdit.vue index 587dd54e58..b2cf1eb283 100644 --- a/frontend/src/business/components/track/case/components/TestCaseEdit.vue +++ b/frontend/src/business/components/track/case/components/TestCaseEdit.vue @@ -2,7 +2,7 @@
- @@ -295,6 +295,7 @@ methods: { open(testCase) { this.resetForm(); + this.listenGoBack(); this.operationType = 'add'; if (testCase) { //修改 @@ -346,6 +347,18 @@ } }); }, + listenGoBack() { + //监听浏览器返回操作,关闭该对话框 + if (window.history && window.history.pushState) { + history.pushState(null, null, document.URL); + window.addEventListener('popstate', this.close, false); + } + }, + close() { + //移除监听,防止监听其他页面 + window.removeEventListener('popstate', this.goBack, false); + this.dialogFormVisible = false; + }, saveCase() { this.$refs['caseFrom'].validate((valid) => { if (valid) { diff --git a/frontend/src/business/components/track/head/TrackHeaderMenus.vue b/frontend/src/business/components/track/head/TrackHeaderMenus.vue index 7ac747dd85..9e351fb219 100644 --- a/frontend/src/business/components/track/head/TrackHeaderMenus.vue +++ b/frontend/src/business/components/track/head/TrackHeaderMenus.vue @@ -8,7 +8,8 @@ {{ $t("i18n.home") }} - + @@ -23,6 +24,7 @@ + @@ -55,6 +57,8 @@ testPlanViewPath: '', isRouterAlive: true, testCaseEditPath: '', + testCaseProjectPath: '', + isProjectActivation: true, projectRecent: { title: this.$t('project.recent'), url: "/project/recent/5", @@ -84,24 +88,38 @@ } }, watch: { - '$route'(to, from) { - let path = to.path; - if (path.indexOf("/track/plan/view") >= 0) { - this.testPlanViewPath = '/track/plan/view/' + this.$route.params.planId; - this.reload(); - } - if (path.indexOf("/track/case/edit") >= 0) { - this.testCaseEditPath = '/track/case/edit/' + this.$route.params.caseId; - this.reload(); - } + '$route'(to) { + this.init(); } }, + mounted() { + this.init(); + }, methods: { reload() { this.isRouterAlive = false; this.$nextTick(function () { this.isRouterAlive = true; }); + }, + init() { + let path = this.$route.path; + if (path.indexOf("/track/case") >= 0 && !!this.$route.params.projectId) { + this.testCaseProjectPath = path; + //不激活项目菜单栏 + this.isProjectActivation = false; + this.reload(); + } else { + this.isProjectActivation = true; + } + if (path.indexOf("/track/plan/view") >= 0) { + this.testPlanViewPath = path; + this.reload(); + } + if (path.indexOf("/track/case/edit") >= 0) { + this.testCaseEditPath = path; + this.reload(); + } } } } @@ -125,4 +143,9 @@ .el-divider--horizontal { margin: 0; } + + .deactivation >>> .el-submenu__title { + border-bottom: white !important; + } + 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 5b644e4314..7710c5636a 100644 --- a/frontend/src/business/components/track/plan/view/comonents/TestPlanTestCaseEdit.vue +++ b/frontend/src/business/components/track/plan/view/comonents/TestPlanTestCaseEdit.vue @@ -354,7 +354,6 @@ } this.testCase = item; this.initTest(); - // this.stepResultChange(); }, openTestCaseEdit(testCase) {