refactor(测试跟踪): 测试计划,用例评审 两处关联测试用例一次加载全部优化

This commit is contained in:
fit2-zhao 2020-10-15 18:08:41 +08:00
parent 92122e0546
commit b4af198897
12 changed files with 253 additions and 104 deletions

View File

@ -20,8 +20,13 @@ public interface ExtTestCaseMapper {
TestCase getMaxNumByProjectId(@Param("projectId") String projectId); TestCase getMaxNumByProjectId(@Param("projectId") String projectId);
List<TestCase> getTestCaseByNotInPlan(@Param("request") QueryTestCaseRequest request);
List<TestCase> getTestCaseByNotInReview(@Param("request") QueryTestCaseRequest request);
/** /**
* 检查某工作空间下是否有某用例 * 检查某工作空间下是否有某用例
*
* @param caseId * @param caseId
* @param workspaceId * @param workspaceId
* @return TestCase ID * @return TestCase ID

View File

@ -97,6 +97,113 @@
</if> </if>
</sql> </sql>
<select id="getTestCaseByNotInReview" resultType="io.metersphere.base.domain.TestCase">
select test_case.id, test_case.name, test_case.priority, test_case.type, test_case.review_status
from test_case
<where>
<if test="request.combine != null">
<include refid="combine">
<property name="condition" value="request.combine"/>
<property name="name" value="request.name"/>
</include>
</if>
and test_case.id not in (select case_id from test_case_review_test_case where review_id =#{request.reviewId})
<if test="request.name != null">
and test_case.name like CONCAT('%', #{request.name},'%')
</if>
<if test="request.projectId != null">
AND test_case.project_id = #{request.projectId}
</if>
<if test="request.nodeIds != null and request.nodeIds.size() > 0">
AND test_case.node_id IN
<foreach collection="request.nodeIds" open="(" close=")" separator="," item="nodeId">
#{nodeId}
</foreach>
</if>
<if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
<choose>
<when test="key=='priority'">
and test_case.priority in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<when test="key=='status'">
and test_case.review_status in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<otherwise>
and test_case.type in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</otherwise>
</choose>
</if>
</foreach>
</if>
</where>
ORDER BY test_case.update_time DESC
</select>
<select id="getTestCaseByNotInPlan" resultType="io.metersphere.base.domain.TestCase">
select test_case.id, test_case.name, test_case.priority, test_case.type, test_case.review_status
from test_case
<where>
<if test="request.combine != null">
<include refid="combine">
<property name="condition" value="request.combine"/>
<property name="name" value="request.name"/>
</include>
</if>
and test_case.id not in (select case_id from test_plan_test_case where plan_id =#{request.planId})
<if test="request.name != null">
and test_case.name like CONCAT('%', #{request.name},'%')
</if>
<if test="request.projectId != null">
AND test_case.project_id = #{request.projectId}
</if>
<if test="request.nodeIds != null and request.nodeIds.size() > 0">
AND test_case.node_id IN
<foreach collection="request.nodeIds" open="(" close=")" separator="," item="nodeId">
#{nodeId}
</foreach>
</if>
<if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
<choose>
<when test="key=='priority'">
and test_case.priority in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<when test="key=='status'">
and test_case.review_status in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<otherwise>
and test_case.type in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</otherwise>
</choose>
</if>
</foreach>
</if>
</where>
ORDER BY test_case.update_time DESC
</select>
<select id="getTestCaseNames" resultType="io.metersphere.base.domain.TestCase"> <select id="getTestCaseNames" resultType="io.metersphere.base.domain.TestCase">
select test_case.id, test_case.name, test_case.priority, test_case.type, test_case.review_status select test_case.id, test_case.name, test_case.priority, test_case.type, test_case.review_status

View File

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

View File

@ -10,5 +10,6 @@ import java.util.List;
@Setter @Setter
public class PlanCaseRelevanceRequest { public class PlanCaseRelevanceRequest {
private String planId; private String planId;
private String projectId;
private List<String> testCaseIds = new ArrayList<>(); private List<String> testCaseIds = new ArrayList<>();
} }

View File

@ -10,5 +10,6 @@ import java.util.List;
@Setter @Setter
public class ReviewRelevanceRequest { public class ReviewRelevanceRequest {
private String reviewId; private String reviewId;
private String projectId;
private List<String> testCaseIds = new ArrayList<>(); private List<String> testCaseIds = new ArrayList<>();
} }

View File

@ -3,6 +3,7 @@ package io.metersphere.track.service;
import io.metersphere.base.domain.*; import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.*; import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ext.ExtProjectMapper; import io.metersphere.base.mapper.ext.ExtProjectMapper;
import io.metersphere.base.mapper.ext.ExtTestCaseMapper;
import io.metersphere.base.mapper.ext.ExtTestCaseReviewMapper; import io.metersphere.base.mapper.ext.ExtTestCaseReviewMapper;
import io.metersphere.base.mapper.ext.ExtTestReviewCaseMapper; import io.metersphere.base.mapper.ext.ExtTestReviewCaseMapper;
import io.metersphere.commons.constants.TestCaseReviewStatus; import io.metersphere.commons.constants.TestCaseReviewStatus;
@ -20,6 +21,7 @@ import io.metersphere.service.UserService;
import io.metersphere.track.dto.TestCaseReviewDTO; import io.metersphere.track.dto.TestCaseReviewDTO;
import io.metersphere.track.dto.TestReviewCaseDTO; import io.metersphere.track.dto.TestReviewCaseDTO;
import io.metersphere.track.dto.TestReviewDTOWithMetric; import io.metersphere.track.dto.TestReviewDTOWithMetric;
import io.metersphere.track.request.testcase.QueryTestCaseRequest;
import io.metersphere.track.request.testreview.QueryCaseReviewRequest; import io.metersphere.track.request.testreview.QueryCaseReviewRequest;
import io.metersphere.track.request.testreview.QueryTestReviewRequest; import io.metersphere.track.request.testreview.QueryTestReviewRequest;
import io.metersphere.track.request.testreview.ReviewRelevanceRequest; import io.metersphere.track.request.testreview.ReviewRelevanceRequest;
@ -32,6 +34,7 @@ import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -66,7 +69,8 @@ public class TestCaseReviewService {
TestCaseReviewTestCaseMapper testCaseReviewTestCaseMapper; TestCaseReviewTestCaseMapper testCaseReviewTestCaseMapper;
@Resource @Resource
MailService mailService; MailService mailService;
@Resource
ExtTestCaseMapper extTestCaseMapper;
public void saveTestCaseReview(SaveTestCaseReviewRequest reviewRequest) { public void saveTestCaseReview(SaveTestCaseReviewRequest reviewRequest) {
checkCaseReviewExist(reviewRequest); checkCaseReviewExist(reviewRequest);
@ -300,6 +304,16 @@ public class TestCaseReviewService {
if (testCaseIds.isEmpty()) { if (testCaseIds.isEmpty()) {
return; return;
} }
// 如果是关联全部指令则从新查询未关联的案例
if (testCaseIds.get(0).equals("all")) {
QueryTestCaseRequest req = new QueryTestCaseRequest();
req.setReviewId(request.getReviewId());
req.setProjectId(request.getProjectId());
List<TestCase> testCases = extTestCaseMapper.getTestCaseByNotInReview(req);
if (!testCases.isEmpty()) {
testCaseIds = testCases.stream().map(testCase -> testCase.getId()).collect(Collectors.toList());
}
}
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
TestCaseReviewTestCaseMapper batchMapper = sqlSession.getMapper(TestCaseReviewTestCaseMapper.class); TestCaseReviewTestCaseMapper batchMapper = sqlSession.getMapper(TestCaseReviewTestCaseMapper.class);

View File

@ -190,46 +190,24 @@ public class TestCaseService {
* @return * @return
*/ */
public List<TestCase> getTestCaseNames(QueryTestCaseRequest request) { public List<TestCase> getTestCaseNames(QueryTestCaseRequest request) {
if (StringUtils.isNotBlank(request.getPlanId())) { List<OrderRequest> orderList = ServiceUtils.getDefaultOrder(request.getOrders());
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getPlanId()); OrderRequest order = new OrderRequest();
// request 传入要查询的 projectId 切换的项目ID order.setName("sort");
} order.setType("desc");
orderList.add(order);
List<TestCase> testCaseNames = extTestCaseMapper.getTestCaseNames(request); request.setOrders(orderList);
return extTestCaseMapper.getTestCaseByNotInPlan(request);
if (StringUtils.isNotBlank(request.getPlanId())) {
TestPlanTestCaseExample testPlanTestCaseExample = new TestPlanTestCaseExample();
testPlanTestCaseExample.createCriteria().andPlanIdEqualTo(request.getPlanId());
List<String> relevanceIds = testPlanTestCaseMapper.selectByExample(testPlanTestCaseExample).stream()
.map(TestPlanTestCase::getCaseId)
.collect(Collectors.toList());
return testCaseNames.stream()
.filter(testcase -> !relevanceIds.contains(testcase.getId()))
.collect(Collectors.toList());
}
return testCaseNames;
} }
public List<TestCase> getReviewCase(QueryTestCaseRequest request) { public List<TestCase> getReviewCase(QueryTestCaseRequest request) {
List<OrderRequest> orderList = ServiceUtils.getDefaultOrder(request.getOrders());
List<TestCase> testCases = extTestCaseMapper.getTestCaseNames(request); OrderRequest order = new OrderRequest();
// 对模板导入的测试用例排序
if (StringUtils.isNotBlank(request.getReviewId())) { order.setName("sort");
TestCaseReviewTestCaseExample testCaseReviewTestCaseExample = new TestCaseReviewTestCaseExample(); order.setType("desc");
testCaseReviewTestCaseExample.createCriteria().andReviewIdEqualTo(request.getReviewId()); orderList.add(order);
List<String> relevanceIds = testCaseReviewTestCaseMapper.selectByExample(testCaseReviewTestCaseExample).stream() request.setOrders(orderList);
.map(TestCaseReviewTestCase::getCaseId) return extTestCaseMapper.getTestCaseByNotInReview(request);
.collect(Collectors.toList());
return testCases.stream()
.filter(testcase -> !relevanceIds.contains(testcase.getId()))
.collect(Collectors.toList());
}
return testCases;
} }

View File

@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import io.metersphere.base.domain.*; import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.*; import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ext.ExtProjectMapper; import io.metersphere.base.mapper.ext.ExtProjectMapper;
import io.metersphere.base.mapper.ext.ExtTestCaseMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanMapper; import io.metersphere.base.mapper.ext.ExtTestPlanMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper; import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper;
import io.metersphere.commons.constants.TestPlanStatus; import io.metersphere.commons.constants.TestPlanStatus;
@ -24,6 +25,7 @@ import io.metersphere.track.dto.TestPlanCaseDTO;
import io.metersphere.track.dto.TestPlanDTO; import io.metersphere.track.dto.TestPlanDTO;
import io.metersphere.track.dto.TestPlanDTOWithMetric; import io.metersphere.track.dto.TestPlanDTOWithMetric;
import io.metersphere.track.request.testcase.PlanCaseRelevanceRequest; import io.metersphere.track.request.testcase.PlanCaseRelevanceRequest;
import io.metersphere.track.request.testcase.QueryTestCaseRequest;
import io.metersphere.track.request.testcase.QueryTestPlanRequest; import io.metersphere.track.request.testcase.QueryTestPlanRequest;
import io.metersphere.track.request.testplan.AddTestPlanRequest; import io.metersphere.track.request.testplan.AddTestPlanRequest;
import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest; import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest;
@ -78,6 +80,8 @@ public class TestPlanService {
TestPlanProjectService testPlanProjectService; TestPlanProjectService testPlanProjectService;
@Resource @Resource
ProjectMapper projectMapper; ProjectMapper projectMapper;
@Resource
ExtTestCaseMapper extTestCaseMapper;
public void addTestPlan(AddTestPlanRequest testPlan) { public void addTestPlan(AddTestPlanRequest testPlan) {
if (getTestPlanByName(testPlan.getName()).size() > 0) { if (getTestPlanByName(testPlan.getName()).size() > 0) {
@ -207,6 +211,16 @@ public class TestPlanService {
return; return;
} }
// 如果是关联全部指令则从新查询未关联的案例
if (testCaseIds.get(0).equals("all")) {
QueryTestCaseRequest req = new QueryTestCaseRequest();
req.setPlanId(request.getPlanId());
req.setProjectId(request.getProjectId());
List<TestCase> testCases = extTestCaseMapper.getTestCaseByNotInPlan(req);
if (!testCases.isEmpty()) {
testCaseIds = testCases.stream().map(testCase -> testCase.getId()).collect(Collectors.toList());
}
}
TestCaseExample testCaseExample = new TestCaseExample(); TestCaseExample testCaseExample = new TestCaseExample();
testCaseExample.createCriteria().andIdIn(testCaseIds); testCaseExample.createCriteria().andIdIn(testCaseIds);

View File

@ -83,6 +83,7 @@
refresh() { refresh() {
this.selectNodeIds = []; this.selectNodeIds = [];
this.selectParentNodes = []; this.selectParentNodes = [];
this.$refs.testCaseRelevance.search();
this.getNodeTreeByPlanId(); this.getNodeTreeByPlanId();
}, },
initData() { initData() {

View File

@ -11,7 +11,9 @@
<el-container class="main-content"> <el-container class="main-content">
<el-aside class="tree-aside" width="250px"> <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" <node-tree class="node-tree"
@nodeSelectEvent="nodeChange" @nodeSelectEvent="nodeChange"
@refresh="refresh" @refresh="refresh"
@ -21,11 +23,13 @@
<el-container> <el-container>
<el-main class="case-content"> <el-main class="case-content">
<ms-table-header :condition.sync="condition" @search="getCaseNames" title="" :show-create="false"/> <ms-table-header :condition.sync="condition" @search="search" title="" :show-create="false"/>
<el-table <el-table
:data="testCases" :data="testCases"
@filter-change="filter" @filter-change="filter"
row-key="id" row-key="id"
@mouseleave.passive="leave"
v-el-table-infinite-scroll="loadData"
@select-all="handleSelectAll" @select-all="handleSelectAll"
@select="handleSelectionChange" @select="handleSelectionChange"
height="50vh" height="50vh"
@ -63,7 +67,9 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<div style="text-align: center"> {{testCases.length}} </div>
<div v-if="!endStatus" style="text-align: center">{{$t('test_track.review_view.last_page')}}</div>
<div style="text-align: center"> {{total}} </div>
</el-main> </el-main>
</el-container> </el-container>
</el-container> </el-container>
@ -91,6 +97,7 @@
import MsTableHeader from "../../../../common/components/MsTableHeader"; import MsTableHeader from "../../../../common/components/MsTableHeader";
import {TEST_CASE_CONFIGS} from "../../../../common/components/search/search-components"; import {TEST_CASE_CONFIGS} from "../../../../common/components/search/search-components";
import SwitchProject from "../../../case/components/SwitchProject"; import SwitchProject from "../../../case/components/SwitchProject";
import elTableInfiniteScroll from 'el-table-infinite-scroll';
export default { export default {
name: "TestCaseRelevance", name: "TestCaseRelevance",
@ -104,6 +111,9 @@
MsTableHeader, MsTableHeader,
SwitchProject SwitchProject
}, },
directives: {
'el-table-infinite-scroll': elTableInfiniteScroll
},
data() { data() {
return { return {
result: {}, result: {},
@ -117,6 +127,10 @@
projectId: '', projectId: '',
projectName: '', projectName: '',
projects: [], projects: [],
pageSize: 50,
currentPage: 1,
total: 0,
endStatus: true,
condition: { condition: {
components: TEST_CASE_CONFIGS components: TEST_CASE_CONFIGS
}, },
@ -140,12 +154,15 @@
}, },
watch: { watch: {
planId() { planId() {
this.initData(); this.condition.planId = this.planId;
}, },
selectNodeIds() { selectNodeIds() {
this.getCaseNames(); if (this.dialogFormVisible) {
this.search();
}
}, },
projectId() { projectId() {
this.condition.projectId = this.projectId;
this.getProjectNode(); this.getProjectNode();
} }
}, },
@ -155,13 +172,17 @@
methods: { methods: {
openTestCaseRelevanceDialog() { openTestCaseRelevanceDialog() {
this.getProject(); this.getProject();
this.initData();
this.dialogFormVisible = true; this.dialogFormVisible = true;
}, },
saveCaseRelevance() { saveCaseRelevance() {
let param = {}; let param = {};
param.planId = this.planId; param.planId = this.planId;
param.testCaseIds = [...this.selectIds]; param.testCaseIds = [...this.selectIds];
param.projectId = this.projectId;
//
if (this.testCases.length === param.testCaseIds.length) {
param.testCaseIds = ['all'];
}
this.result = this.$post('/test/plan/relevance', param, () => { this.result = this.$post('/test/plan/relevance', param, () => {
this.selectIds.clear(); this.selectIds.clear();
this.$success(this.$t('commons.save_success')); this.$success(this.$t('commons.save_success'));
@ -169,25 +190,34 @@
this.$emit('refresh'); this.$emit('refresh');
}); });
}, },
getCaseNames() { buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize;
},
search() {
this.currentPage = 1;
this.testCases = [];
this.getTestCases();
},
getTestCases() {
if (this.planId) { if (this.planId) {
// param.planId = this.planId;
this.condition.planId = this.planId; this.condition.planId = this.planId;
} }
if (this.selectNodeIds && this.selectNodeIds.length > 0) { if (this.selectNodeIds && this.selectNodeIds.length > 0) {
// param.nodeIds = this.selectNodeIds;
this.condition.nodeIds = this.selectNodeIds; this.condition.nodeIds = this.selectNodeIds;
} else { } else {
this.condition.nodeIds = []; this.condition.nodeIds = [];
} }
if (this.projectId) { if (this.projectId) {
this.condition.projectId = this.projectId; this.condition.projectId = this.projectId;
this.result = this.$post('/test/case/name', this.condition, response => { this.result = this.$post(this.buildPagePath('/test/case/name'), this.condition, response => {
this.testCases = response.data; let data = response.data;
this.testCases.forEach(item => { this.total = data.itemCount;
let tableData = data.listObject;
tableData.forEach(item => {
item.checked = false; item.checked = false;
}); });
this.testCases = this.testCases.concat(tableData);
this.endStatus = tableData.length === 50 && this.testCases.length < this.total;
}); });
} }
@ -198,7 +228,6 @@
this.selectIds.add(item.id); this.selectIds.add(item.id);
}); });
} else { } else {
// this.selectIds.clear();
this.testCases.forEach(item => { this.testCases.forEach(item => {
if (this.selectIds.has(item.id)) { if (this.selectIds.has(item.id)) {
this.selectIds.delete(item.id); this.selectIds.delete(item.id);
@ -217,32 +246,37 @@
this.selectNodeIds = nodeIds; this.selectNodeIds = nodeIds;
this.selectNodeNames = nodeNames; this.selectNodeNames = nodeNames;
}, },
initData() {
this.getCaseNames();
this.getAllNodeTreeByPlanId();
},
refresh() { refresh() {
this.close(); this.close();
}, },
loadData() {
if (this.dialogFormVisible) {
if (this.endStatus) {
this.currentPage += 1;
this.getTestCases();
}
}
},
getAllNodeTreeByPlanId() { getAllNodeTreeByPlanId() {
if (this.planId) { if (this.planId) {
let param = { let param = {
testPlanId: this.planId, testPlanId: this.planId,
projectId: this.projectId projectId: this.projectId
}; };
this.result = this.$post("/case/node/list/all/plan", param , response => { this.result = this.$post("/case/node/list/all/plan", param, response => {
this.treeNodes = response.data; this.treeNodes = response.data;
}); });
} }
}, },
close() { close() {
this.endStatus = false;
this.selectIds.clear(); this.selectIds.clear();
this.selectNodeIds = []; this.selectNodeIds = [];
this.selectNodeNames = []; this.selectNodeNames = [];
}, },
filter(filters) { filter(filters) {
_filter(filters, this.condition); _filter(filters, this.condition);
this.initData(); this.search();
}, },
toggleSelection(rows) { toggleSelection(rows) {
rows.forEach(row => { rows.forEach(row => {
@ -256,7 +290,7 @@
}, },
getProject() { getProject() {
if (this.planId) { if (this.planId) {
this.$post("/test/plan/project/", {planId: this.planId},res => { this.$post("/test/plan/project/", {planId: this.planId}, res => {
let data = res.data; let data = res.data;
if (data) { if (data) {
this.projects = data; this.projects = data;
@ -267,7 +301,7 @@
} }
}, },
switchProject() { switchProject() {
this.$refs.switchProject.open({id: this.planId, url: '/test/plan/project/',type: 'plan'}); this.$refs.switchProject.open({id: this.planId, url: '/test/plan/project/', type: 'plan'});
}, },
getProjectNode(projectId) { getProjectNode(projectId) {
const index = this.projects.findIndex(project => project.id === projectId); const index = this.projects.findIndex(project => project.id === projectId);
@ -278,9 +312,9 @@
this.projectId = projectId; this.projectId = projectId;
} }
this.result = this.$post("/case/node/list/all/plan", this.result = this.$post("/case/node/list/all/plan",
{testPlanId: this.planId, projectId: this.projectId} , response => { {testPlanId: this.planId, projectId: this.projectId}, response => {
this.treeNodes = response.data; this.treeNodes = response.data;
}); });
this.selectNodeIds = []; this.selectNodeIds = [];
} }

View File

@ -88,6 +88,7 @@ export default {
refresh() { refresh() {
this.selectNodeIds = []; this.selectNodeIds = [];
this.selectParentNodes = []; this.selectParentNodes = [];
this.$refs.testReviewRelevance.search();
this.getNodeTreeByReviewId(); this.getNodeTreeByReviewId();
}, },
initData() { initData() {

View File

@ -2,9 +2,7 @@
<div> <div>
<el-dialog :title="$t('test_track.review_view.relevance_case')" <el-dialog :title="$t('test_track.review_view.relevance_case')" :visible.sync="dialogFormVisible" @close="close"
:visible.sync="dialogFormVisible"
@close="close"
width="60%" v-loading="result.loading" width="60%" v-loading="result.loading"
:close-on-click-modal="false" :close-on-click-modal="false"
top="50px"> top="50px">
@ -14,30 +12,21 @@
<el-link type="primary" class="project-link" @click="switchProject">{{projectName ? projectName : <el-link type="primary" class="project-link" @click="switchProject">{{projectName ? projectName :
$t('test_track.switch_project') }} $t('test_track.switch_project') }}
</el-link> </el-link>
<node-tree class="node-tree" <node-tree class="node-tree" @nodeSelectEvent="nodeChange" @refresh="refresh" :tree-nodes="treeNodes"
@nodeSelectEvent="nodeChange"
@refresh="refresh"
:tree-nodes="treeNodes"
ref="nodeTree"/> ref="nodeTree"/>
</el-aside> </el-aside>
<el-container> <el-container>
<el-main class="case-content"> <el-main class="case-content">
<ms-table-header :condition.sync="condition" @search="search" title="" :show-create="false"/> <ms-table-header :condition.sync="condition" @search="search" title="" :show-create="false"/>
<el-table <el-table :data="testReviews" @mouseleave.passive="leave" v-el-table-infinite-scroll="loadData"
:data="testReviews" @filter-change="filter" row-key="id"
v-el-table-infinite-scroll="loadData" @select-all="handleSelectAll"
class="infinite-list" @select="handleSelectionChange"
@filter-change="filter" height="50vh"
row-key="id" ref="table">
@select-all="handleSelectAll"
@select="handleSelectionChange"
height="50vh"
ref="table">
<el-table-column
type="selection"/>
<el-table-column type="selection"/>
<el-table-column <el-table-column
prop="name" prop="name"
:label="$t('test_track.case.name')" :label="$t('test_track.case.name')"
@ -46,6 +35,7 @@
{{scope.row.name}} {{scope.row.name}}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="priority" prop="priority"
:filters="priorityFilters" :filters="priorityFilters"
@ -56,6 +46,7 @@
<priority-table-item :value="scope.row.priority"/> <priority-table-item :value="scope.row.priority"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="type" prop="type"
:filters="typeFilters" :filters="typeFilters"
@ -66,6 +57,7 @@
<type-table-item :value="scope.row.type"/> <type-table-item :value="scope.row.type"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
:filters="statusFilters" :filters="statusFilters"
column-key="status" column-key="status"
@ -75,7 +67,9 @@
<status-table-item :value="scope.row.reviewStatus"/> <status-table-item :value="scope.row.reviewStatus"/>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<div v-if="!endStatus" style="text-align: center">{{$t('test_track.review_view.last_page')}}</div>
<div style="text-align: center"> {{total}} </div> <div style="text-align: center"> {{total}} </div>
</el-main> </el-main>
</el-container> </el-container>
@ -129,7 +123,6 @@
dialogFormVisible: false, dialogFormVisible: false,
isCheckAll: false, isCheckAll: false,
testReviews: [], testReviews: [],
tableData: [],
selectIds: new Set(), selectIds: new Set(),
treeNodes: [], treeNodes: [],
selectNodeIds: [], selectNodeIds: [],
@ -169,12 +162,15 @@
}, },
watch: { watch: {
reviewId() { reviewId() {
this.initData(); this.condition.reviewId = this.reviewId;
}, },
selectNodeIds() { selectNodeIds() {
this.search(); if (this.dialogFormVisible) {
this.search();
}
}, },
projectId() { projectId() {
this.condition.projectId = this.projectId;
this.getProjectNode(); this.getProjectNode();
} }
}, },
@ -184,13 +180,17 @@
methods: { methods: {
openTestReviewRelevanceDialog() { openTestReviewRelevanceDialog() {
this.getProject(); this.getProject();
this.initData();
this.dialogFormVisible = true; this.dialogFormVisible = true;
}, },
saveReviewRelevance() { saveReviewRelevance() {
let param = {}; let param = {};
param.reviewId = this.reviewId; param.reviewId = this.reviewId;
param.testCaseIds = [...this.selectIds]; param.testCaseIds = [...this.selectIds];
param.projectId = this.projectId;
//
if (this.testReviews.length === param.testCaseIds.length) {
param.testCaseIds = ['all'];
}
this.result = this.$post('/test/case/review/relevance', param, () => { this.result = this.$post('/test/case/review/relevance', param, () => {
this.selectIds.clear(); this.selectIds.clear();
this.$success(this.$t('commons.save_success')); this.$success(this.$t('commons.save_success'));
@ -210,18 +210,18 @@
} else { } else {
this.condition.nodeIds = []; this.condition.nodeIds = [];
} }
if (this.projectId) { if (this.projectId) {
this.condition.projectId = this.projectId; this.condition.projectId = this.projectId;
this.result = this.$post(this.buildPagePath('/test/case/reviews/case'), this.condition, response => { this.result = this.$post(this.buildPagePath('/test/case/reviews/case'), this.condition, response => {
let data = response.data; let data = response.data;
this.total = data.itemCount; this.total = data.itemCount;
this.tableData = data.listObject; let tableData = data.listObject;
this.endStatus = this.tableData.length === 50; tableData.forEach(item => {
this.tableData.forEach(item => {
item.checked = false; item.checked = false;
}); });
this.testReviews = this.testReviews.concat(this.tableData); this.testReviews = this.testReviews.concat(tableData);
this.endStatus = tableData.length === 50 && this.testReviews.length < this.total;
}); });
} }
@ -251,11 +251,6 @@
this.selectNodeIds = nodeIds; this.selectNodeIds = nodeIds;
this.selectNodeNames = nodeNames; this.selectNodeNames = nodeNames;
}, },
initData() {
// this.testReviews=[];
// this.getReviews();
// this.getAllNodeTreeByPlanId();
},
refresh() { refresh() {
this.close(); this.close();
}, },
@ -275,7 +270,6 @@
this.selectIds.clear(); this.selectIds.clear();
this.selectNodeIds = []; this.selectNodeIds = [];
this.selectNodeNames = []; this.selectNodeNames = [];
this.tableData = [];
}, },
filter(filters) { filter(filters) {
_filter(filters, this.condition); _filter(filters, this.condition);
@ -308,11 +302,9 @@
}, },
loadData() { loadData() {
if (this.dialogFormVisible) { if (this.dialogFormVisible) {
if (this.endStatus === true) { if (this.endStatus) {
this.currentPage += 1; this.currentPage += 1;
this.getReviews(); this.getReviews();
} else {
this.$message.warning(this.$t('test_track.review_view.last_page'));
} }
} }
}, },