fix: 测试用例页面浏览器回退问题
This commit is contained in:
parent
af03676879
commit
73a4ee5d12
|
@ -107,7 +107,7 @@
|
||||||
}
|
}
|
||||||
let caseId = this.$route.params.caseId;
|
let caseId = this.$route.params.caseId;
|
||||||
this.openRecentTestCaseEditDialog(caseId);
|
this.openRecentTestCaseEditDialog(caseId);
|
||||||
this.$router.push('/track/case/all');
|
// this.$router.push('/track/case/all');
|
||||||
} else if (route.params.projectId){
|
} else if (route.params.projectId){
|
||||||
this.getProjects();
|
this.getProjects();
|
||||||
this.getProjectById(route.params.projectId);
|
this.getProjectById(route.params.projectId);
|
||||||
|
@ -205,7 +205,7 @@
|
||||||
this.$get('/project/get/' + id, response => {
|
this.$get('/project/get/' + id, response => {
|
||||||
let project = response.data;
|
let project = response.data;
|
||||||
this.setCurrentProject(project);
|
this.setCurrentProject(project);
|
||||||
this.$router.push('/track/case/all');
|
// this.$router.push('/track/case/all');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (id === 'all') {
|
if (id === 'all') {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
<div>
|
<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')"
|
: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%">
|
:visible.sync="dialogFormVisible" width="65%">
|
||||||
|
|
||||||
|
@ -295,6 +295,7 @@
|
||||||
methods: {
|
methods: {
|
||||||
open(testCase) {
|
open(testCase) {
|
||||||
this.resetForm();
|
this.resetForm();
|
||||||
|
this.listenGoBack();
|
||||||
this.operationType = 'add';
|
this.operationType = 'add';
|
||||||
if (testCase) {
|
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() {
|
saveCase() {
|
||||||
this.$refs['caseFrom'].validate((valid) => {
|
this.$refs['caseFrom'].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
<el-menu-item :index="'/track/home'">
|
<el-menu-item :index="'/track/home'">
|
||||||
{{ $t("i18n.home") }}
|
{{ $t("i18n.home") }}
|
||||||
</el-menu-item>
|
</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>
|
<template v-slot:title>{{$t('commons.project')}}</template>
|
||||||
<ms-recent-list :options="projectRecent"/>
|
<ms-recent-list :options="projectRecent"/>
|
||||||
<el-divider/>
|
<el-divider/>
|
||||||
|
@ -23,6 +24,7 @@
|
||||||
<el-divider/>
|
<el-divider/>
|
||||||
<ms-show-all :index="'/track/case/all'"/>
|
<ms-show-all :index="'/track/case/all'"/>
|
||||||
<el-menu-item :index="testCaseEditPath" class="blank_item"></el-menu-item>
|
<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')"/>
|
<ms-create-button v-permission="['test_manager','test_user']" :index="'/track/case/create'" :title="$t('test_track.case.create_case')"/>
|
||||||
</el-submenu>
|
</el-submenu>
|
||||||
|
|
||||||
|
@ -55,6 +57,8 @@
|
||||||
testPlanViewPath: '',
|
testPlanViewPath: '',
|
||||||
isRouterAlive: true,
|
isRouterAlive: true,
|
||||||
testCaseEditPath: '',
|
testCaseEditPath: '',
|
||||||
|
testCaseProjectPath: '',
|
||||||
|
isProjectActivation: true,
|
||||||
projectRecent: {
|
projectRecent: {
|
||||||
title: this.$t('project.recent'),
|
title: this.$t('project.recent'),
|
||||||
url: "/project/recent/5",
|
url: "/project/recent/5",
|
||||||
|
@ -84,24 +88,38 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
'$route'(to, from) {
|
'$route'(to) {
|
||||||
let path = to.path;
|
this.init();
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
this.init();
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
reload() {
|
reload() {
|
||||||
this.isRouterAlive = false;
|
this.isRouterAlive = false;
|
||||||
this.$nextTick(function () {
|
this.$nextTick(function () {
|
||||||
this.isRouterAlive = true;
|
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 {
|
.el-divider--horizontal {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.deactivation >>> .el-submenu__title {
|
||||||
|
border-bottom: white !important;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -354,7 +354,6 @@
|
||||||
}
|
}
|
||||||
this.testCase = item;
|
this.testCase = item;
|
||||||
this.initTest();
|
this.initTest();
|
||||||
//
|
|
||||||
this.stepResultChange();
|
this.stepResultChange();
|
||||||
},
|
},
|
||||||
openTestCaseEdit(testCase) {
|
openTestCaseEdit(testCase) {
|
||||||
|
|
Loading…
Reference in New Issue