关联测试用例页面

This commit is contained in:
chenjianxing 2020-04-02 18:29:20 +08:00
parent d800a15a79
commit b3e14a641b
7 changed files with 95 additions and 115 deletions

View File

@ -34,7 +34,7 @@ public class TestCaseController {
} }
@PostMapping("/list") @PostMapping("/list")
public List<TestCase> getTestCaseByProjectId(@RequestBody List<Integer> nodeIds){ public List<TestCase> getTestCaseByNodeId(@RequestBody List<Integer> nodeIds){
return testCaseService.getTestCaseByNodeId(nodeIds); return testCaseService.getTestCaseByNodeId(nodeIds);
} }

View File

@ -20,6 +20,11 @@ public class TestCaseNodeController {
return testCaseNodeService.getNodeTreeByProjectId(projectId); return testCaseNodeService.getNodeTreeByProjectId(projectId);
} }
@GetMapping("/list/all/plan/{planId}")
public List<TestCaseNodeDTO> getAllNodeByPlanId(@PathVariable String planId){
return testCaseNodeService.getAllNodeByPlanId(planId);
}
@GetMapping("/list/plan/{planId}") @GetMapping("/list/plan/{planId}")
public List<TestCaseNodeDTO> getNodeByPlanId(@PathVariable String planId){ public List<TestCaseNodeDTO> getNodeByPlanId(@PathVariable String planId){
return testCaseNodeService.getNodeByPlanId(planId); return testCaseNodeService.getNodeByPlanId(planId);

View File

@ -113,6 +113,12 @@ public class TestCaseNodeService {
return testCaseNodeMapper.deleteByExample(testCaseNodeExample); return testCaseNodeMapper.deleteByExample(testCaseNodeExample);
} }
/**
* 获取当前计划下
* 有关联数据的节点
* @param planId
* @return
*/
public List<TestCaseNodeDTO> getNodeByPlanId(String planId) { public List<TestCaseNodeDTO> getNodeByPlanId(String planId) {
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(planId); TestPlan testPlan = testPlanMapper.selectByPrimaryKey(planId);
@ -177,4 +183,8 @@ public class TestCaseNodeService {
return false; return false;
} }
public List<TestCaseNodeDTO> getAllNodeByPlanId(String planId) {
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(planId);
return getNodeTreeByProjectId(testPlan.getProjectId());
}
} }

View File

@ -51,9 +51,8 @@
get() { get() {
}, },
openTestCaseRelevanceDialog(data) { openTestCaseRelevanceDialog() {
this.$refs.testCaseRelevance.dialogFormVisible = true; this.$refs.testCaseRelevance.openTestCaseRelevanceDialog(this.planId);
this.$refs.testCaseRelevance.getCaseNames(this.planId);
}, },
getCaseByNodeIds() { getCaseByNodeIds() {

View File

@ -18,12 +18,11 @@
</el-tree> </el-tree>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: "NodeTree", name: "PlanNodeTree",
data() { data() {
return { return {
filterText: '', filterText: '',
@ -31,31 +30,23 @@
children: 'children', children: 'children',
label: 'label' label: 'label'
}, },
form: {
name: '',
},
formLabelWidth: '80px',
dialogTableVisible: false, dialogTableVisible: false,
dialogFormVisible: false,
editType: '',
editData: {},
treeNodes: [],
defaultKeys: [] defaultKeys: []
}; };
}, },
props: { props: {
planId: { planId: {
type: String type: String
} },
treeNodes: {
Array
},
}, },
watch: { watch: {
filterText(val) { filterText(val) {
this.$refs.tree.filter(val); this.$refs.tree.filter(val);
} }
}, },
created() {
this.getNodeTree();
},
methods: { methods: {
handleDragEnd(draggingNode, dropNode, dropType, ev) { handleDragEnd(draggingNode, dropNode, dropType, ev) {
let param = {}; let param = {};
@ -91,7 +82,7 @@
if (!value) return true; if (!value) return true;
return data.label.indexOf(value) !== -1; return data.label.indexOf(value) !== -1;
}, },
getNodeTree() { getNodeTreeByNodeIds() {
if(this.planId){ if(this.planId){
this.$get("/case/node/list/plan/" + this.planId, response => { this.$get("/case/node/list/plan/" + this.planId, response => {
this.treeNodes = response.data; this.treeNodes = response.data;

View File

@ -8,9 +8,9 @@
<span class="title">{{$t('test_track.test_case')}}</span> <span class="title">{{$t('test_track.test_case')}}</span>
</el-col> </el-col>
<el-col :span="1" :offset="8"> <el-col :span="1" :offset="6">
<el-button icon="el-icon-circle-plus-outline" size="small" round <el-button icon="el-icon-circle-plus-outline" size="small" round
@click="$emit('openTestCaseRelevanceDialog')" >{{$t('commons.create')}}</el-button> @click="$emit('openTestCaseRelevanceDialog')" >关联测试用例</el-button>
</el-col> </el-col>
<el-col :span="1" > <el-col :span="1" >

View File

@ -2,32 +2,35 @@
<div> <div>
<el-dialog :title="$t('test_track.create')" <el-dialog title="关联测试用例"
:visible.sync="dialogFormVisible" :visible.sync="dialogFormVisible"
width="65%"> width="65%">
<el-container style="min-height: 350px"> <el-container class="main-content">
<el-aside class="node_tree" width="200px" style="background-color: rgb(238, 241, 246)"> <el-aside class="node-tree" width="250px">
<plan-node-tree></plan-node-tree> <plan-node-tree
:tree-nodes="treeNodes" ref="tree"></plan-node-tree>
</el-aside> </el-aside>
<el-container> <el-container>
<el-header > <el-main class="case-content">
<el-checkbox ></el-checkbox>
</el-header>
<el-main style="height: 100px;">
<el-scrollbar style="height:100%"> <el-scrollbar style="height:100%">
<el-table <el-table
:data="testCases"> :data="testCases"
row-key="id"
@select-all="handleSelectAll"
@select="handleSelectionChange"
ref="table">
<el-table-column
type="selection"
:reserve-selection="true"></el-table-column>
<el-table-column <el-table-column
prop="name" prop="name"
label="用例名称"
style="width: 100%"> style="width: 100%">
<template slot="header">
<el-checkbox v-model="checkAll"></el-checkbox>
用例名称
</template>
<template slot-scope="scope"> <template slot-scope="scope">
<el-checkbox v-model="scope.row.checked"></el-checkbox>
{{scope.row.name}} {{scope.row.name}}
</template> </template>
</el-table-column> </el-table-column>
@ -35,11 +38,8 @@
</el-scrollbar> </el-scrollbar>
</el-main> </el-main>
</el-container> </el-container>
</el-container> </el-container>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button <el-button
@click="dialogFormVisible = false"> @click="dialogFormVisible = false">
@ -47,13 +47,12 @@
</el-button> </el-button>
<el-button <el-button
type="primary" type="primary"
@click="saveCase"> @click="saveCaseRelevance">
{{$t('test_track.confirm')}} {{$t('test_track.confirm')}}
</el-button> </el-button>
</div> </div>
</el-dialog> </el-dialog>
</div> </div>
@ -61,94 +60,31 @@
<script> <script>
import {CURRENT_PROJECT} from '../../../../../common/constants';
import PlanNodeTree from './PlanNodeTree'; import PlanNodeTree from './PlanNodeTree';
export default { export default {
name: "TestCaseEdit", name: "TestCaseRelevance",
components: {PlanNodeTree}, components: {PlanNodeTree},
data() { data() {
return { return {
dialogFormVisible: false, dialogFormVisible: false,
count: 6, isCheckAll: false,
checkAll: false,
testCases: [], testCases: [],
form: { selectIds: new Set(),
name: '', treeNodes: []
}
}; };
}, },
methods: { methods: {
openTestCaseEditDialog(testCase) { openTestCaseRelevanceDialog(planId) {
this.resetForm(); console.log(planId);
this.operationType = 'add'; this.getNodeTreeByPlanId(planId);
if(testCase){ console.log(this.$refs);
// this.getCaseNames(planId);
this.operationType = 'edit';
let tmp = {};
Object.assign(tmp, testCase);
tmp.steps = JSON.parse(testCase.steps);
Object.assign(this.form, tmp);
this.form.module = testCase.nodeId;
}
this.dialogFormVisible = true; this.dialogFormVisible = true;
}, },
handleAddStep(index, data) { saveCaseRelevance(){
let step = {};
step.num = data.num + 1;
step.desc = null;
step.result = null;
this.form.steps.forEach(step => {
if(step.num > data.num){
step.num ++;
}
});
this.form.steps.push(step);
},
handleDeleteStep(index, data) {
this.form.steps.splice(index, 1);
this.form.steps.forEach(step => {
if(step.num > data.num){
step.num --;
}
});
},
saveCase(){
this.$refs['relevanceFrom'].validate((valid) => {
if (valid) {
let param = {};
Object.assign(param, this.form);
param.steps = JSON.stringify(this.form.steps);
param.nodeId = this.form.module;
this.moduleOptions.forEach(item => {
if(this.form.module === item.id){
param.nodePath = item.path;
}
});
if(localStorage.getItem(CURRENT_PROJECT)) {
param.projectId = JSON.parse(localStorage.getItem(CURRENT_PROJECT)).id;
}
this.$post('/test/case/' + this.operationType, param, () => {
this.$message.success(this.$t('commons.save_success'));
this.dialogFormVisible = false;
this.$emit("refresh");
});
} else {
return false;
}
});
}
,
resetForm() {
if (this.$refs['relevanceFrom']) {
this.$refs['relevanceFrom'].resetFields();
}
}, },
load () {
this.count += 2
},
getCaseNames(planId) { getCaseNames(planId) {
if(planId){ if(planId){
let param = {}; let param = {};
@ -160,7 +96,37 @@
}); });
}); });
} }
},
checkAll() {
this.testCases.forEach(item => {
item.checked = this.isCheckAll;
});
this.dialogFormVisible = true;
},
handleSelectAll(selection) {
if(selection.length > 0){
this.testCases.forEach(item => {
this.selectIds.add(item.id);
});
} else {
this.selectIds.clear();
} }
},
handleSelectionChange(selection, row) {
if(this.selectIds.has(row.id)){
this.selectIds.delete(row.id);
} else {
this.selectIds.add(row.id);
}
},
getNodeTreeByPlanId(planId) {
if(planId){
this.$get("/case/node/list/all/plan/" + planId, response => {
this.treeNodes = response.data;
});
}
}
} }
} }
</script> </script>
@ -180,10 +146,11 @@
} }
.node_tree{ .node-tree{
/*border-radius: 1px;*/ /*border-radius: 1px;*/
/*padding-top: 5px ;*/ /*padding-top: 5px ;*/
/*height: 100%;*/ /*height: 100%;*/
margin-right: 5px;
/*box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04);*/ /*box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04);*/
} }
@ -195,7 +162,15 @@
} }
.el-aside { .el-aside {
color: #333; /*color: #333;*/
/*background-color: rgb(238, 241, 246)*/
}
.case-content {
height: 100%;
}
.main-content {
min-height: 300px;
} }
</style> </style>