测试详情添加测试计划菜单栏

This commit is contained in:
chenjianxing 2020-04-09 13:51:04 +08:00
parent f735d4c953
commit 3c59765b2a
7 changed files with 125 additions and 37 deletions

View File

@ -34,6 +34,12 @@ public class TestPlanController {
return PageUtils.setPageInfo(page, testPlanService.listTestPlan(request)); return PageUtils.setPageInfo(page, testPlanService.listTestPlan(request));
} }
@PostMapping("/list/all")
public List<TestPlan> listAll() {
String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId();
return testPlanService.listTestAllPlan(currentWorkspaceId);
}
@GetMapping("recent/{count}") @GetMapping("recent/{count}")
public List<TestPlan> recentTestPlans(@PathVariable int count) { public List<TestPlan> recentTestPlans(@PathVariable int count) {

View File

@ -116,4 +116,10 @@ public class TestPlanService {
testPlanTestCaseExample.setOrderByClause("update_time desc"); testPlanTestCaseExample.setOrderByClause("update_time desc");
return testPlanMapper.selectByExample(testPlanTestCaseExample); return testPlanMapper.selectByExample(testPlanTestCaseExample);
} }
public List<TestPlan> listTestAllPlan(String currentWorkspaceId) {
TestPlanExample testPlanExample = new TestPlanExample();
testPlanExample.createCriteria().andWorkspaceIdEqualTo(currentWorkspaceId);
return testPlanMapper.selectByExample(testPlanExample);
}
} }

View File

@ -130,6 +130,7 @@
let orgId = data.id; let orgId = data.id;
this.$post("/user/switch/source/org/" + orgId, {}, response => { this.$post("/user/switch/source/org/" + orgId, {}, response => {
localStorage.setItem(TokenKey, JSON.stringify(response.data)); localStorage.setItem(TokenKey, JSON.stringify(response.data));
this.$router.push('/');
window.location.reload(); window.location.reload();
}) })
}, },
@ -141,6 +142,7 @@
this.$post("/user/switch/source/ws/" + workspaceId, {}, response => { this.$post("/user/switch/source/ws/" + workspaceId, {}, response => {
localStorage.setItem(TokenKey, JSON.stringify(response.data)); localStorage.setItem(TokenKey, JSON.stringify(response.data));
localStorage.setItem("workspace_id", workspaceId); localStorage.setItem("workspace_id", workspaceId);
this.$router.push('/');
window.location.reload(); window.location.reload();
}) })
} }

View File

@ -3,29 +3,19 @@
<el-container> <el-container>
<el-aside width="250px"> <el-aside width="250px">
<el-menu :unique-opened="true" mode="horizontal" active-text-color="write" <select-menu
class="project_menu"> :data="projects"
<el-submenu index="1" popper-class="submenu"> :current-data="currentProject"
<template v-slot:title> :title="'项目'"
{{currentProject == null ? '' : currentProject.name}} @dataChange="changeProject">
</template> </select-menu>
<div style="height:400px;">
<el-scrollbar style="height:100%">
<label v-for="(item,index) in projects" :key="index">
<el-menu-item @click="changeProject(item)">
{{item.name}}
<i class="el-icon-check" v-if="currentProject && item.id === currentProject.id"></i>
</el-menu-item>
</label>
</el-scrollbar>
</div>
</el-submenu>
</el-menu>
<node-tree class="node_tree" <node-tree class="node_tree"
:current-project="currentProject" :current-project="currentProject"
@nodeSelectEvent="refreshTable" @nodeSelectEvent="refreshTable"
@refresh="refreshTable" @refresh="refreshTable"
ref="nodeTree"></node-tree> ref="nodeTree">
</node-tree>
</el-aside> </el-aside>
<el-main class="main-content"> <el-main class="main-content">
@ -34,10 +24,10 @@
:current-project="currentProject" :current-project="currentProject"
@openTestCaseEditDialog="openTestCaseEditDialog" @openTestCaseEditDialog="openTestCaseEditDialog"
@testCaseEdit="openTestCaseEditDialog" @testCaseEdit="openTestCaseEditDialog"
ref="testCaseList"></test-case-list> ref="testCaseList">
</test-case-list>
</el-main> </el-main>
</el-container> </el-container>
<test-case-edit <test-case-edit
@ -53,10 +43,11 @@
import TestCaseEdit from './components/TestCaseEdit'; import TestCaseEdit from './components/TestCaseEdit';
import {WORKSPACE_ID,CURRENT_PROJECT} from '../../../../common/constants'; import {WORKSPACE_ID,CURRENT_PROJECT} from '../../../../common/constants';
import TestCaseList from "./components/TestCaseList"; import TestCaseList from "./components/TestCaseList";
import SelectMenu from "../common/SelectMenu";
export default { export default {
name: "TestCase", name: "TestCase",
components: {TestCaseList, NodeTree, TestCaseEdit}, components: {TestCaseList, NodeTree, TestCaseEdit, SelectMenu},
comments: {}, comments: {},
data() { data() {
return { return {
@ -208,7 +199,7 @@
} }
.node_tree { .node_tree {
margin: 10%; margin: 5%;
} }
.project_menu { .project_menu {

View File

@ -0,0 +1,53 @@
<template>
<el-menu :unique-opened="true" mode="horizontal" active-text-color="write"
class="project_menu">
<el-submenu index="1" popper-class="submenu">
<template v-slot:title>
<span class="menu-title">{{'[' + title + ']'}}</span>
<span> {{currentData == null ? '' : currentData.name}} </span>
</template>
<template v-slot:default>
<div style="height:400px;">
<el-scrollbar style="height:100%">
<label v-for="(item,index) in data" :key="index">
<el-menu-item @click="changeData(item)">
{{item.name}}
<i class="el-icon-check" v-if="currentData && item.id === currentData.id"></i>
</el-menu-item>
</label>
</el-scrollbar>
</div>
</template>
</el-submenu>
</el-menu>
</template>
<script>
export default {
name: "SelectMenu",
props: {
data: {
type: Array
},
currentData: {
type: Object
},
title: {
type: String
}
},
methods: {
changeData(data) {
this.$emit("dataChange", data);
}
}
}
</script>
<style scoped>
.menu-title {
color: darkgrey;
}
</style>

View File

@ -2,12 +2,21 @@
<div class="plan_container"> <div class="plan_container">
<el-container> <el-container>
<el-aside class="node-tree" width="250px"> <el-aside class="aside-container" width="250px">
<select-menu
:data="testPlans"
:current-data="currentPlan"
:title="'计划'"
@dataChange="changePlan">
</select-menu>
<plan-node-tree <plan-node-tree
:tree-nodes="treeNodes" class="node_tree"
:plan-id="planId" :plan-id="planId"
@nodeSelectEvent="getPlanCases" @nodeSelectEvent="getPlanCases"
ref="tree"></plan-node-tree> ref="tree">
</plan-node-tree>
</el-aside> </el-aside>
<el-main> <el-main>
@ -30,7 +39,6 @@
@refresh="refresh"> @refresh="refresh">
</test-plan-test-case-edit> </test-plan-test-case-edit>
</div> </div>
</template> </template>
@ -41,13 +49,15 @@
import TestCasePlanList from "./components/TestCasePlanList"; import TestCasePlanList from "./components/TestCasePlanList";
import TestCaseRelevance from "./components/TestCaseRelevance"; import TestCaseRelevance from "./components/TestCaseRelevance";
import TestPlanTestCaseEdit from "./components/TestPlanTestCaseEdit"; import TestPlanTestCaseEdit from "./components/TestPlanTestCaseEdit";
import SelectMenu from "../common/SelectMenu";
export default { export default {
name: "TestPlanView", name: "TestPlanView",
components: {PlanNodeTree, TestCasePlanList, TestCaseRelevance, TestPlanTestCaseEdit}, components: {PlanNodeTree, TestCasePlanList, TestCaseRelevance, TestPlanTestCaseEdit, SelectMenu},
data() { data() {
return { return {
treeNodes: [] testPlans: [],
currentPlan: {}
} }
}, },
computed: { computed: {
@ -55,6 +65,14 @@
return this.$route.params.planId; return this.$route.params.planId;
} }
}, },
created() {
this.getTestPlans();
},
watch: {
planId() {
this.getTestPlans();
}
},
methods: { methods: {
refresh() { refresh() {
this.getPlanCases(); this.getPlanCases();
@ -71,7 +89,6 @@
Object.assign(item, testCase); Object.assign(item, testCase);
item.results = JSON.parse(item.results); item.results = JSON.parse(item.results);
item.steps = JSON.parse(item.steps); item.steps = JSON.parse(item.steps);
item.steptResults = []; item.steptResults = [];
for (let i = 0; i < item.steps.length; i++){ for (let i = 0; i < item.steps.length; i++){
if(item.results[i]){ if(item.results[i]){
@ -82,6 +99,20 @@
} }
this.$refs.testPlanTestCaseEdit.testCase = item; this.$refs.testPlanTestCaseEdit.testCase = item;
this.$refs.testPlanTestCaseEdit.dialog = true; this.$refs.testPlanTestCaseEdit.dialog = true;
},
getTestPlans() {
this.result = this.$post('/test/plan/list/all', {}, response => {
this.testPlans = response.data;
this.testPlans.forEach(plan => {
if (this.planId && plan.id === this.planId) {
this.currentPlan = plan;
}
});
});
},
changePlan(plan) {
this.currentPlan = plan;
this.$router.push('/track/plan/view/' + plan.id);
} }
} }
} }
@ -94,9 +125,12 @@
height: 600px; height: 600px;
} }
.node-tree { .aside-container {
margin-top: 2%;
margin-left: 15px; margin-left: 15px;
} }
.node_tree {
margin: 3%;
}
</style> </style>

View File

@ -139,7 +139,6 @@
currentPage: 1, currentPage: 1,
pageSize: 5, pageSize: 5,
total: 0, total: 0,
loadingRequire: {project: true, testCase: true},
testId: null, testId: null,
} }
}, },
@ -148,14 +147,11 @@
this.initTableData(); this.initTableData();
}, },
methods: { methods: {
initTableData(nodeIds) { initTableData() {
let param = { let param = {
name: this.condition, name: this.condition,
}; };
param.nodeIds = nodeIds;
this.result = this.$post(this.buildPagePath(this.queryPath), param, response => { this.result = this.$post(this.buildPagePath(this.queryPath), param, response => {
this.loadingRequire.testCase = false;
let data = response.data; let data = response.data;
this.total = data.itemCount; this.total = data.itemCount;
this.tableData = data.listObject; this.tableData = data.listObject;