子页面激活菜单栏
This commit is contained in:
parent
2364fac57b
commit
11956de1ea
|
@ -2,10 +2,7 @@ package io.metersphere.controller;
|
|||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.metersphere.base.domain.LoadTest;
|
||||
import io.metersphere.base.domain.TestCase;
|
||||
import io.metersphere.base.domain.TestCaseNode;
|
||||
import io.metersphere.base.domain.TestCaseWithBLOBs;
|
||||
import io.metersphere.base.domain.*;
|
||||
import io.metersphere.commons.utils.PageUtils;
|
||||
import io.metersphere.commons.utils.Pager;
|
||||
import io.metersphere.controller.request.testcase.QueryTestCaseRequest;
|
||||
|
@ -39,8 +36,7 @@ public class TestCaseController {
|
|||
String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId();
|
||||
QueryTestCaseRequest request = new QueryTestCaseRequest();
|
||||
request.setWorkspaceId(currentWorkspaceId);
|
||||
PageHelper.startPage(1, count, true);
|
||||
return testCaseService.recentTestPlans(request);
|
||||
return testCaseService.recentTestPlans(request, count);
|
||||
}
|
||||
|
||||
@PostMapping("/list")
|
||||
|
@ -58,6 +54,11 @@ public class TestCaseController {
|
|||
return testCaseService.getTestCase(testCaseId);
|
||||
}
|
||||
|
||||
@GetMapping("/project/{testCaseId}")
|
||||
public Project getProjectByTestCaseId(@PathVariable String testCaseId){
|
||||
return testCaseService.getProjectByTestCaseId(testCaseId);
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
public void addTestCase(@RequestBody TestCaseWithBLOBs testCase){
|
||||
testCaseService.addTestCase(testCase);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.metersphere.service;
|
||||
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.metersphere.base.domain.*;
|
||||
import io.metersphere.base.mapper.ProjectMapper;
|
||||
import io.metersphere.base.mapper.TestCaseMapper;
|
||||
|
@ -114,7 +115,7 @@ public class TestCaseService {
|
|||
}
|
||||
|
||||
|
||||
public List<TestCase> recentTestPlans(QueryTestCaseRequest request) {
|
||||
public List<TestCase> recentTestPlans(QueryTestCaseRequest request, int count) {
|
||||
|
||||
if (StringUtils.isBlank(request.getWorkspaceId())) {
|
||||
return null;
|
||||
|
@ -126,9 +127,19 @@ public class TestCaseService {
|
|||
List<String> projectIds = projectMapper.selectByExample(projectExample).stream()
|
||||
.map(Project::getId).collect(Collectors.toList());
|
||||
|
||||
PageHelper.startPage(1, count, true);
|
||||
|
||||
TestCaseExample testCaseExample = new TestCaseExample();
|
||||
testCaseExample.createCriteria().andProjectIdIn(projectIds);
|
||||
testCaseExample.setOrderByClause("update_time desc");
|
||||
return testCaseMapper.selectByExample(testCaseExample);
|
||||
}
|
||||
|
||||
public Project getProjectByTestCaseId(String testCaseId) {
|
||||
TestCaseWithBLOBs testCaseWithBLOBs = testCaseMapper.selectByPrimaryKey(testCaseId);
|
||||
if (testCaseWithBLOBs == null) {
|
||||
return null;
|
||||
}
|
||||
return projectMapper.selectByPrimaryKey(testCaseWithBLOBs.getProjectId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<el-col>
|
||||
<header-menus/>
|
||||
<api-header-menus/>
|
||||
<div>
|
||||
<transition>
|
||||
<keep-alive>
|
||||
|
@ -12,11 +12,11 @@
|
|||
</template>
|
||||
<script>
|
||||
|
||||
import HeaderMenus from "./head/HeaderMenus";
|
||||
import ApiHeaderMenus from "./head/ApiHeaderMenus";
|
||||
|
||||
export default {
|
||||
name: "ApiTest",
|
||||
components: {HeaderMenus},
|
||||
components: {ApiHeaderMenus},
|
||||
data() {
|
||||
return {
|
||||
beaseUrl: "api"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
|
||||
<div id="menu-bar">
|
||||
<div id="menu-bar" v-if="isRouterAlive">
|
||||
<el-menu class="header-menu" :unique-opened="true" mode="horizontal" router
|
||||
:default-active='$route.path'>
|
||||
<el-menu-item :index="'/api/home'">
|
||||
|
@ -24,7 +24,7 @@
|
|||
<el-submenu v-if="isCurrentWorkspaceUser"
|
||||
index="4" popper-class="submenu" v-permission="['test_manager', 'test_user']">
|
||||
<template v-slot:title>{{$t('commons.test')}}</template>
|
||||
<api-recent-test-plan/>
|
||||
<api-recent-test/>
|
||||
<el-divider/>
|
||||
<el-menu-item :index="'/api/test/all'">
|
||||
<font-awesome-icon :icon="['fa', 'list-ul']"/>
|
||||
|
@ -33,6 +33,8 @@
|
|||
<el-menu-item :index="'/api/test/create'">
|
||||
<el-button type="text">{{$t('load_test.create')}}</el-button>
|
||||
</el-menu-item>
|
||||
<el-menu-item :index="testCaseProjectPath" class="blank_item"></el-menu-item>
|
||||
<el-menu-item :index="testEditPath" class="blank_item"></el-menu-item>
|
||||
</el-submenu>
|
||||
|
||||
<el-submenu v-if="isCurrentWorkspaceUser"
|
||||
|
@ -44,6 +46,7 @@
|
|||
<font-awesome-icon :icon="['fa', 'list-ul']"/>
|
||||
<span style="padding-left: 5px;">{{$t('commons.show_all')}}</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item :index="reportViewPath" class="blank_item"></el-menu-item>
|
||||
</el-submenu>
|
||||
|
||||
<router-link v-if="isCurrentWorkspaceUser"
|
||||
|
@ -64,15 +67,45 @@
|
|||
import {checkoutCurrentWorkspace} from "../../../../common/utils";
|
||||
|
||||
export default {
|
||||
name: "MsMenus",
|
||||
name: "ApiHeaderMenus",
|
||||
components: {ApiRecentTest, ApiRecentReport, ApiRecentProject},
|
||||
data() {
|
||||
return {
|
||||
isCurrentWorkspaceUser: false,
|
||||
testCaseProjectPath: '',
|
||||
testEditPath: '',
|
||||
reportViewPath: '',
|
||||
isRouterAlive: true
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'$route'(to, from) {
|
||||
let path = to.path;
|
||||
//激活菜单栏
|
||||
if (path.indexOf("/api/test/") >= 0){
|
||||
this.testCaseProjectPath = '/api/test/' + this.$route.params.projectId;
|
||||
this.reload();
|
||||
}
|
||||
if (path.indexOf("/api/test/edit/") >= 0){
|
||||
this.testEditPath = '/api/test/edit/' + this.$route.params.testId;
|
||||
this.reload();
|
||||
}
|
||||
if (path.indexOf("/api/report/view/") >= 0){
|
||||
this.reportViewPath = '/api/report/view/' + this.$route.params.reportId;
|
||||
this.reload();
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.isCurrentWorkspaceUser = checkoutCurrentWorkspace();
|
||||
},
|
||||
methods: {
|
||||
reload () {
|
||||
this.isRouterAlive = false;
|
||||
this.$nextTick(function () {
|
||||
this.isRouterAlive = true;
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,4 +139,9 @@
|
|||
#menu-bar {
|
||||
border-bottom: 1px solid #E6E6E6;
|
||||
}
|
||||
|
||||
.blank_item {
|
||||
display: none;
|
||||
}
|
||||
|
||||
</style>
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<el-col>
|
||||
<header-menus/>
|
||||
<performance-header-menus/>
|
||||
<div>
|
||||
<transition>
|
||||
<keep-alive>
|
||||
|
@ -13,11 +13,11 @@
|
|||
|
||||
<script>
|
||||
|
||||
import HeaderMenus from "./head/HeaderMenus";
|
||||
import PerformanceHeaderMenus from "./head/PerformanceHeaderMenus";
|
||||
|
||||
export default {
|
||||
name: "PerformanceTest",
|
||||
components: {HeaderMenus},
|
||||
components: {PerformanceHeaderMenus},
|
||||
data() {
|
||||
return {
|
||||
beaseUrl: "performance"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
|
||||
<div id="menu-bar">
|
||||
<div id="menu-bar" v-if="isRouterAlive">
|
||||
<el-menu class="header-menu" :unique-opened="true" mode="horizontal" router
|
||||
:default-active='$route.path'>
|
||||
<el-menu-item :index="'/performance/home'">
|
||||
|
@ -33,6 +33,8 @@
|
|||
<el-menu-item :index="'/performance/test/create'">
|
||||
<el-button type="text">{{$t('load_test.create')}}</el-button>
|
||||
</el-menu-item>
|
||||
<el-menu-item :index="testCaseProjectPath" class="blank_item"></el-menu-item>
|
||||
<el-menu-item :index="testEditPath" class="blank_item"></el-menu-item>
|
||||
</el-submenu>
|
||||
|
||||
<el-submenu v-if="isCurrentWorkspaceUser"
|
||||
|
@ -44,6 +46,7 @@
|
|||
<font-awesome-icon :icon="['fa', 'list-ul']"/>
|
||||
<span style="padding-left: 5px;">{{$t('commons.show_all')}}</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item :index="reportViewPath" class="blank_item"></el-menu-item>
|
||||
</el-submenu>
|
||||
|
||||
<router-link v-if="isCurrentWorkspaceUser"
|
||||
|
@ -64,20 +67,45 @@
|
|||
import {checkoutCurrentWorkspace} from "../../../../common/utils";
|
||||
|
||||
export default {
|
||||
name: "MsMenus",
|
||||
name: "PerformanceHeaderMenus",
|
||||
components: {PerformanceRecentReport, PerformanceRecentTestPlan, PerformanceRecentProject},
|
||||
data() {
|
||||
return {
|
||||
isCurrentWorkspaceUser: false,
|
||||
}
|
||||
},
|
||||
props: {
|
||||
beaseUrl: {
|
||||
type: String
|
||||
testCaseProjectPath: '',
|
||||
testEditPath: '',
|
||||
reportViewPath: '',
|
||||
isRouterAlive: true
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.isCurrentWorkspaceUser = checkoutCurrentWorkspace();
|
||||
},
|
||||
watch: {
|
||||
'$route'(to, from) {
|
||||
let path = to.path;
|
||||
//激活菜单栏
|
||||
if (path.indexOf("/performance/test/") >= 0){
|
||||
this.testCaseProjectPath = '/performance/test/' + this.$route.params.projectId;
|
||||
this.reload();
|
||||
}
|
||||
if (path.indexOf("/performance/test/edit/") >= 0){
|
||||
this.testEditPath = '/performance/test/edit/' + this.$route.params.testId;
|
||||
this.reload();
|
||||
}
|
||||
if (path.indexOf("/performance/report/view/") >= 0){
|
||||
this.reportViewPath = '/performance/report/view/' + this.$route.params.reportId;
|
||||
this.reload();
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
reload () {
|
||||
this.isRouterAlive = false;
|
||||
this.$nextTick(function () {
|
||||
this.isRouterAlive = true;
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,4 +139,8 @@
|
|||
#menu-bar {
|
||||
border-bottom: 1px solid #E6E6E6;
|
||||
}
|
||||
|
||||
.blank_item {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<el-col>
|
||||
<header-menus/>
|
||||
<track-header-menus/>
|
||||
<div>
|
||||
<transition>
|
||||
<keep-alive>
|
||||
|
@ -13,11 +13,11 @@
|
|||
|
||||
<script>
|
||||
|
||||
import HeaderMenus from "./head/HeaderMenus";
|
||||
import TrackHeaderMenus from "./head/TrackHeaderMenus";
|
||||
|
||||
export default {
|
||||
name: "TrackHome",
|
||||
components: {HeaderMenus},
|
||||
components: {TrackHeaderMenus},
|
||||
data() {
|
||||
return {
|
||||
beaseUrl: "track"
|
||||
|
|
|
@ -72,23 +72,22 @@
|
|||
treeNodes: []
|
||||
}
|
||||
},
|
||||
created: function () {
|
||||
this.caseId = this.$route.params.caseId;
|
||||
created() {
|
||||
this.getProjects();
|
||||
},
|
||||
mounted() {
|
||||
if (this.$route.path.indexOf("/track/case/edit") >= 0){
|
||||
this.openRecentTestCaseEditDialog();
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'$route'(to, from) {
|
||||
let path = to.path;
|
||||
if (path.indexOf("/track/case/all") >= 0){
|
||||
this.getProjects();
|
||||
this.refresh();
|
||||
}
|
||||
if (path.indexOf("/track/case/edit") >= 0){
|
||||
let caseId = this.$route.params.caseId;
|
||||
this.$get('/test/case/get/' + caseId, response => {
|
||||
console.log(response.data);
|
||||
this.openTestCaseEditDialog(response.data[0]);
|
||||
});
|
||||
this.openRecentTestCaseEditDialog();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -164,9 +163,24 @@
|
|||
this.$refs.testCaseEditDialog.maintainerOptions = response.data;
|
||||
});
|
||||
},
|
||||
getProjectByCaseId(caseId) {
|
||||
return this.$get('/test/case/project/' + caseId, async response => {
|
||||
localStorage.setItem(CURRENT_PROJECT, JSON.stringify(response.data));
|
||||
this.refresh();
|
||||
});
|
||||
},
|
||||
refresh() {
|
||||
this.$refs.testCaseList.initTableData();
|
||||
this.$refs.nodeTree.getNodeTree();
|
||||
this.getProjects();
|
||||
},
|
||||
openRecentTestCaseEditDialog() {
|
||||
let caseId = this.$route.params.caseId;
|
||||
this.getProjectByCaseId(caseId);
|
||||
this.refresh();
|
||||
this.$get('/test/case/get/' + caseId, response => {
|
||||
this.openTestCaseEditDialog(response.data[0]);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,7 +140,6 @@
|
|||
}
|
||||
},
|
||||
created: function () {
|
||||
|
||||
this.initTableData();
|
||||
},
|
||||
methods: {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
|
||||
<div id="menu-bar">
|
||||
<div id="menu-bar" v-if="isRouterAlive">
|
||||
<el-menu class="header-menu" :unique-opened="true" mode="horizontal" router
|
||||
:default-active='$route.path'>
|
||||
<el-menu-item :index="'/track/home'">
|
||||
|
@ -30,6 +30,7 @@
|
|||
<font-awesome-icon :icon="['fa', 'list-ul']"/>
|
||||
<span style="padding-left: 5px;">{{$t('test_track.case_list')}}</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item :index="testCaseEditPath" class="blank_item"></el-menu-item>
|
||||
<!--<el-menu-item :index="'/' + beaseUrl + '/case/create'">-->
|
||||
<!--<el-button type="text">{{$t('test_track.create_case')}}</el-button>-->
|
||||
<!--</el-menu-item>-->
|
||||
|
@ -40,11 +41,12 @@
|
|||
<template v-slot:title>{{$t('test_track.test_plan')}}</template>
|
||||
<recent-test-plan/>
|
||||
<el-divider/>
|
||||
<el-menu-item :index="'/track/plan/all'">
|
||||
<el-menu-item index="/track/plan/all">
|
||||
<font-awesome-icon :icon="['fa', 'list-ul']"/>
|
||||
<span style="padding-left: 5px;">{{$t('commons.show_all')}}</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item :index="'/track/plan/create'">
|
||||
<el-menu-item :index="testPlanViewPath" class="blank_item"></el-menu-item>
|
||||
<el-menu-item index="/track/plan/create">
|
||||
<el-button type="text">{{$t('test_track.create_plan')}}</el-button>
|
||||
</el-menu-item>
|
||||
</el-submenu>
|
||||
|
@ -53,7 +55,6 @@
|
|||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import {checkoutCurrentWorkspace} from "../../../../common/utils";
|
||||
|
@ -62,25 +63,45 @@
|
|||
import RecentTestPlan from "../plan/components/RecentTestPlan";
|
||||
|
||||
export default {
|
||||
name: "MsMenus",
|
||||
name: "TrackHeaderMenus",
|
||||
components: {RecentTestCase, TrackRecentProject, RecentTestPlan},
|
||||
data() {
|
||||
return {
|
||||
isCurrentWorkspaceUser: false,
|
||||
testPlanViewPath: '',
|
||||
isRouterAlive: true,
|
||||
testCaseEditPath: ''
|
||||
}
|
||||
},
|
||||
props: {
|
||||
beaseUrl: {
|
||||
type: String
|
||||
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();
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.isCurrentWorkspaceUser = checkoutCurrentWorkspace();
|
||||
},
|
||||
methods: {
|
||||
reload () {
|
||||
this.isRouterAlive = false;
|
||||
this.$nextTick(function () {
|
||||
this.isRouterAlive = true;
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<style>
|
||||
|
||||
.header-menu.el-menu--horizontal > li {
|
||||
|
@ -100,6 +121,8 @@
|
|||
margin-left: 20%;
|
||||
}
|
||||
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
<style scoped>
|
||||
|
@ -109,4 +132,8 @@
|
|||
#menu-bar {
|
||||
border-bottom: 1px solid #E6E6E6;
|
||||
}
|
||||
|
||||
.blank_item {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue