fix: 测试用例页面浏览器回退问题
This commit is contained in:
parent
af03676879
commit
73a4ee5d12
|
@ -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') {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<div>
|
||||
|
||||
<el-dialog
|
||||
<el-dialog @close="close"
|
||||
:title="operationType == 'edit' ? ( readOnly ? $t('test_track.case.view_case') : $t('test_track.case.edit_case')) : $t('test_track.case.create')"
|
||||
:visible.sync="dialogFormVisible" width="65%">
|
||||
|
||||
|
@ -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) {
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
<el-menu-item :index="'/track/home'">
|
||||
{{ $t("i18n.home") }}
|
||||
</el-menu-item>
|
||||
<el-submenu v-permission="['test_manager','test_user','test_viewer']" index="3" popper-class="submenu">
|
||||
<el-submenu :class="{'deactivation':!isProjectActivation}"
|
||||
v-permission="['test_manager','test_user','test_viewer']" index="3" popper-class="submenu">
|
||||
<template v-slot:title>{{$t('commons.project')}}</template>
|
||||
<ms-recent-list :options="projectRecent"/>
|
||||
<el-divider/>
|
||||
|
@ -23,6 +24,7 @@
|
|||
<el-divider/>
|
||||
<ms-show-all :index="'/track/case/all'"/>
|
||||
<el-menu-item :index="testCaseEditPath" class="blank_item"></el-menu-item>
|
||||
<el-menu-item :index="testCaseProjectPath" class="blank_item"></el-menu-item>
|
||||
<ms-create-button v-permission="['test_manager','test_user']" :index="'/track/case/create'" :title="$t('test_track.case.create_case')"/>
|
||||
</el-submenu>
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
|
@ -354,7 +354,6 @@
|
|||
}
|
||||
this.testCase = item;
|
||||
this.initTest();
|
||||
//
|
||||
this.stepResultChange();
|
||||
},
|
||||
openTestCaseEdit(testCase) {
|
||||
|
|
Loading…
Reference in New Issue