提交 78c82517 编写于 作者: C chenjianxing

修改测试用例head

上级 d60dc5ec
......@@ -42,6 +42,11 @@ public class ProjectController {
return projectService.getRecentProjectList(request);
}
@GetMapping("/get/{id}")
public Project getProject(@PathVariable String id) {
return projectService.getProjectById(id);
}
@PostMapping("/add")
@RequiresRoles(RoleConstants.TEST_MANAGER)
public Project addProject(@RequestBody Project project) {
......
......@@ -50,7 +50,7 @@ public class TestCaseController {
}
@GetMapping("/get/{testCaseId}")
public List<TestCaseWithBLOBs> getTestCase(@PathVariable String testCaseId){
public TestCaseWithBLOBs getTestCase(@PathVariable String testCaseId){
return testCaseService.getTestCase(testCaseId);
}
......
......@@ -74,4 +74,8 @@ public class ProjectService {
example.setOrderByClause("update_time desc");
return projectMapper.selectByExample(example);
}
public Project getProjectById(String id) {
return projectMapper.selectByPrimaryKey(id);
}
}
......@@ -54,10 +54,8 @@ public class TestCaseService {
return testCaseMapper.selectByExample(testCaseExample);
}
public List<TestCaseWithBLOBs> getTestCase(String testCaseId) {
TestCaseExample testCaseExample = new TestCaseExample();
testCaseExample.createCriteria().andIdEqualTo(testCaseId);
return testCaseMapper.selectByExampleWithBLOBs(testCaseExample);
public TestCaseWithBLOBs getTestCase(String testCaseId) {
return testCaseMapper.selectByPrimaryKey(testCaseId);
}
public int editTestCase(TestCaseWithBLOBs testCase) {
......
......@@ -52,7 +52,6 @@
data() {
return {
result: {},
projectId: null,
tableData: [],
multipleSelection: [],
currentPage: 1,
......@@ -67,15 +66,19 @@
this.getProjects();
},
mounted() {
if (this.$route.params.projectId){
this.getProjectById(this.$route.params.projectId)
}
if (this.$route.path.indexOf("/track/case/edit") >= 0){
this.openRecentTestCaseEditDialog();
this.$router.push('/track/case/all');
}
},
watch: {
'$route'(to, from) {
let path = to.path;
if (path.indexOf("/track/case/all") >= 0){
this.refresh();
if (to.params.projectId){
this.getProjectById(to.params.projectId)
}
if (path.indexOf("/track/case/edit") >= 0){
this.openRecentTestCaseEditDialog();
......@@ -87,9 +90,9 @@
getProjects() {
this.$get("/project/listAll", (response) => {
this.projects = response.data;
if (localStorage.getItem(CURRENT_PROJECT)) {
let lastProject = JSON.parse(localStorage.getItem(CURRENT_PROJECT));
let hasCurrentProject = false;
let lastProject = JSON.parse(localStorage.getItem(CURRENT_PROJECT));
if (lastProject) {
let hasCurrentProject = false;
for (let i = 0; i < this.projects.length; i++) {
if (this.projects[i].id == lastProject.id) {
this.currentProject = lastProject;
......@@ -100,14 +103,9 @@
if (!hasCurrentProject) {
this.currentProject = null;
}
if(this.projects.length > 0){
this.currentProject = this.projects[0];
localStorage.setItem(CURRENT_PROJECT, JSON.stringify(this.projects[0]));
}
} else {
if(this.projects.length > 0){
this.currentProject = this.projects[0];
localStorage.setItem(CURRENT_PROJECT, JSON.stringify(this.projects[0]));
this.setCurrentProject(this.projects[0]);
}
}
// this.checkProject();
......@@ -124,8 +122,7 @@
}
},
changeProject(project) {
this.currentProject = project;
localStorage.setItem(CURRENT_PROJECT, JSON.stringify(project));
this.setCurrentProject(project);
},
refreshTable(data) {
this.$refs.testCaseList.initTableData(data);
......@@ -161,8 +158,7 @@
},
getProjectByCaseId(caseId) {
return this.$get('/test/case/project/' + caseId, async response => {
localStorage.setItem(CURRENT_PROJECT, JSON.stringify(response.data));
this.refresh();
this.setCurrentProject(response.data);
});
},
refresh() {
......@@ -173,11 +169,32 @@
openRecentTestCaseEditDialog() {
let caseId = this.$route.params.caseId;
this.getProjectByCaseId(caseId);
this.refresh();
// this.refresh();
this.$get('/test/case/get/' + caseId, response => {
this.openTestCaseEditDialog(response.data[0]);
if (response.data) {
this.openTestCaseEditDialog(response.data);
}
});
},
getProjectById(id) {
if (id && id != 'all'){
this.$get('/project/get/' + id, response => {
let project = response.data;
this.setCurrentProject(project);
});
}
if (id === 'all') {
this.refresh();
}
},
setCurrentProject(project) {
if (project) {
this.currentProject = project;
localStorage.setItem(CURRENT_PROJECT, JSON.stringify(project));
}
this.refresh();
}
}
}
</script>
......
<template>
<el-menu router menu-trigger="click" :default-active="$route.path">
<div class="recent-text">
<i class="el-icon-time"/>
{{$t('load_test.recent')}}
</div>
<el-menu-item :key="t.id" v-for="t in recentTestCases"
:index="'/track/case/edit/' + t.id">
{{ t.name }}
</el-menu-item>
</el-menu>
</template>
<script>
import {ROLE_TEST_MANAGER, ROLE_TEST_USER, ROLE_TEST_VIEWER} from "../../../../../common/constants";
export default {
name: "RecentTestCase",
mounted() {
const rolesString = localStorage.getItem("roles");
const roles = rolesString.split(',');
if (roles.indexOf(ROLE_TEST_MANAGER) > -1 || roles.indexOf(ROLE_TEST_USER) > -1 || roles.indexOf(ROLE_TEST_VIEWER) > -1) {
this.$get('/test/case/recent/5', (response) => {
this.recentTestCases = response.data;
});
}
},
data() {
return {
recentTestCases: []
}
}
}
</script>
<style scoped>
.recent-text {
padding-left: 10%;
color: #777777;
}
</style>
<template>
<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'">
{{ $t("i18n.home") }}
</el-menu-item>
<el-submenu v-if="isCurrentWorkspaceUser"
index="3" popper-class="submenu" v-permission="['test_manager']" >
<template v-slot:title>{{$t('commons.project')}}</template>
<track-recent-project/>
<el-divider/>
<el-menu-item :index="'/track/project/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/project/create'">
<el-button type="text">{{$t('project.create')}}</el-button>
</el-menu-item>
</el-submenu>
<el-submenu v-if="isCurrentWorkspaceUser"
index="6" popper-class="submenu" v-permission="['test_manager', 'test_user']">
<template v-slot:title>{{$t('test_track.test_case')}}</template>
<recent-test-case/>
<el-divider/>
<el-menu-item :index="'/track/case/all'">
<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-submenu>
<el-submenu v-if="isCurrentWorkspaceUser"
index="7" popper-class="submenu" v-permission="['test_manager', 'test_user', 'test_viewer']">
<template v-slot:title>{{$t('test_track.test_plan')}}</template>
<recent-test-plan/>
<el-divider/>
<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="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>
</el-menu>
<el-row type="flex">
<el-col :span="8">
<el-menu class="header-menu" :unique-opened="true" mode="horizontal" router
:default-active='$route.path'>
<el-menu-item :index="'/track/home'">
{{ $t("i18n.home") }}
</el-menu-item>
<el-submenu v-if="isCurrentWorkspaceUser"
index="3" popper-class="submenu" v-permission="['test_manager']" >
<template v-slot:title>{{$t('commons.project')}}</template>
<ms-recent-list :options="projectRecent"/>
<el-divider/>
<ms-show-all :index="'/track/project/all'"/>
<ms-create-button :index="'/track/project/create'" :title="$t('project.create')"/>
</el-submenu>
<el-submenu v-if="isCurrentWorkspaceUser"
index="6" popper-class="submenu" v-permission="['test_manager', 'test_user']">
<template v-slot:title>{{$t('test_track.test_case')}}</template>
<ms-recent-list :options="testRecent"/>
<el-divider/>
<ms-show-all :index="'/track/case/all'"/>
<el-menu-item :index="testCaseEditPath" class="blank_item"></el-menu-item>
</el-submenu>
<el-submenu v-if="isCurrentWorkspaceUser"
index="7" popper-class="submenu" v-permission="['test_manager', 'test_user', 'test_viewer']">
<template v-slot:title>{{$t('test_track.test_plan')}}</template>
<ms-recent-list :options="planRecent"/>
<el-divider/>
<ms-show-all :index="'/track/plan/all'"/>
<el-menu-item :index="testPlanViewPath" class="blank_item"></el-menu-item>
<ms-create-button :index="'/track/plan/create'" :title="$t('project.create')"/>
</el-submenu>
</el-menu>
</el-col>
</el-row>
</div>
</template>
<script>
import {checkoutCurrentWorkspace} from "../../../../common/utils";
import TrackRecentProject from "../../track/project/TrackRecentProject";
import RecentTestCase from "../case/components/RecentTestCase";
import RecentTestPlan from "../plan/components/RecentTestPlan";
import MsShowAll from "../../common/head/ShowAll";
import MsRecentList from "../../common/head/RecentList";
import MsCreateButton from "../../common/head/CreateButton";
export default {
name: "TrackHeaderMenus",
components: {RecentTestCase, TrackRecentProject, RecentTestPlan},
components: {MsShowAll, MsRecentList, MsCreateButton},
data() {
return {
isCurrentWorkspaceUser: false,
testPlanViewPath: '',
isRouterAlive: true,
testCaseEditPath: ''
testCaseEditPath: '',
projectRecent: {
title: this.$t('project.recent'),
url: "/project/recent/5",
index: function (item) {
return '/track/case/' + item.id;
},
router: function (item) {
return {name: 'testCase', params: {projectId: item.id, projectName: item.name}}
}
},
testRecent: {
title: this.$t('load_test.recent'),
url: "/test/case/recent/5",
index: function (item) {
return '/track/case/edit/' + item.id;
},
router: function (item) {}
},
planRecent: {
title: this.$t('report.recent'),
url: "/test/plan/recent/5",
index: function (item) {
return '/track/plan/view/' + item.id;
},
router: function (item) {}
}
}
},
watch: {
......@@ -133,4 +151,8 @@
.blank_item {
display: none;
}
.el-divider--horizontal {
margin: 0;
}
</style>
<template>
<el-menu router menu-trigger="click" :default-active="$route.path">
<div class="recent-text">
<i class="el-icon-time"/>
{{$t('load_test.recent')}}
</div>
<el-menu-item :key="t.id" v-for="t in recentTestPlans"
:index="'/track/plan/view/' + t.id">
{{ t.name }}
</el-menu-item>
</el-menu>
</template>
<script>
import {ROLE_TEST_MANAGER, ROLE_TEST_USER, ROLE_TEST_VIEWER} from "../../../../../common/constants";
export default {
name: "RecentTestPlan",
mounted() {
const rolesString = localStorage.getItem("roles");
const roles = rolesString.split(',');
if (roles.indexOf(ROLE_TEST_MANAGER) > -1 || roles.indexOf(ROLE_TEST_USER) > -1 || roles.indexOf(ROLE_TEST_VIEWER) > -1) {
this.$get('/test/plan/recent/5', (response) => {
this.recentTestPlans = response.data;
});
}
},
data() {
return {
recentTestPlans: []
}
}
}
</script>
<style scoped>
.recent-text {
padding-left: 10%;
color: #777777;
}
</style>
<template>
<el-menu router menu-trigger="click" :default-active="$route.path">
<div class="recent-text">
<i class="el-icon-time"/>
{{$t('project.recent')}}
</div>
<el-menu-item :key="p.id" v-for="p in recentProjects"
@click="routeToTestCase(p)">
{{ p.name }}
</el-menu-item>
</el-menu>
</template>
<script>
import {ROLE_TEST_MANAGER, ROLE_TEST_USER, ROLE_TEST_VIEWER, CURRENT_PROJECT} from "../../../../common/constants";
import {hasRoles} from "../../../../common/utils";
export default {
name: "TrackRecentProject",
mounted() {
if (hasRoles(ROLE_TEST_VIEWER, ROLE_TEST_USER, ROLE_TEST_MANAGER)) {
this.$get('/project/recent/5', (response) => {
this.recentProjects = response.data;
});
}
},
data() {
return {
recentProjects: [],
}
},
methods: {
routeToTestCase(project) {
localStorage.setItem(CURRENT_PROJECT, JSON.stringify(project));
if(this.$router.currentRoute.path === '/track/case/all'){
this.$router.go(0);
} else {
this.$router.push("/track/case/all");
}
}
}
}
</script>
<style scoped>
.recent-text {
padding-left: 10%;
color: #777777;
}
</style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册