refactor(测试跟踪): 关联测试用例一次加载全部优化

This commit is contained in:
fit2-zhao 2020-10-14 18:56:27 +08:00
parent a02cb2cc46
commit 92122e0546
6 changed files with 250 additions and 206 deletions

View File

@ -77,9 +77,10 @@ public class TestCaseController {
return testCaseService.getTestCaseNames(request);
}
@PostMapping("/reviews/case")
public List<TestCase> getReviewCase(@RequestBody QueryTestCaseRequest request) {
return testCaseService.getReviewCase(request);
@PostMapping("/reviews/case/{goPage}/{pageSize}")
public Pager<List<TestCase>> getReviewCase(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestCaseRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testCaseService.getReviewCase(request));
}
@GetMapping("/get/{testCaseId}")

View File

@ -34,7 +34,8 @@
"html2canvas": "^1.0.0-rc.7",
"jspdf": "^2.1.1",
"yan-progress": "^1.0.3",
"nprogress": "^0.2.0"
"nprogress": "^0.2.0",
"el-table-infinite-scroll": "^1.0.10"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^4.1.0",

View File

@ -11,7 +11,9 @@
<el-container class="main-content">
<el-aside class="tree-aside" width="250px">
<el-link type="primary" class="project-link" @click="switchProject">{{projectName ? projectName : $t('test_track.switch_project') }}</el-link>
<el-link type="primary" class="project-link" @click="switchProject">{{projectName ? projectName :
$t('test_track.switch_project') }}
</el-link>
<node-tree class="node-tree"
@nodeSelectEvent="nodeChange"
@refresh="refresh"
@ -21,9 +23,11 @@
<el-container>
<el-main class="case-content">
<ms-table-header :condition.sync="condition" @search="getReviews" title="" :show-create="false"/>
<ms-table-header :condition.sync="condition" @search="search" title="" :show-create="false"/>
<el-table
:data="testReviews"
v-el-table-infinite-scroll="loadData"
class="infinite-list"
@filter-change="filter"
row-key="id"
@select-all="handleSelectAll"
@ -72,7 +76,7 @@
</template>
</el-table-column>
</el-table>
<div style="text-align: center"> {{testReviews.length}} </div>
<div style="text-align: center"> {{total}} </div>
</el-main>
</el-container>
</el-container>
@ -90,216 +94,251 @@
<script>
import NodeTree from "../../../common/NodeTree";
import MsDialogFooter from "../../../../common/components/MsDialogFooter";
import PriorityTableItem from "../../../common/tableItems/planview/PriorityTableItem";
import TypeTableItem from "../../../common/tableItems/planview/TypeTableItem";
import MsTableSearchBar from "../../../../common/components/MsTableSearchBar";
import MsTableAdvSearchBar from "../../../../common/components/search/MsTableAdvSearchBar";
import MsTableHeader from "../../../../common/components/MsTableHeader";
import SwitchProject from "../../../case/components/SwitchProject";
import {TEST_CASE_CONFIGS} from "../../../../common/components/search/search-components";
import {_filter} from "../../../../../../common/js/utils";
import StatusTableItem from "@/business/components/track/common/tableItems/planview/StatusTableItem";
import NodeTree from "../../../common/NodeTree";
import MsDialogFooter from "../../../../common/components/MsDialogFooter";
import PriorityTableItem from "../../../common/tableItems/planview/PriorityTableItem";
import TypeTableItem from "../../../common/tableItems/planview/TypeTableItem";
import MsTableSearchBar from "../../../../common/components/MsTableSearchBar";
import MsTableAdvSearchBar from "../../../../common/components/search/MsTableAdvSearchBar";
import MsTableHeader from "../../../../common/components/MsTableHeader";
import SwitchProject from "../../../case/components/SwitchProject";
import {TEST_CASE_CONFIGS} from "../../../../common/components/search/search-components";
import {_filter} from "../../../../../../common/js/utils";
import StatusTableItem from "@/business/components/track/common/tableItems/planview/StatusTableItem";
import elTableInfiniteScroll from 'el-table-infinite-scroll';
export default {
name: "TestReviewRelevance",
components: {
NodeTree,
MsDialogFooter,
PriorityTableItem,
TypeTableItem,
MsTableSearchBar,
MsTableAdvSearchBar,
MsTableHeader,
SwitchProject,
StatusTableItem
},
data() {
return {
result: {},
dialogFormVisible: false,
isCheckAll: false,
testReviews: [],
selectIds: new Set(),
treeNodes: [],
selectNodeIds: [],
selectNodeNames: [],
projectId: '',
projectName: '',
projects: [],
condition: {
components: TEST_CASE_CONFIGS
export default {
name: "TestReviewRelevance",
components: {
NodeTree,
MsDialogFooter,
PriorityTableItem,
TypeTableItem,
MsTableSearchBar,
MsTableAdvSearchBar,
MsTableHeader,
SwitchProject,
StatusTableItem
},
directives: {
'el-table-infinite-scroll': elTableInfiniteScroll
},
data() {
return {
result: {},
dialogFormVisible: false,
isCheckAll: false,
testReviews: [],
tableData: [],
selectIds: new Set(),
treeNodes: [],
selectNodeIds: [],
selectNodeNames: [],
projectId: '',
projectName: '',
projects: [],
pageSize: 50,
currentPage: 1,
total: 0,
endStatus: true,
condition: {
components: TEST_CASE_CONFIGS
},
priorityFilters: [
{text: 'P0', value: 'P0'},
{text: 'P1', value: 'P1'},
{text: 'P2', value: 'P2'},
{text: 'P3', value: 'P3'}
],
typeFilters: [
{text: this.$t('commons.functional'), value: 'functional'},
{text: this.$t('commons.performance'), value: 'performance'},
{text: this.$t('commons.api'), value: 'api'}
],
statusFilters: [
{text: this.$t('test_track.case.status_prepare'), value: 'Prepare'},
{text: this.$t('test_track.case.status_pass'), value: 'Pass'},
{text: this.$t('test_track.case.status_un_pass'), value: 'UnPass'},
],
};
},
props: {
reviewId: {
type: String
}
},
watch: {
reviewId() {
this.initData();
},
priorityFilters: [
{text: 'P0', value: 'P0'},
{text: 'P1', value: 'P1'},
{text: 'P2', value: 'P2'},
{text: 'P3', value: 'P3'}
],
typeFilters: [
{text: this.$t('commons.functional'), value: 'functional'},
{text: this.$t('commons.performance'), value: 'performance'},
{text: this.$t('commons.api'), value: 'api'}
],
statusFilters: [
{text: this.$t('test_track.case.status_prepare'), value: 'Prepare'},
{text: this.$t('test_track.case.status_pass'), value: 'Pass'},
{text: this.$t('test_track.case.status_un_pass'), value: 'UnPass'},
],
};
},
props: {
reviewId: {
type: String
}
},
watch: {
reviewId() {
this.initData();
},
selectNodeIds() {
this.getReviews();
},
projectId() {
this.getProjectNode();
}
},
updated() {
this.toggleSelection(this.testReviews);
},
methods: {
openTestReviewRelevanceDialog() {
this.getProject();
this.initData();
this.dialogFormVisible = true;
},
saveReviewRelevance() {
let param = {};
param.reviewId = this.reviewId;
param.testCaseIds = [...this.selectIds];
this.result = this.$post('/test/case/review/relevance', param, () => {
this.selectIds.clear();
this.$success(this.$t('commons.save_success'));
this.dialogFormVisible = false;
this.$emit('refresh');
});
},
getReviews() {
if (this.reviewId) {
this.condition.reviewId = this.reviewId;
}
if (this.selectNodeIds && this.selectNodeIds.length > 0) {
this.condition.nodeIds = this.selectNodeIds;
} else {
this.condition.nodeIds = [];
selectNodeIds() {
this.search();
},
projectId() {
this.getProjectNode();
}
},
updated() {
this.toggleSelection(this.testReviews);
},
methods: {
openTestReviewRelevanceDialog() {
this.getProject();
this.initData();
this.dialogFormVisible = true;
},
saveReviewRelevance() {
let param = {};
param.reviewId = this.reviewId;
param.testCaseIds = [...this.selectIds];
this.result = this.$post('/test/case/review/relevance', param, () => {
this.selectIds.clear();
this.$success(this.$t('commons.save_success'));
this.dialogFormVisible = false;
this.$emit('refresh');
});
},
buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize;
},
getReviews() {
if (this.reviewId) {
this.condition.reviewId = this.reviewId;
}
if (this.selectNodeIds && this.selectNodeIds.length > 0) {
this.condition.nodeIds = this.selectNodeIds;
} else {
this.condition.nodeIds = [];
}
if (this.projectId) {
this.condition.projectId = this.projectId;
this.result = this.$post('/test/case/reviews/case', this.condition, response => {
this.testReviews = response.data;
this.testReviews.forEach(item => {
item.checked = false;
if (this.projectId) {
this.condition.projectId = this.projectId;
this.result = this.$post(this.buildPagePath('/test/case/reviews/case'), this.condition, response => {
let data = response.data;
this.total = data.itemCount;
this.tableData = data.listObject;
this.endStatus = this.tableData.length === 50;
this.tableData.forEach(item => {
item.checked = false;
});
this.testReviews = this.testReviews.concat(this.tableData);
});
});
}
}
},
handleSelectAll(selection) {
if (selection.length > 0) {
this.testReviews.forEach(item => {
this.selectIds.add(item.id);
});
} else {
// this.selectIds.clear();
this.testReviews.forEach(item => {
if (this.selectIds.has(item.id)) {
this.selectIds.delete(item.id);
}
});
}
},
handleSelectionChange(selection, row) {
if (this.selectIds.has(row.id)) {
this.selectIds.delete(row.id);
} else {
this.selectIds.add(row.id);
}
},
nodeChange(nodeIds, nodeNames) {
this.selectNodeIds = nodeIds;
this.selectNodeNames = nodeNames;
},
initData() {
this.getReviews();
this.getAllNodeTreeByPlanId();
},
refresh() {
this.close();
},
getAllNodeTreeByPlanId() {
if (this.reviewId) {
let param = {
reviewId: this.reviewId,
projectId: this.projectId
};
this.result = this.$post("/case/node/list/all/review", param , response => {
this.treeNodes = response.data;
});
}
},
close() {
this.selectIds.clear();
this.selectNodeIds = [];
this.selectNodeNames = [];
},
filter(filters) {
_filter(filters, this.condition);
this.initData();
},
toggleSelection(rows) {
rows.forEach(row => {
this.selectIds.forEach(id => {
if (row.id === id) {
// true
this.$refs.table.toggleRowSelection(row, true)
}
},
handleSelectAll(selection) {
if (selection.length > 0) {
this.testReviews.forEach(item => {
this.selectIds.add(item.id);
});
} else {
// this.selectIds.clear();
this.testReviews.forEach(item => {
if (this.selectIds.has(item.id)) {
this.selectIds.delete(item.id);
}
});
}
},
handleSelectionChange(selection, row) {
if (this.selectIds.has(row.id)) {
this.selectIds.delete(row.id);
} else {
this.selectIds.add(row.id);
}
},
nodeChange(nodeIds, nodeNames) {
this.selectNodeIds = nodeIds;
this.selectNodeNames = nodeNames;
},
initData() {
// this.testReviews=[];
// this.getReviews();
// this.getAllNodeTreeByPlanId();
},
refresh() {
this.close();
},
getAllNodeTreeByPlanId() {
if (this.reviewId) {
let param = {
reviewId: this.reviewId,
projectId: this.projectId
};
this.result = this.$post("/case/node/list/all/review", param, response => {
this.treeNodes = response.data;
});
}
},
close() {
this.endStatus = false;
this.selectIds.clear();
this.selectNodeIds = [];
this.selectNodeNames = [];
this.tableData = [];
},
filter(filters) {
_filter(filters, this.condition);
this.search();
},
toggleSelection(rows) {
rows.forEach(row => {
this.selectIds.forEach(id => {
if (row.id === id) {
// true
this.$refs.table.toggleRowSelection(row, true)
}
})
})
})
},
getProject() {
if (this.reviewId) {
this.$post("/test/case/review/projects", {reviewId: this.reviewId},res => {
let data = res.data;
if (data) {
this.projects = data;
this.projectId = data[0].id;
this.projectName = data[0].name;
},
getProject() {
if (this.reviewId) {
this.$post("/test/case/review/projects", {reviewId: this.reviewId}, res => {
let data = res.data;
if (data) {
this.projects = data;
this.projectId = data[0].id;
this.projectName = data[0].name;
}
})
}
},
switchProject() {
this.$refs.switchProject.open({id: this.reviewId, url: '/test/case/review/project/', type: 'review'});
},
loadData() {
if (this.dialogFormVisible) {
if (this.endStatus === true) {
this.currentPage += 1;
this.getReviews();
} else {
this.$message.warning(this.$t('test_track.review_view.last_page'));
}
})
}
},
switchProject() {
this.$refs.switchProject.open({id: this.reviewId, url : '/test/case/review/project/', type: 'review'});
},
getProjectNode(projectId) {
const index = this.projects.findIndex(project => project.id === projectId);
if (index !== -1) {
this.projectName = this.projects[index].name;
}
if (projectId) {
this.projectId = projectId;
}
this.result = this.$post("/case/node/list/all/review",
{reviewId: this.reviewId, projectId: this.projectId} , response => {
this.treeNodes = response.data;
});
}
},
search() {
this.currentPage = 1;
this.testReviews = [];
this.getReviews();
},
this.selectNodeIds = [];
getProjectNode(projectId) {
const index = this.projects.findIndex(project => project.id === projectId);
if (index !== -1) {
this.projectName = this.projects[index].name;
}
if (projectId) {
this.projectId = projectId;
}
this.result = this.$post("/case/node/list/all/review",
{reviewId: this.reviewId, projectId: this.projectId}, response => {
this.treeNodes = response.data;
});
this.selectNodeIds = [];
}
}
}
}
</script>
<style scoped>

View File

@ -807,6 +807,7 @@ export default {
all_case: "All case",
start_review: "Start Review",
relevance_case: "Relevance Case",
last_page: "It's the end",
execute_result: "Result",
},
module: {

View File

@ -809,6 +809,7 @@ export default {
all_case: "全部用例",
start_review: "开始评审",
relevance_case: "关联用例",
last_page: "已经到底了!",
execute_result: "评审结果",
},
module: {

View File

@ -809,6 +809,7 @@ export default {
all_case: "全部用例",
start_review: "開始評審",
relevance_case: "關聯用例",
last_page: "已經到底了!",
execute_result: "評審結果",
},
module: {