feat(测试计划): 关联测试用例切换项目页列表分页

This commit is contained in:
shiziyuan9527 2020-09-14 15:14:19 +08:00
parent ed86abfb9e
commit 3b439edaeb
6 changed files with 130 additions and 89 deletions

View File

@ -14,6 +14,7 @@ import io.metersphere.track.dto.TestPlanDTOWithMetric;
import io.metersphere.track.request.testcase.PlanCaseRelevanceRequest;
import io.metersphere.track.request.testcase.QueryTestPlanRequest;
import io.metersphere.track.request.testplan.AddTestPlanRequest;
import io.metersphere.track.request.testplancase.TestCaseRelevanceRequest;
import io.metersphere.track.service.TestPlanProjectService;
import io.metersphere.track.service.TestPlanService;
import org.apache.shiro.authz.annotation.Logical;
@ -111,8 +112,18 @@ public class TestPlanController {
return testPlanService.getProjectNameByPlanId(planId);
}
@GetMapping("/project/{planId}")
public List<Project> getProjectByPlanId(@PathVariable String planId) {
return testPlanProjectService.getProjectByPlanId(planId);
@PostMapping("/project")
public List<Project> getProjectByPlanId(@RequestBody TestCaseRelevanceRequest request) {
List<String> projectIds = testPlanProjectService.getProjectIdsByPlanId(request.getPlanId());
request.setProjectIds(projectIds);
return testPlanProjectService.getProjectByPlanId(request);
}
@PostMapping("/project/{goPage}/{pageSize}")
public Pager<List<Project>> getProjectByPlanId(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody TestCaseRelevanceRequest request) {
List<String> projectIds = testPlanProjectService.getProjectIdsByPlanId(request.getPlanId());
request.setProjectIds(projectIds);
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testPlanProjectService.getProjectByPlanId(request));
}
}

View File

@ -0,0 +1,14 @@
package io.metersphere.track.request.testplancase;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class TestCaseRelevanceRequest {
private String planId;
private String name;
private List<String> projectIds;
}

View File

@ -6,15 +6,14 @@ import io.metersphere.base.domain.TestPlanProject;
import io.metersphere.base.domain.TestPlanProjectExample;
import io.metersphere.base.mapper.ProjectMapper;
import io.metersphere.base.mapper.TestPlanProjectMapper;
import org.python.antlr.ast.Str;
import io.metersphere.track.request.testplancase.TestCaseRelevanceRequest;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@Service
@ -41,12 +40,14 @@ public class TestPlanProjectService {
return projectIds;
}
public List<Project> getProjectByPlanId(String planId) {
List<String> projectIds = getProjectIdsByPlanId(planId);
public List<Project> getProjectByPlanId(TestCaseRelevanceRequest request) {
ProjectExample projectExample = new ProjectExample();
projectExample.createCriteria().andIdIn(projectIds);
List<Project> projects = projectMapper.selectByExample(projectExample);
return Optional.ofNullable(projects).orElse(new ArrayList<>());
ProjectExample.Criteria criteria = projectExample.createCriteria();
criteria.andIdIn(request.getProjectIds());
if (StringUtils.isNotBlank(request.getName())) {
criteria.andNameLike(StringUtils.wrapIfMissing(request.getName(), "%"));
}
return projectMapper.selectByExample(projectExample);
}
public void deleteTestPlanProjectByPlanId(String planId) {

View File

@ -2,7 +2,9 @@
<el-dialog v-loading="result.loading"
:visible.sync="dialogVisible"
:close-on-click-modal="false"
class="ms-switch-project"
>
<ms-table-header :condition.sync="condition" @search="initData" title="" :show-create="false"/>
<el-table
:data="tableData"
highlight-current-row
@ -15,7 +17,6 @@
</template>
</el-table-column>
<el-table-column
sortable
prop="createTime"
:label="$t('commons.create_time')"
show-overflow-tooltip>
@ -24,7 +25,6 @@
</template>
</el-table-column>
<el-table-column
sortable
prop="updateTime"
:label="$t('commons.update_time')"
show-overflow-tooltip>
@ -33,6 +33,8 @@
</template>
</el-table-column>
</el-table>
<ms-table-pagination :change="initData" :current-page.sync="currentPage" :page-size.sync="pageSize"
:total="total"/>
<template v-slot:footer>
<div class="dialog-footer">
<ms-dialog-footer
@ -45,26 +47,37 @@
<script>
import MsDialogFooter from "../../../common/components/MsDialogFooter";
import MsTableHeader from "../../../common/components/MsTableHeader";
import MsTablePagination from "../../../common/pagination/TablePagination";
export default {
name: "SwitchProject",
components: {MsDialogFooter},
components: {MsDialogFooter, MsTableHeader, MsTablePagination},
data() {
return {
tableData: [],
result: {},
dialogVisible: false,
projectId: ''
projectId: '',
planId: '',
condition: {},
currentPage: 1,
pageSize: 5,
total: 0,
}
},
methods: {
open(planId) {
this.dialogVisible = true;
this.initData(planId);
this.planId = planId;
this.initData();
},
initData(planId) {
this.result = this.$get("/test/plan/project/" + planId,res => {
this.tableData = res.data;
initData() {
this.condition.planId = this.planId;
this.result = this.$post("/test/plan/project/" + this.currentPage + "/" + this.pageSize, this.condition, res => {
const data = res.data;
this.total = data.itemCount;
this.tableData = data.listObject;
})
},
handleCurrentChange(currentRow) {
@ -82,5 +95,7 @@
</script>
<style scoped>
.ms-switch-project >>> .el-dialog__body {
padding: 0 15px !important;
}
</style>

View File

@ -192,8 +192,8 @@ export default {
this.total = data.itemCount;
this.tableData = data.listObject;
for (let i = 0; i < this.tableData.length; i++) {
let path = "/test/plan/project/" + this.tableData[i].id;
this.$get(path, res => {
let path = "/test/plan/project";
this.$post(path,{planId: this.tableData[i].id}, res => {
let arr = res.data;
let projectName = arr.map(data => data.name).join("、");
let projectIds = arr.map(data => data.id);

View File

@ -256,7 +256,7 @@
},
getProject() {
if (this.planId) {
this.$get("/test/plan/project/" + this.planId,res => {
this.$post("/test/plan/project/", {planId: this.planId},res => {
let data = res.data;
if (data) {
this.projects = data;