feat(测试跟踪): 用例搜索刷新模块树用例数量

--story=1008229 --user=陈建星 功能用例优化 https://www.tapd.cn/55049933/s/1191465
This commit is contained in:
chenjianxing 2022-06-30 11:10:39 +08:00 committed by f2c-ci-robot[bot]
parent f95d2337ed
commit 384f085872
21 changed files with 413 additions and 250 deletions

View File

@ -6,6 +6,7 @@ import io.metersphere.controller.request.BaseQueryRequest;
import io.metersphere.dto.RelationshipGraphData; import io.metersphere.dto.RelationshipGraphData;
import io.metersphere.track.dto.CustomFieldResourceCompatibleDTO; import io.metersphere.track.dto.CustomFieldResourceCompatibleDTO;
import io.metersphere.track.dto.TestCaseDTO; import io.metersphere.track.dto.TestCaseDTO;
import io.metersphere.track.dto.TestCaseNodeDTO;
import io.metersphere.track.request.testcase.DeleteTestCaseRequest; import io.metersphere.track.request.testcase.DeleteTestCaseRequest;
import io.metersphere.track.request.testcase.QueryTestCaseRequest; import io.metersphere.track.request.testcase.QueryTestCaseRequest;
import io.metersphere.track.request.testcase.TestCaseBatchRequest; import io.metersphere.track.request.testcase.TestCaseBatchRequest;
@ -108,7 +109,7 @@ public interface ExtTestCaseMapper {
List<String> selectRelateIdsByQuery(@Param("request") BaseQueryRequest query); List<String> selectRelateIdsByQuery(@Param("request") BaseQueryRequest query);
List<Map<String, Object>> moduleCountByCollection(@Param("request") QueryTestCaseRequest request); List<TestCaseNodeDTO> getCountNodes(@Param("request") QueryTestCaseRequest request);
List<TestCaseWithBLOBs> getCustomFieldsByIds(@Param("ids") List<String> ids); List<TestCaseWithBLOBs> getCustomFieldsByIds(@Param("ids") List<String> ids);

View File

@ -298,11 +298,12 @@
left join project on test_case.project_id = project.id left join project on test_case.project_id = project.id
<include refid="queryWhereConditionWidthProject"/> <include refid="queryWhereConditionWidthProject"/>
</select> </select>
<select id="getCountNodes" resultType="io.metersphere.track.dto.TestCaseNodeDTO">
<select id="moduleCountByCollection" resultType="java.util.Map"> select tcn.id, count(*) as caseNum
select node_id AS moduleId,count(id) AS countNum from test_case from test_case
inner join test_case_node tcn on test_case.node_id = tcn.id
<include refid="queryWhereCondition"/> <include refid="queryWhereCondition"/>
GROUP BY node_id group by test_case.node_id;
</select> </select>
<select id="listByMethod" resultType="io.metersphere.track.dto.TestCaseDTO"> <select id="listByMethod" resultType="io.metersphere.track.dto.TestCaseDTO">
select load_test.id, load_test.name, load_test.project_id,'性能测试' as type, project_version.name as version_name select load_test.id, load_test.name, load_test.project_id,'性能测试' as type, project_version.name as version_name
@ -398,7 +399,7 @@
from test_case from test_case
left join (select id,workspace_id,NAME from project where workspace_id =#{request.workspaceId}) left join (select id,workspace_id,NAME from project where workspace_id =#{request.workspaceId})
project on test_case.project_id = project.id project on test_case.project_id = project.id
where (test_case.STATUS IS NULL OR test_case.STATUS != 'Trash') and test_case.case_public=true GROUP BY ref_id) where test_case.STATUS != 'Trash' and test_case.case_public = true GROUP BY ref_id)
tmp on test_case.update_time = tmp.update_time and test_case.ref_id = tmp.ref_id tmp on test_case.update_time = tmp.update_time and test_case.ref_id = tmp.ref_id
<where> <where>
<if test="request.combine != null"> <if test="request.combine != null">
@ -409,11 +410,11 @@
</include> </include>
</if> </if>
<if test="request.statusIsNot != null"> <if test="request.statusIsNot != null">
and (test_case.status is null or test_case.status != #{request.statusIsNot}) and test_case.status != #{request.statusIsNot}
</if> </if>
<if test="request.notEqStatus != null"> <if test="request.notEqStatus != null">
and (test_case.status is null or test_case.status != #{request.notEqStatus}) and test_case.status != #{request.notEqStatus}
</if> </if>
<if test="request.name != null"> <if test="request.name != null">
and (test_case.name like CONCAT('%', #{request.name},'%') and (test_case.name like CONCAT('%', #{request.name},'%')
@ -469,11 +470,11 @@
</if> </if>
<if test="request.statusIsNot != null"> <if test="request.statusIsNot != null">
and (test_case.status is null or test_case.status != #{request.statusIsNot}) and test_case.status != #{request.statusIsNot}
</if> </if>
<if test="request.notEqStatus != null"> <if test="request.notEqStatus != null">
and (test_case.status is null or test_case.status != #{request.notEqStatus}) and test_case.status != #{request.notEqStatus}
</if> </if>
<if test="request.name != null"> <if test="request.name != null">
and (test_case.name like CONCAT('%', #{request.name},'%') and (test_case.name like CONCAT('%', #{request.name},'%')
@ -570,12 +571,12 @@
</choose> </choose>
</if> </if>
<if test="key=='status' and (values == null || values.size() == 0)"> <if test="key=='status' and (values == null || values.size() == 0)">
and (test_case.status is null or test_case.status != 'Trash') and test_case.status != 'Trash'
</if> </if>
</foreach> </foreach>
</if> </if>
<if test="request.filters == null || request.filters.size() == 0 || !request.filters.containsKey('status')"> <if test="request.filters == null || request.filters.size() == 0 || !request.filters.containsKey('status')">
and (test_case.status is null or test_case.status != 'Trash') and test_case.status != 'Trash'
</if> </if>
</sql> </sql>

View File

@ -1,6 +1,5 @@
package io.metersphere.base.mapper.ext; package io.metersphere.base.mapper.ext;
import io.metersphere.base.domain.TestCase;
import io.metersphere.controller.request.BaseQueryRequest; import io.metersphere.controller.request.BaseQueryRequest;
import io.metersphere.track.dto.*; import io.metersphere.track.dto.*;
import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest; import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest;
@ -68,7 +67,9 @@ public interface ExtTestPlanTestCaseMapper {
Long getLastOrder(@Param("planId") String planId, @Param("baseOrder") Long baseOrder); Long getLastOrder(@Param("planId") String planId, @Param("baseOrder") Long baseOrder);
List<TestCase> getTestCaseWithNodeInfo(@Param("planId") String planId); List<TestCaseNodeDTO> getTestPlanCountNodes(@Param("request") QueryTestPlanCaseRequest request);
List<String> projectIdsByPlanId(@Param("planId") String planId);
List<CountMapDTO> getExecResultMapByPlanId(@Param("planId") String planId); List<CountMapDTO> getExecResultMapByPlanId(@Param("planId") String planId);

View File

@ -180,7 +180,7 @@
<include refid="queryVersionCondition"> <include refid="queryVersionCondition">
<property name="versionTable" value="test_case"/> <property name="versionTable" value="test_case"/>
</include> </include>
and (test_case.status != 'Trash' or test_case.status is null) and test_case.status != 'Trash'
<include refid="filter"/> <include refid="filter"/>
</where> </where>
</sql> </sql>
@ -523,7 +523,6 @@
<if test="id != null and id != ''"> <if test="id != null and id != ''">
and plan_id=#{id,jdbcType=VARCHAR} and plan_id=#{id,jdbcType=VARCHAR}
</if> </if>
</update> </update>
<delete id="deleteByTestCaseID" parameterType="java.lang.String"> <delete id="deleteByTestCaseID" parameterType="java.lang.String">
delete delete
@ -557,12 +556,13 @@
</if> </if>
order by `order` desc limit 1; order by `order` desc limit 1;
</select> </select>
<select id="getTestPlanCountNodes" resultType="io.metersphere.track.dto.TestCaseNodeDTO">
<select id="getTestCaseWithNodeInfo" resultType="io.metersphere.base.domain.TestCase"> select tcn.id, count(*) as caseNum, test_case.project_id
select tc.project_id, tc.node_id from test_plan_test_case
from test_plan_test_case tptc inner join test_case on test_plan_test_case.case_id = test_case.id
join test_case tc on tptc.case_id = tc.id inner join test_case_node tcn on test_case.node_id = tcn.id
where tptc.plan_id = #{planId} <include refid="queryWhereCondition"/>
group by test_case.node_id;
</select> </select>
<select id="getExecResultMapByPlanId" resultType="io.metersphere.track.dto.CountMapDTO"> <select id="getExecResultMapByPlanId" resultType="io.metersphere.track.dto.CountMapDTO">
select status as `key`, count(*) as `value` select status as `key`, count(*) as `value`
@ -577,6 +577,13 @@
where id = #{0} where id = #{0}
</select> </select>
<select id="projectIdsByPlanId" resultType="java.lang.String">
select distinct tc.project_id
from test_plan_test_case tptc
join test_case tc on tptc.case_id = tc.id
where tptc.plan_id = #{planId}
</select>
<sql id="queryVersionCondition"> <sql id="queryVersionCondition">
<if test="request.versionId != null"> <if test="request.versionId != null">
and ${versionTable}.version_id = #{request.versionId} and ${versionTable}.version_id = #{request.versionId}

View File

@ -1,6 +1,7 @@
package io.metersphere.base.mapper.ext; package io.metersphere.base.mapper.ext;
import io.metersphere.track.dto.CountMapDTO; import io.metersphere.track.dto.CountMapDTO;
import io.metersphere.track.dto.TestCaseNodeDTO;
import io.metersphere.track.dto.TestReviewCaseDTO; import io.metersphere.track.dto.TestReviewCaseDTO;
import io.metersphere.track.request.testreview.QueryCaseReviewRequest; import io.metersphere.track.request.testreview.QueryCaseReviewRequest;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -30,14 +31,17 @@ public interface ExtTestReviewCaseMapper {
List<TestReviewCaseDTO> listForMinder(@Param("request") QueryCaseReviewRequest request); List<TestReviewCaseDTO> listForMinder(@Param("request") QueryCaseReviewRequest request);
List<String> selectReviewIds(); List<String> selectReviewIds();
List<String> getIdsOrderByUpdateTime(@Param("reviewId") String reviewId); List<String> getIdsOrderByUpdateTime(@Param("reviewId") String reviewId);
Long getPreOrder(@Param("reviewId")String reviewId, @Param("baseOrder") Long baseOrder); Long getPreOrder(@Param("reviewId") String reviewId, @Param("baseOrder") Long baseOrder);
Long getLastOrder(@Param("reviewId")String reviewId, @Param("baseOrder") Long baseOrder); Long getLastOrder(@Param("reviewId") String reviewId, @Param("baseOrder") Long baseOrder);
List<CountMapDTO> getStatusMapByReviewId(@Param("reviewId") String reviewId); List<CountMapDTO> getStatusMapByReviewId(@Param("reviewId") String reviewId);
List<String> projectIdsByPlanId(@Param("reviewId") String reviewId);
List<TestCaseNodeDTO> getTestReviewCountNodes(@Param("request") QueryCaseReviewRequest request);
} }

View File

@ -464,7 +464,19 @@
where review_id = #{reviewId} and is_del = 0 where review_id = #{reviewId} and is_del = 0
group by status group by status
</select> </select>
<select id="projectIdsByPlanId" resultType="java.lang.String">
select distinct project_id
from test_case_review_test_case
inner join test_case on test_case_review_test_case.case_id = test_case.id
</select>
<select id="getTestReviewCountNodes" resultType="io.metersphere.track.dto.TestCaseNodeDTO">
select tcn.id, count(*) as caseNum, test_case.project_id
from test_case_review_test_case
inner join test_case on test_case_review_test_case.case_id = test_case.id
inner join test_case_node tcn on test_case.node_id = tcn.id
<include refid="queryWhereCondition"/>
group by test_case.node_id;
</select>
<sql id="queryVersionCondition"> <sql id="queryVersionCondition">
<if test="request.versionId != null"> <if test="request.versionId != null">
and ${versionTable}.version_id = #{request.versionId} and ${versionTable}.version_id = #{request.versionId}

View File

@ -198,7 +198,7 @@ public class BaseModuleService extends NodeTreeService<ModuleNodeDTO> {
if (moduleIdObj != null && countNumObj != null) { if (moduleIdObj != null && countNumObj != null) {
String moduleId = String.valueOf(moduleIdObj); String moduleId = String.valueOf(moduleIdObj);
try { try {
Integer countNumInteger = new Integer(String.valueOf(countNumObj)); Integer countNumInteger = Integer.valueOf(String.valueOf(countNumObj));
returnMap.put(moduleId, countNumInteger); returnMap.put(moduleId, countNumInteger);
} catch (Exception e) { } catch (Exception e) {
} }

View File

@ -1,12 +1,16 @@
package io.metersphere.service; package io.metersphere.service;
import io.metersphere.base.domain.Project;
import io.metersphere.commons.utils.BeanUtils; import io.metersphere.commons.utils.BeanUtils;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.LogUtil;
import io.metersphere.track.dto.TreeNodeDTO; import io.metersphere.track.dto.TreeNodeDTO;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
public class NodeTreeService<T extends TreeNodeDTO> { public class NodeTreeService<T extends TreeNodeDTO> {
@ -32,6 +36,16 @@ public class NodeTreeService<T extends TreeNodeDTO> {
public List<T> getNodeTrees(List<T> nodes) { public List<T> getNodeTrees(List<T> nodes) {
return getNodeTrees(nodes, null);
}
public Map<String, Integer> getCountMap(List<T> nodes) {
Map<String, Integer> countMap = nodes.stream()
.collect(Collectors.toMap(TreeNodeDTO::getId, TreeNodeDTO::getCaseNum));
return countMap;
}
public List<T> getNodeTrees(List<T> nodes, Map<String, Integer> countMap) {
List<T> nodeTreeList = new ArrayList<>(); List<T> nodeTreeList = new ArrayList<>();
Map<Integer, List<T>> nodeLevelMap = new HashMap<>(); Map<Integer, List<T>> nodeLevelMap = new HashMap<>();
nodes.forEach(node -> { nodes.forEach(node -> {
@ -45,25 +59,24 @@ public class NodeTreeService<T extends TreeNodeDTO> {
} }
}); });
List<T> rootNodes = Optional.ofNullable(nodeLevelMap.get(1)).orElse(new ArrayList<>()); List<T> rootNodes = Optional.ofNullable(nodeLevelMap.get(1)).orElse(new ArrayList<>());
rootNodes.forEach(rootNode -> { rootNodes.forEach(rootNode -> nodeTreeList.add(buildNodeTree(nodeLevelMap, rootNode, countMap)));
nodeTreeList.add(buildNodeTree(nodeLevelMap, rootNode));
});
return nodeTreeList; return nodeTreeList;
} }
/** /**
* 递归构建节点树 * 递归构建节点树
* 并统计设置 CaseNum
* *
* @param nodeLevelMap * @param nodeLevelMap
* @param rootNode * @param rootNode
* @return * @return
*/ */
public T buildNodeTree(Map<Integer, List<T>> nodeLevelMap, T rootNode) { public T buildNodeTree(Map<Integer, List<T>> nodeLevelMap, T rootNode, Map<String, Integer> countMap) {
T nodeTree = getClassInstance(); T nodeTree = getClassInstance();
// T nodeTree = (T) new TreeNodeDTO();
BeanUtils.copyBean(nodeTree, rootNode); BeanUtils.copyBean(nodeTree, rootNode);
nodeTree.setLabel(rootNode.getName()); nodeTree.setLabel(rootNode.getName());
setCaseNum(countMap, nodeTree);
List<T> lowerNodes = nodeLevelMap.get(rootNode.getLevel() + 1); List<T> lowerNodes = nodeLevelMap.get(rootNode.getLevel() + 1);
if (lowerNodes == null) { if (lowerNodes == null) {
@ -74,13 +87,95 @@ public class NodeTreeService<T extends TreeNodeDTO> {
lowerNodes.forEach(node -> { lowerNodes.forEach(node -> {
if (node.getParentId() != null && node.getParentId().equals(rootNode.getId())) { if (node.getParentId() != null && node.getParentId().equals(rootNode.getId())) {
children.add(buildNodeTree(nodeLevelMap, node)); children.add(buildNodeTree(nodeLevelMap, node, countMap));
if (countMap != null) {
Integer childrenCount = children.stream().map(TreeNodeDTO::getCaseNum).reduce(Integer::sum).get();
nodeTree.setCaseNum(nodeTree.getCaseNum() + childrenCount);
}
nodeTree.setChildren(children); nodeTree.setChildren(children);
} }
}); });
return nodeTree; return nodeTree;
} }
public T buildNodeTree(Map<Integer, List<T>> nodeLevelMap, T rootNode) {
return buildNodeTree(nodeLevelMap, rootNode, null);
}
private void setCaseNum(Map<String, Integer> countMap, T nodeTree) {
if (countMap != null) {
if (countMap.get(nodeTree.getId()) != null) {
nodeTree.setCaseNum(countMap.get(nodeTree.getId()));
} else {
nodeTree.setCaseNum(0);
}
}
}
public List<T> getNodeTreeWithPruningTree(List<T> countModules,
Function<List<String>, List<T>> getProjectModulesFunc) {
if (org.springframework.util.CollectionUtils.isEmpty(countModules)) {
return new ArrayList<>();
}
List<T> list = new ArrayList<>();
Set<String> projectIdSet = new HashSet<>();
countModules.forEach(x -> projectIdSet.add(x.getProjectId()));
List<String> projectIds = new ArrayList<>(projectIdSet);
ProjectService projectService = CommonBeanFactory.getBean(ProjectService.class);
List<Project> projects = projectService.getProjectByIds(new ArrayList<>(projectIds));
Map<String, List<T>> projectModuleMap = getProjectModulesFunc.apply(projectIds)
.stream()
.collect(Collectors.groupingBy(TreeNodeDTO::getProjectId));
// 模块与用例数的映射
Map<String, Integer> countMap = countModules.stream()
.collect(Collectors.toMap(TreeNodeDTO::getId, TreeNodeDTO::getCaseNum));
projects.forEach((project) -> {
if (project != null) {
List<T> testCaseNodes = projectModuleMap.get(project.getId());
testCaseNodes = testCaseNodes.stream().sorted(Comparator.comparingDouble(TreeNodeDTO::getPos))
.collect(Collectors.toList());
testCaseNodes = getNodeTreeWithPruningTreeByCaseCount(testCaseNodes, countMap);
// 项目设置成根节点
T projectNode = getClassInstance();
projectNode.setId(project.getId());
projectNode.setName(project.getName());
projectNode.setLabel(project.getName());
projectNode.setChildren(testCaseNodes);
projectNode.setCaseNum(testCaseNodes.stream().mapToInt(TreeNodeDTO::getCaseNum).sum());
if (!org.springframework.util.CollectionUtils.isEmpty(testCaseNodes)) {
list.add(projectNode);
}
}
});
return list;
}
/**
* 生成模块树并剪枝
*
* @return
*/
public List<T> getNodeTreeWithPruningTreeByCaseCount(List<T> testCaseNodes, Map<String, Integer> countMap) {
List<T> nodeTrees = getNodeTrees(testCaseNodes, countMap);
Iterator<T> iterator = nodeTrees.iterator();
while (iterator.hasNext()) {
T rootNode = iterator.next();
if (pruningTreeByCaseCount(rootNode)) {
iterator.remove();
}
}
return nodeTrees;
}
/** /**
* 去除没有数据的节点 * 去除没有数据的节点
* *
@ -116,6 +211,26 @@ public class NodeTreeService<T extends TreeNodeDTO> {
return false; return false;
} }
public boolean pruningTreeByCaseCount(T rootNode) {
List<T> children = rootNode.getChildren();
if (rootNode.getCaseNum() == null || rootNode.getCaseNum() < 1) {
// 没有用例的模块剪掉
return true;
}
if (children != null) {
Iterator<T> iterator = children.iterator();
while (iterator.hasNext()) {
T subNode = iterator.next();
if (pruningTreeByCaseCount(subNode)) {
iterator.remove();
}
}
}
return false;
}
/** /**
* 根据目标节点路径创建相关节点 * 根据目标节点路径创建相关节点
* *

View File

@ -8,13 +8,16 @@ import io.metersphere.service.CheckPermissionService;
import io.metersphere.track.dto.TestCaseNodeDTO; import io.metersphere.track.dto.TestCaseNodeDTO;
import io.metersphere.track.request.testcase.DragNodeRequest; import io.metersphere.track.request.testcase.DragNodeRequest;
import io.metersphere.track.request.testcase.QueryNodeRequest; import io.metersphere.track.request.testcase.QueryNodeRequest;
import io.metersphere.track.request.testcase.QueryTestCaseRequest;
import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest; import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest;
import io.metersphere.track.request.testreview.QueryCaseReviewRequest;
import io.metersphere.track.service.TestCaseNodeService; import io.metersphere.track.service.TestCaseNodeService;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
@RequestMapping("/case/node") @RequestMapping("/case/node")
@RestController @RestController
@ -31,6 +34,12 @@ public class TestCaseNodeController {
return testCaseNodeService.getNodeTreeByProjectId(projectId); return testCaseNodeService.getNodeTreeByProjectId(projectId);
} }
@PostMapping("/list/{projectId}")
public List<TestCaseNodeDTO> getNodeByCondition(@PathVariable String projectId, @RequestBody(required = false) QueryTestCaseRequest request) {
checkPermissionService.checkProjectOwner(projectId);
return testCaseNodeService.getNodeTreeByProjectId(projectId, Optional.ofNullable(request).orElse(new QueryTestCaseRequest()));
}
@PostMapping("/minder/extraNode/count") @PostMapping("/minder/extraNode/count")
public Map<String, Integer> getMinderTreeExtraNodeCount(@RequestBody List<String> nodeIds) { public Map<String, Integer> getMinderTreeExtraNodeCount(@RequestBody List<String> nodeIds) {
return testCaseNodeService.getMinderTreeExtraNodeCount(nodeIds); return testCaseNodeService.getMinderTreeExtraNodeCount(nodeIds);
@ -70,8 +79,14 @@ public class TestCaseNodeController {
return testCaseNodeService.getNodeByPlanId(planId); return testCaseNodeService.getNodeByPlanId(planId);
} }
@PostMapping("/list/plan/{planId}")
public List<TestCaseNodeDTO> getNodeByPlanId(@PathVariable String planId, @RequestBody(required = false) QueryTestPlanCaseRequest request) {
checkPermissionService.checkTestPlanOwner(planId);
return testCaseNodeService.getNodeByPlanId(planId, Optional.ofNullable(request).orElse(new QueryTestPlanCaseRequest()));
}
@GetMapping("/list/plan/{planId}/{runResult}") @GetMapping("/list/plan/{planId}/{runResult}")
public List<TestCaseNodeDTO> getNodeByPlanIdAndRunResult(@PathVariable String planId,@PathVariable String runResult) { public List<TestCaseNodeDTO> getNodeByPlanIdAndRunResult(@PathVariable String planId, @PathVariable String runResult) {
checkPermissionService.checkTestPlanOwner(planId); checkPermissionService.checkTestPlanOwner(planId);
QueryTestPlanCaseRequest request = new QueryTestPlanCaseRequest(); QueryTestPlanCaseRequest request = new QueryTestPlanCaseRequest();
request.setPlanId(planId); request.setPlanId(planId);
@ -85,6 +100,12 @@ public class TestCaseNodeController {
return testCaseNodeService.getNodeByReviewId(reviewId); return testCaseNodeService.getNodeByReviewId(reviewId);
} }
@PostMapping("/list/review/{reviewId}")
public List<TestCaseNodeDTO> getNodeByReviewId(@PathVariable String reviewId, @RequestBody(required = false) QueryCaseReviewRequest request) {
checkPermissionService.checkTestReviewOwner(reviewId);
return testCaseNodeService.getNodeByReviewId(reviewId, Optional.ofNullable(request).orElse(new QueryCaseReviewRequest()));
}
@PostMapping("/add") @PostMapping("/add")
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE, type = OperLogConstants.CREATE, title = "#node.name", content = "#msClass.getLogDetails(#node)", msClass = TestCaseNodeService.class) @MsAuditLog(module = OperLogModule.TRACK_TEST_CASE, type = OperLogConstants.CREATE, title = "#node.name", content = "#msClass.getLogDetails(#node)", msClass = TestCaseNodeService.class)
public String addNode(@RequestBody TestCaseNode node) { public String addNode(@RequestBody TestCaseNode node) {

View File

@ -7,8 +7,8 @@ import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.*; import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ext.ExtTestCaseMapper; import io.metersphere.base.mapper.ext.ExtTestCaseMapper;
import io.metersphere.base.mapper.ext.ExtTestCaseNodeMapper; import io.metersphere.base.mapper.ext.ExtTestCaseNodeMapper;
import io.metersphere.base.mapper.ext.ExtTestCaseReviewTestCaseMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper; import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper;
import io.metersphere.base.mapper.ext.ExtTestReviewCaseMapper;
import io.metersphere.commons.constants.TestCaseConstants; import io.metersphere.commons.constants.TestCaseConstants;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.BeanUtils; import io.metersphere.commons.utils.BeanUtils;
@ -22,16 +22,19 @@ import io.metersphere.log.vo.DetailColumn;
import io.metersphere.log.vo.OperatingLogDetails; import io.metersphere.log.vo.OperatingLogDetails;
import io.metersphere.log.vo.api.ModuleReference; import io.metersphere.log.vo.api.ModuleReference;
import io.metersphere.service.NodeTreeService; import io.metersphere.service.NodeTreeService;
import io.metersphere.service.ProjectService;
import io.metersphere.track.dto.TestCaseDTO; import io.metersphere.track.dto.TestCaseDTO;
import io.metersphere.track.dto.TestCaseNodeDTO; import io.metersphere.track.dto.TestCaseNodeDTO;
import io.metersphere.track.dto.TestPlanCaseDTO; import io.metersphere.track.dto.TestPlanCaseDTO;
import io.metersphere.track.request.testcase.*; import io.metersphere.track.request.testcase.*;
import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest; import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest;
import io.metersphere.track.request.testreview.QueryCaseReviewRequest;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionUtils; import org.mybatis.spring.SqlSessionUtils;
import org.springframework.context.annotation.Lazy;
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;
@ -63,11 +66,12 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
@Resource @Resource
ProjectMapper projectMapper; ProjectMapper projectMapper;
@Resource @Resource
TestCaseReviewTestCaseMapper testCaseReviewTestCaseMapper;
@Resource
ExtTestCaseReviewTestCaseMapper extTestCaseReviewTestCaseMapper;
@Resource
TestCaseReviewMapper testCaseReviewMapper; TestCaseReviewMapper testCaseReviewMapper;
@Resource
ExtTestReviewCaseMapper extTestReviewCaseMapper;
@Lazy
@Resource
ProjectService projectService;
public TestCaseNodeService() { public TestCaseNodeService() {
super(TestCaseNodeDTO.class); super(TestCaseNodeDTO.class);
@ -138,81 +142,42 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
testCaseNodeMapper.insert(record); testCaseNodeMapper.insert(record);
record.setCaseNum(0); record.setCaseNum(0);
return record; return record;
}else { } else {
return list.get(0); return list.get(0);
} }
} }
public List<TestCaseNodeDTO> getNodeTreeByProjectId(String projectId) { public List<TestCaseNodeDTO> getNodeTreeByProjectId(String projectId) {
QueryTestCaseRequest request = new QueryTestCaseRequest(); return getNodeTreeByProjectId(projectId, new QueryTestCaseRequest());
return getNodeTreeByProjectId(projectId, request);
} }
public List<TestCaseNodeDTO> getNodeTreeByProjectId(String projectId, QueryTestCaseRequest request) { public List<TestCaseNodeDTO> getNodeTreeByProjectId(String projectId, QueryTestCaseRequest request) {
// 判断当前项目下是否有默认模块没有添加默认模块 // 判断当前项目下是否有默认模块没有添加默认模块
this.getDefaultNode(projectId); this.getDefaultNode(projectId);
List<TestCaseNodeDTO> testCaseNodes = extTestCaseNodeMapper.getNodeTreeByProjectId(projectId);
request.setUserId(SessionUtils.getUserId());
request.setProjectId(projectId); request.setProjectId(projectId);
request.setUserId(SessionUtils.getUserId());
//优化将for循环内的SQL抽出来只差一次 List<TestCaseNodeDTO> countMNodes = extTestCaseMapper.getCountNodes(request);
List<String> allModuleIdList = new ArrayList<>(); List<TestCaseNodeDTO> testCaseNodes = extTestCaseNodeMapper.getNodeTreeByProjectId(projectId);
for (TestCaseNodeDTO node : testCaseNodes) { return getNodeTrees(testCaseNodes, getCountMap(countMNodes));
List<String> moduleIds = new ArrayList<>();
moduleIds = this.nodeList(testCaseNodes, node.getId(), moduleIds);
moduleIds.add(node.getId());
for (String moduleId : moduleIds) {
if(!allModuleIdList.contains(moduleId)){
allModuleIdList.add(moduleId);
}
}
}
request.setModuleIds(allModuleIdList);
List<Map<String,Object>> moduleCountList = extTestCaseMapper.moduleCountByCollection(request);
Map<String,Integer> moduleCountMap = this.parseModuleCountList(moduleCountList);
testCaseNodes.forEach(node -> {
List<String> moduleIds = new ArrayList<>();
moduleIds = this.nodeList(testCaseNodes, node.getId(), moduleIds);
moduleIds.add(node.getId());
int countNum = 0;
for (String moduleId : moduleIds) {
if(moduleCountMap.containsKey(moduleId)){
countNum += moduleCountMap.get(moduleId).intValue();
}
}
node.setCaseNum(countNum);
});
return getNodeTrees(testCaseNodes);
} }
private Map<String, Integer> parseModuleCountList(List<Map<String, Object>> moduleCountList) { private Map<String, Integer> parseModuleCountList(List<Map<String, Object>> moduleCountList) {
Map<String,Integer> returnMap = new HashMap<>(); Map<String, Integer> returnMap = new HashMap<>();
for (Map<String, Object> map: moduleCountList){ for (Map<String, Object> map : moduleCountList) {
Object moduleIdObj = map.get("moduleId"); Object moduleIdObj = map.get("moduleId");
Object countNumObj = map.get("countNum"); Object countNumObj = map.get("countNum");
if(moduleIdObj!= null && countNumObj != null){ if (moduleIdObj != null && countNumObj != null) {
String moduleId = String.valueOf(moduleIdObj); String moduleId = String.valueOf(moduleIdObj);
try { try {
Integer countNumInteger = new Integer(String.valueOf(countNumObj)); Integer countNumInteger = Integer.valueOf(String.valueOf(countNumObj));
returnMap.put(moduleId,countNumInteger); returnMap.put(moduleId, countNumInteger);
}catch (Exception e){ } catch (Exception e) {
} }
} }
} }
return returnMap; return returnMap;
} }
public static List<String> nodeList(List<TestCaseNodeDTO> testCaseNodes, String pid, List<String> list) {
for (TestCaseNodeDTO node : testCaseNodes) {
//遍历出父id等于参数的idadd进子节点集合
if (StringUtils.equals(node.getParentId(), pid)) {
list.add(node.getId());
//递归遍历下一级
nodeList(testCaseNodes, node.getId(), list);
}
}
return list;
}
public int editNode(DragNodeRequest request) { public int editNode(DragNodeRequest request) {
request.setUpdateTime(System.currentTimeMillis()); request.setUpdateTime(System.currentTimeMillis());
checkTestCaseNodeExist(request); checkTestCaseNodeExist(request);
@ -235,6 +200,7 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
/** /**
* 修改用例的 nodePath * 修改用例的 nodePath
*
* @param editNodeIds * @param editNodeIds
* @param projectId * @param projectId
*/ */
@ -263,9 +229,9 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
} }
private List<String> selectCaseIdByNodeIds(List<String> nodeIds) { private List<String> selectCaseIdByNodeIds(List<String> nodeIds) {
if(CollectionUtils.isEmpty(nodeIds)){ if (CollectionUtils.isEmpty(nodeIds)) {
return new ArrayList<>(); return new ArrayList<>();
}else { } else {
return extTestCaseMapper.selectIdsByNodeIds(nodeIds); return extTestCaseMapper.selectIdsByNodeIds(nodeIds);
} }
} }
@ -278,7 +244,6 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
* @return List<TestCaseNodeDTO> * @return List<TestCaseNodeDTO>
*/ */
public List<TestCaseNodeDTO> getNodeByQueryRequest(QueryTestPlanCaseRequest request) { public List<TestCaseNodeDTO> getNodeByQueryRequest(QueryTestPlanCaseRequest request) {
List<TestCaseNodeDTO> list = new ArrayList<>(); List<TestCaseNodeDTO> list = new ArrayList<>();
List<String> projectIds = testPlanProjectService.getProjectIdsByPlanId(request.getPlanId()); List<String> projectIds = testPlanProjectService.getProjectIdsByPlanId(request.getPlanId());
projectIds.forEach(id -> { projectIds.forEach(id -> {
@ -300,17 +265,22 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
* 获取当前计划下 * 获取当前计划下
* 有关联数据的节点 * 有关联数据的节点
* *
* @param planId plan id * @param planId plan id
* @param request 根据查询条件过滤用例数量
* @return List<TestCaseNodeDTO> * @return List<TestCaseNodeDTO>
*/ */
public List<TestCaseNodeDTO> getNodeByPlanId(String planId) { public List<TestCaseNodeDTO> getNodeByPlanId(String planId, QueryTestPlanCaseRequest request) {
List<TestCase> testCases = extTestPlanTestCaseMapper.getTestCaseWithNodeInfo(planId); request.setPlanId(planId);
Map<String, List<String>> projectNodeMap = getProjectNodeMap(testCases); request.setProjectId(null);
return getNodeTreeWithPruningTree(projectNodeMap); List<TestCaseNodeDTO> countModules = extTestPlanTestCaseMapper.getTestPlanCountNodes(request);
return getNodeTreeWithPruningTree(countModules);
} }
public List<TestCaseNodeDTO> getPublicNodeByProjectNode(List<TestCaseNodeDTO> projectNodes) { public List<TestCaseNodeDTO> getNodeByPlanId(String planId) {
QueryTestCaseRequest request = new QueryTestCaseRequest(); return this.getNodeByPlanId(planId, new QueryTestPlanCaseRequest());
}
public List<TestCaseNodeDTO> getPublicNodeByProjectNode(List<TestCaseNodeDTO> projectNodes, QueryTestCaseRequest request) {
request.setCasePublic(true); request.setCasePublic(true);
for (TestCaseNodeDTO dto : projectNodes) { for (TestCaseNodeDTO dto : projectNodes) {
List<TestCaseNodeDTO> children = this.getNodeTreeByProjectId(dto.getId(), request); List<TestCaseNodeDTO> children = this.getNodeTreeByProjectId(dto.getId(), request);
@ -322,60 +292,37 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
} }
public List<TestCaseNodeDTO> getNodeByReviewId(String reviewId) { public List<TestCaseNodeDTO> getNodeByReviewId(String reviewId) {
List<TestCase> testCases = extTestCaseReviewTestCaseMapper.getTestCaseWithNodeInfo(reviewId); return this.getNodeByReviewId(reviewId, new QueryCaseReviewRequest());
Map<String, List<String>> projectNodeMap = getProjectNodeMap(testCases);
return getNodeTreeWithPruningTree(projectNodeMap);
} }
public List<TestCaseNodeDTO> getNodeTreeWithPruningTree(Map<String, List<String>> projectNodeMap) { public List<TestCaseNodeDTO> getNodeByReviewId(String reviewId, QueryCaseReviewRequest request) {
List<TestCaseNodeDTO> list = new ArrayList<>(); request.setReviewId(reviewId);
projectNodeMap.forEach((k, v) -> { request.setProjectId(null);
Project project = projectMapper.selectByPrimaryKey(k); List<TestCaseNodeDTO> countModules = extTestReviewCaseMapper.getTestReviewCountNodes(request);
if (project != null) { return getNodeTreeWithPruningTree(countModules);
String name = project.getName(); }
List<TestCaseNodeDTO> testCaseNodes = getNodeTreeWithPruningTree(k, v);
TestCaseNodeDTO testCaseNodeDTO = new TestCaseNodeDTO(); public List<TestCaseNodeDTO> getNodeTreeWithPruningTree(List<TestCaseNodeDTO> countModules) {
testCaseNodeDTO.setId(project.getId()); return getNodeTreeWithPruningTree(countModules, extTestCaseNodeMapper::getNodeTreeByProjectIds);
testCaseNodeDTO.setName(name);
testCaseNodeDTO.setLabel(name);
testCaseNodeDTO.setChildren(testCaseNodes);
if (!CollectionUtils.isEmpty(testCaseNodes)) {
list.add(testCaseNodeDTO);
}
}
});
return list;
} }
/** /**
* 获取当前项目下的 * 生成模块树并剪枝
* @param projectId *
* @param pruningTreeIds
* @return * @return
*/ */
public List<TestCaseNodeDTO> getNodeTreeWithPruningTree(String projectId, List<String> pruningTreeIds) { public List<TestCaseNodeDTO> getNodeTreeWithPruningTree(List<TestCaseNodeDTO> testCaseNodes, List<String> containIds) {
List<TestCaseNodeDTO> testCaseNodes = extTestCaseNodeMapper.getNodeTreeByProjectId(projectId);
List<TestCaseNodeDTO> nodeTrees = getNodeTrees(testCaseNodes); List<TestCaseNodeDTO> nodeTrees = getNodeTrees(testCaseNodes);
Iterator<TestCaseNodeDTO> iterator = nodeTrees.iterator(); Iterator<TestCaseNodeDTO> iterator = nodeTrees.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
TestCaseNodeDTO rootNode = iterator.next(); TestCaseNodeDTO rootNode = iterator.next();
if (pruningTree(rootNode, pruningTreeIds)) { if (pruningTree(rootNode, containIds)) {
iterator.remove(); iterator.remove();
} }
} }
return nodeTrees; return nodeTrees;
} }
private Map<String, List<String>> getProjectNodeMap(List<TestCase> testCases) {
Map<String, List<String>> projectNodeMap = new HashMap<>();
for (TestCase testCase : testCases) {
List<String> nodeIds = Optional.ofNullable(projectNodeMap.get(testCase.getProjectId())).orElse(new ArrayList<>());
nodeIds.add(testCase.getNodeId());
projectNodeMap.put(testCase.getProjectId(), nodeIds);
}
return projectNodeMap;
}
private List<TestCaseNodeDTO> getNodeDTO(String projectId, QueryTestPlanCaseRequest request) { private List<TestCaseNodeDTO> getNodeDTO(String projectId, QueryTestPlanCaseRequest request) {
List<TestPlanCaseDTO> testPlanTestCases = extTestPlanTestCaseMapper.listByPlanId(request); List<TestPlanCaseDTO> testPlanTestCases = extTestPlanTestCaseMapper.listByPlanId(request);
if (testPlanTestCases.isEmpty()) { if (testPlanTestCases.isEmpty()) {
@ -392,7 +339,8 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
.map(TestCase::getNodeId) .map(TestCase::getNodeId)
.collect(Collectors.toList()); .collect(Collectors.toList());
return getNodeTreeWithPruningTree(projectId, dataNodeIds); List<TestCaseNodeDTO> testCaseNodes = extTestCaseNodeMapper.getNodeTreeByProjectId(projectId);
return getNodeTreeWithPruningTree(testCaseNodes, dataNodeIds);
} }
public List<TestCaseNodeDTO> getAllNodeByPlanId(QueryNodeRequest request) { public List<TestCaseNodeDTO> getAllNodeByPlanId(QueryNodeRequest request) {
@ -415,7 +363,6 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
if (testCaseReview == null) { if (testCaseReview == null) {
return Collections.emptyList(); return Collections.emptyList();
} }
return getNodeTreeByProjectId(projectId); return getNodeTreeByProjectId(projectId);
} }
@ -533,8 +480,8 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
private List<TestCaseDTO> QueryTestCaseByNodeIds(List<String> nodeIds) { private List<TestCaseDTO> QueryTestCaseByNodeIds(List<String> nodeIds) {
QueryTestCaseRequest testCaseRequest = new QueryTestCaseRequest(); QueryTestCaseRequest testCaseRequest = new QueryTestCaseRequest();
testCaseRequest.setNodeIds(nodeIds); testCaseRequest.setNodeIds(nodeIds);
if(testCaseRequest.getFilters()!=null && !testCaseRequest.getFilters().containsKey("status")){ if (testCaseRequest.getFilters() != null && !testCaseRequest.getFilters().containsKey("status")) {
testCaseRequest.getFilters().put("status",new ArrayList<>(0)); testCaseRequest.getFilters().put("status", new ArrayList<>(0));
} }
return extTestCaseMapper.list(testCaseRequest); return extTestCaseMapper.list(testCaseRequest);
} }
@ -578,10 +525,6 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
return projectMapper.selectByPrimaryKey(projectId); return projectMapper.selectByPrimaryKey(projectId);
} }
private TestCaseNode getCaseNode(String id) {
return testCaseNodeMapper.selectByPrimaryKey(id);
}
@Override @Override
public TestCaseNodeDTO getNode(String id) { public TestCaseNodeDTO getNode(String id) {
return extTestCaseNodeMapper.get(id); return extTestCaseNodeMapper.get(id);
@ -729,7 +672,7 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
if (org.apache.commons.collections.CollectionUtils.isNotEmpty(testCaseNodes)) { if (org.apache.commons.collections.CollectionUtils.isNotEmpty(testCaseNodes)) {
for (TestCaseMinderEditRequest.TestCaseNodeMinderEditItem item: testCaseNodes) { for (TestCaseMinderEditRequest.TestCaseNodeMinderEditItem item : testCaseNodes) {
if (StringUtils.isBlank(item.getParentId()) || item.getParentId().equals("root")) { if (StringUtils.isBlank(item.getParentId()) || item.getParentId().equals("root")) {
item.setParentId(null); item.setParentId(null);
} }
@ -759,6 +702,7 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
/** /**
* 统计某些节点下的临时节点的数量 * 统计某些节点下的临时节点的数量
*
* @param nodeIds * @param nodeIds
* @return * @return
*/ */
@ -769,4 +713,4 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
List<Map<String, Object>> moduleCountList = extTestCaseMapper.moduleExtraNodeCount(nodeIds); List<Map<String, Object>> moduleCountList = extTestCaseMapper.moduleExtraNodeCount(nodeIds);
return this.parseModuleCountList(moduleCountList); return this.parseModuleCountList(moduleCountList);
} }
} }

View File

@ -2775,7 +2775,7 @@ public class TestCaseService {
public List<TestCaseNodeDTO> getPublicCaseNode(QueryTestCaseRequest request) { public List<TestCaseNodeDTO> getPublicCaseNode(QueryTestCaseRequest request) {
List<TestCaseNodeDTO> testCaseDTOS = publicProjectNode(request); List<TestCaseNodeDTO> testCaseDTOS = publicProjectNode(request);
return testCaseNodeService.getPublicNodeByProjectNode(testCaseDTOS); return testCaseNodeService.getPublicNodeByProjectNode(testCaseDTOS, request);
} }
public List<TestCaseNodeDTO> publicProjectNode(QueryTestCaseRequest request) { public List<TestCaseNodeDTO> publicProjectNode(QueryTestCaseRequest request) {

View File

@ -3,34 +3,28 @@
<ms-aside-container v-show="isAsideHidden"> <ms-aside-container v-show="isAsideHidden">
<test-case-node-tree <test-case-node-tree
@nodeSelectEvent="nodeChange" :type="'edit'"
:total='total'
:show-operator="true"
:public-total="publicTotal"
@refreshTable="refresh" @refreshTable="refresh"
@setTreeNodes="setTreeNodes" @setTreeNodes="setTreeNodes"
@exportTestCase="exportTestCase" @exportTestCase="exportTestCase"
@saveAsEdit="editTestCase" @saveAsEdit="editTestCase"
:show-operator="true"
@createCase="handleCaseSimpleCreate($event, 'add')"
@refreshAll="refreshAll" @refreshAll="refreshAll"
@enableTrash="enableTrash" @enableTrash="enableTrash"
@enablePublic="enablePublic" @enablePublic="enablePublic"
@toPublic="toPublic" @toPublic="toPublic"
:type="'edit'"
:total='total'
:public-total="publicTotal"
ref="nodeTree"
@importChangeConfirm="importChangeConfirm" @importChangeConfirm="importChangeConfirm"
@createCase="handleCaseSimpleCreate($event, 'add')"
ref="nodeTree"
/> />
</ms-aside-container> </ms-aside-container>
<ms-aside-container v-if="showPublicNode"> <ms-aside-container v-if="showPublicNode">
<node-tree class="node-tree" <test-case-public-node-tree
:is-display="'public'" @nodeSelectEvent="publicNodeChange"
v-loading="result.loading" ref="publicNodeTree"/>
local-suffix="test_case"
default-label="未规划用例"
@nodeSelectEvent="publicNodeChange"
:tree-nodes="publicTreeNodes"
ref="publicNodeTree"/>
</ms-aside-container> </ms-aside-container>
<ms-main-container> <ms-main-container>
@ -57,6 +51,7 @@
@refresh="refresh" @refresh="refresh"
@refreshAll="refreshAll" @refreshAll="refreshAll"
@setCondition="setCondition" @setCondition="setCondition"
@search="refreshTreeByCaseFilter"
ref="testCaseTrashList"> ref="testCaseTrashList">
</test-case-list> </test-case-list>
</ms-tab-button> </ms-tab-button>
@ -81,6 +76,7 @@
@refreshAll="refreshAll" @refreshAll="refreshAll"
@refreshPublic="refreshPublic" @refreshPublic="refreshPublic"
@setCondition="setCondition" @setCondition="setCondition"
@search="refreshTreeByCaseFilter"
ref="testCasePublicList"> ref="testCasePublicList">
</test-case-list> </test-case-list>
</el-tab-pane> </el-tab-pane>
@ -115,6 +111,7 @@
@refreshAll="refreshAll" @refreshAll="refreshAll"
@setCondition="setCondition" @setCondition="setCondition"
@decrease="decrease" @decrease="decrease"
@search="refreshTreeByCaseFilter"
ref="testCaseList"> ref="testCaseList">
</test-case-list> </test-case-list>
<test-case-minder <test-case-minder
@ -218,14 +215,15 @@ import {
hasPermission, hasPermission,
setCurTabId setCurTabId
} from "@/common/js/utils"; } from "@/common/js/utils";
import TestCaseNodeTree from "../common/TestCaseNodeTree"; import TestCaseNodeTree from "../module/TestCaseNodeTree";
import MsTabButton from "@/business/components/common/components/MsTabButton"; import MsTabButton from "@/business/components/common/components/MsTabButton";
import TestCaseMinder from "@/business/components/track/common/minder/TestCaseMinder"; import TestCaseMinder from "@/business/components/track/common/minder/TestCaseMinder";
import IsChangeConfirm from "@/business/components/common/components/IsChangeConfirm"; import IsChangeConfirm from "@/business/components/common/components/IsChangeConfirm";
import {openMinderConfirm, saveMinderConfirm} from "@/business/components/track/common/minder/minderUtils"; import {openMinderConfirm} from "@/business/components/track/common/minder/minderUtils";
import TestCaseEditShow from "@/business/components/track/case/components/TestCaseEditShow"; import TestCaseEditShow from "@/business/components/track/case/components/TestCaseEditShow";
import {PROJECT_ID} from "@/common/js/constants"; import {PROJECT_ID} from "@/common/js/constants";
import TestCasePublicNodeTree from "@/business/components/track/module/TestCasePublicNodeTree";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/); const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const VersionSelect = requireComponent.keys().length > 0 ? requireComponent("./version/VersionSelect.vue") : {}; const VersionSelect = requireComponent.keys().length > 0 ? requireComponent("./version/VersionSelect.vue") : {};
@ -233,6 +231,7 @@ const VersionSelect = requireComponent.keys().length > 0 ? requireComponent("./v
export default { export default {
name: "TestCase", name: "TestCase",
components: { components: {
TestCasePublicNodeTree,
IsChangeConfirm, IsChangeConfirm,
TestCaseMinder, TestCaseMinder,
MsTabButton, MsTabButton,
@ -267,8 +266,6 @@ export default {
currentTrashVersion: null, currentTrashVersion: null,
versionEnable: false, versionEnable: false,
isAsideHidden: true, isAsideHidden: true,
showPublicNode: false,
publicTreeNodes: [],
ignoreTreeNodes:false, ignoreTreeNodes:false,
}; };
}, },
@ -306,8 +303,7 @@ export default {
this.init(to); this.init(to);
}, },
activeName(newVal, oldVal) { activeName(newVal, oldVal) {
this.isAsideHidden = this.activeName === 'default'; this.isAsideHidden = this.activeName === 'default' || this.activeName === 'trash';
this.showPublicNode = this.activeName === 'public';
if (oldVal !== 'default' && newVal === 'default' && this.$refs.minder) { if (oldVal !== 'default' && newVal === 'default' && this.$refs.minder) {
this.$refs.minder.refresh(); this.$refs.minder.refresh();
} }
@ -323,18 +319,15 @@ export default {
if (this.trashEnable) { if (this.trashEnable) {
this.activeName = 'trash'; this.activeName = 'trash';
} else { } else {
this.activeName = 'default'; this.actciveName = 'default';
} }
}, },
publicEnable() { publicEnable() {
if (this.publicEnable) { if (this.publicEnable) {
this.activeName = 'public'; this.activeName = 'public';
this.result = this.$post('/test/case/public/case/node', {workspaceId: getCurrentWorkspaceId()}, res => { this.$nextTick(() => {
this.publicTreeNodes = res.data; this.$refs.publicNodeTree.list();
this.publicTreeNodes.forEach(firstLevel => { });
this.$refs.publicNodeTree.nodeExpand(firstLevel);
})
})
} else { } else {
this.activeName = 'default'; this.activeName = 'default';
} }
@ -355,7 +348,9 @@ export default {
let redirectParam = this.$route.params.dataSelectRange; let redirectParam = this.$route.params.dataSelectRange;
return redirectParam; return redirectParam;
}, },
showPublicNode() {
return this.activeName === 'public';
},
projectId() { projectId() {
return getCurrentProjectID(); return getCurrentProjectID();
}, },
@ -592,16 +587,7 @@ export default {
this.$router.push('/track/case/all'); this.$router.push('/track/case/all');
} }
}, },
nodeChange(node) {
this.condition.trashEnable = false;
this.trashEnable = false;
this.condition.publicEnable = false;
this.publicEnable = false;
this.activeName = "default";
},
publicNodeChange(node, nodeIds, pNodes) { publicNodeChange(node, nodeIds, pNodes) {
this.activeName = 'public';
this.publicEnable = true;
if (this.$refs.testCasePublicList) { if (this.$refs.testCasePublicList) {
this.$refs.testCasePublicList.initTableData(nodeIds); this.$refs.testCasePublicList.initTableData(nodeIds);
} }
@ -681,6 +667,13 @@ export default {
} }
this.refreshAll(data); this.refreshAll(data);
}, },
refreshTreeByCaseFilter() {
if (this.publicEnable) {
this.$refs.publicNodeTree.list(this.condition);
} else if (!this.trashEnable) {
this.$refs.nodeTree.list(this.condition);
}
},
setTable(data) { setTable(data) {
if (data) { if (data) {
for (let index in this.tabs) { for (let index in this.tabs) {
@ -709,9 +702,7 @@ export default {
if (this.$refs.testCasePublicList) { if (this.$refs.testCasePublicList) {
this.$refs.testCasePublicList.initTableData([]); this.$refs.testCasePublicList.initTableData([]);
} }
this.result = this.$post('/test/case/public/case/node', {workspaceId: getCurrentWorkspaceId()}, res => { this.$refs.publicNodeTree.list();
this.publicTreeNodes = res.data;
})
}, },
setTreeNodes(data) { setTreeNodes(data) {
this.treeNodes = data; this.treeNodes = data;
@ -728,11 +719,9 @@ export default {
}); });
}, },
enableTrash(data) { enableTrash(data) {
this.initApiTableOpretion = "trashEnable";
this.trashEnable = data; this.trashEnable = data;
}, },
enablePublic(data) { enablePublic(data) {
this.initApiTableOpretion = "publicEnable";
this.publicEnable = !data; this.publicEnable = !data;
this.$nextTick(() => { this.$nextTick(() => {
this.publicEnable = data; this.publicEnable = data;
@ -744,7 +733,6 @@ export default {
} else { } else {
this.activeName = "trash" this.activeName = "trash"
} }
}, },
changeVersion(currentVersion) { changeVersion(currentVersion) {
this.currentVersion = currentVersion || null; this.currentVersion = currentVersion || null;

View File

@ -823,6 +823,7 @@ export default {
// //
this.page.currentPage = 1; this.page.currentPage = 1;
this.initTableData(); this.initTableData();
this.$emit('search');
}, },
buildPagePath(path) { buildPagePath(path) {
return path + "/" + this.page.currentPage + "/" + this.page.pageSize; return path + "/" + this.page.currentPage + "/" + this.page.pageSize;
@ -1126,7 +1127,6 @@ export default {
this.$warning(this.$t('test_track.case.public_warning')); this.$warning(this.$t('test_track.case.public_warning'));
} }
}); });
}, },
openRelateDemand() { openRelateDemand() {
this.$refs.relateDemand.open(); this.$refs.relateDemand.open();

View File

@ -24,10 +24,10 @@
:show-operator="showOperator" :show-operator="showOperator"
:condition="condition" :condition="condition"
:commands="operators"/> :commands="operators"/>
<module-trash-button <module-trash-button
:condition="condition" :condition="condition"
:total="total" :total="total"
:exe="enableTrash"/> :exe="enableTrash"/>
<module-public-button <module-public-button
:condition="condition" :condition="condition"
:public-total="publicTotal" :public-total="publicTotal"
@ -58,8 +58,8 @@
</template> </template>
<script> <script>
import NodeEdit from "./NodeEdit"; import NodeEdit from "../common/NodeEdit";
import MsNodeTree from "./NodeTree"; import MsNodeTree from "../common/NodeTree";
import TestCaseCreate from "@/business/components/track/case/components/TestCaseCreate"; import TestCaseCreate from "@/business/components/track/case/components/TestCaseCreate";
import TestCaseImport from "@/business/components/track/case/components/import/TestCaseImport"; import TestCaseImport from "@/business/components/track/case/components/import/TestCaseImport";
import TestCaseExport from "@/business/components/track/case/components/TestCaseExport"; import TestCaseExport from "@/business/components/track/case/components/TestCaseExport";
@ -69,7 +69,7 @@ import {buildNodePath} from "@/business/components/api/definition/model/NodeTree
import {getCurrentProjectID} from "@/common/js/utils"; import {getCurrentProjectID} from "@/common/js/utils";
import ModuleTrashButton from "@/business/components/api/definition/components/module/ModuleTrashButton"; import ModuleTrashButton from "@/business/components/api/definition/components/module/ModuleTrashButton";
import ModulePublicButton from "@/business/components/api/definition/components/module/ModulePublicButton"; import ModulePublicButton from "@/business/components/api/definition/components/module/ModulePublicButton";
import {getTestCaseNodes} from "@/network/testCase"; import {getTestCaseNodes, getTestCaseNodesByCaseFilter} from "@/network/testCase";
import IsChangeConfirm from "@/business/components/common/components/IsChangeConfirm"; import IsChangeConfirm from "@/business/components/common/components/IsChangeConfirm";
export default { export default {
@ -181,9 +181,9 @@ export default {
this.$emit('enablePublic', this.condition.publicEnable); this.$emit('enablePublic', this.condition.publicEnable);
this.$emit('toPublic', 'public'); this.$emit('toPublic', 'public');
}, },
list() { list(caseCondition) {
if (this.projectId) { if (this.projectId) {
this.result = getTestCaseNodes(this.projectId, data => { this.result = getTestCaseNodesByCaseFilter(this.projectId, caseCondition, data => {
this.treeNodes = data; this.treeNodes = data;
this.treeNodes.forEach(node => { this.treeNodes.forEach(node => {
node.name = node.name === '未规划用例' ? this.$t('api_test.unplanned_case') : node.name node.name = node.name === '未规划用例' ? this.$t('api_test.unplanned_case') : node.name
@ -275,15 +275,10 @@ export default {
this.$store.commit('setTestCaseSelectNodeIds', nodeIds); this.$store.commit('setTestCaseSelectNodeIds', nodeIds);
this.condition.trashEnable = false; this.condition.trashEnable = false;
this.condition.publicEnable = false; this.condition.publicEnable = false;
this.$emit("nodeSelectEvent", node, nodeIds, pNodes);
this.currentModule = node.data; this.currentModule = node.data;
this.currentNode = node; this.currentNode = node;
if (node.data.id === 'root') {
this.$emit("nodeSelectEvent", node, [], pNodes); this.$emit("nodeSelectEvent", node, node.data.id === 'root' ? [] : nodeIds, pNodes);
} else {
this.$emit("nodeSelectEvent", node, nodeIds, pNodes);
}
}, },
openMinderConfirm() { openMinderConfirm() {
let isTestCaseMinderChanged = this.$store.state.isTestCaseMinderChanged; let isTestCaseMinderChanged = this.$store.state.isTestCaseMinderChanged;

View File

@ -0,0 +1,48 @@
<template>
<ms-node-tree class="node-tree"
:is-display="'public'"
v-loading="result.loading"
local-suffix="test_case"
default-label="未规划用例"
@nodeSelectEvent="publicNodeChange"
:tree-nodes="publicTreeNodes"
ref="publicNodeTree"/>
</template>
<script>
import MsNodeTree from "@/business/components/track/common/NodeTree";
import {getTestCasePublicNodes} from "@/network/testCase";
export default {
name: "TestCasePublicNodeTree",
components: {MsNodeTree},
data() {
return {
publicTreeNodes: [],
result: {}
}
},
methods: {
publicNodeChange(node, nodeIds, pNodes) {
this.$emit("nodeSelectEvent", node, node.data.id === 'root' ? [] : nodeIds, pNodes);
},
list(caseCondition) {
let condition = {
...caseCondition
};
condition.projectId = null;
this.result = getTestCasePublicNodes(condition, data => {
this.publicTreeNodes = data;
if (this.$refs.publicNodeTree) {
this.publicTreeNodes.forEach(firstLevel => {
this.$refs.publicNodeTree.nodeExpand(firstLevel);
})
}
});
},
}
}
</script>
<style scoped>
</style>

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="card-container"> <div class="card-container">
<ms-table-header :condition.sync="condition" @search="initTableData" ref="tableHeader" <ms-table-header :condition.sync="condition" @search="search" ref="tableHeader"
:show-create="false" :tip="$t('commons.search_by_id_name_tag')"> :show-create="false" :tip="$t('commons.search_by_id_name_tag')">
<!-- 不显示 全部用例 标题,使标题为空 --> <!-- 不显示 全部用例 标题,使标题为空 -->
@ -35,7 +35,8 @@
:row-order-group-id="planId" :row-order-group-id="planId"
:row-order-func="editTestPlanTestCaseOrder" :row-order-func="editTestPlanTestCaseOrder"
:enable-order-drag="enableOrderDrag" :enable-order-drag="enableOrderDrag"
@refresh="initTableData" @filter="search"
@order="initTableData"
@handlePageChange="initTableData" @handlePageChange="initTableData"
@handleRowClick="handleEdit" @handleRowClick="handleEdit"
row-key="id" row-key="id"
@ -236,7 +237,7 @@
</span> </span>
</ms-table> </ms-table>
<ms-table-pagination :change="search" :current-page.sync="currentPage" :page-size.sync="pageSize" <ms-table-pagination :change="initTableData" :current-page.sync="currentPage" :page-size.sync="pageSize"
:total="total"/> :total="total"/>
<functional-test-case-edit <functional-test-case-edit
@ -252,7 +253,7 @@
:test-cases="tableData" :test-cases="tableData"
:is-read-only="isReadOnly" :is-read-only="isReadOnly"
:total="total" :total="total"
@refreshTable="search"/> @refreshTable="initTableData"/>
<batch-edit ref="batchEdit" @batchEdit="batchEdit" <batch-edit ref="batchEdit" @batchEdit="batchEdit"
:type-arr="typeArr" :value-arr="valueArr" :dialog-title="$t('test_track.case.batch_edit_case')"/> :type-arr="typeArr" :value-arr="valueArr" :dialog-title="$t('test_track.case.batch_edit_case')"/>
@ -469,7 +470,7 @@ export default {
}, },
selectNodeIds() { selectNodeIds() {
this.condition.selectAll = false; this.condition.selectAll = false;
this.search(); this.initTableData();
}, },
tableLabel: { tableLabel: {
handler(newVal) { handler(newVal) {
@ -632,7 +633,7 @@ export default {
}, },
refresh() { refresh() {
this.$refs.table.clear(); this.$refs.table.clear();
this.search(); this.initTableData();
this.$emit('refreshTree'); this.$emit('refreshTree');
}, },
refreshTableAndPlan() { refreshTableAndPlan() {
@ -650,6 +651,7 @@ export default {
}, },
search() { search() {
this.initTableData(); this.initTableData();
this.$emit('search');
}, },
buildPagePath(path) { buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize; return path + "/" + this.currentPage + "/" + this.pageSize;

View File

@ -27,11 +27,11 @@
class="border-hidden sync-textarea" class="border-hidden sync-textarea"
type="textarea" type="textarea"
:disabled="true" :disabled="true"
v-model="scope.row.result"/>eee v-model="scope.row.result"/>
</template> </template>
</el-table-column>f </el-table-column>f
<el-table-column :label="$t('test_track.plan_view.actual_result')" min-width="21%"> <el-table-column :label="$t('test_track.plan_view.actual_result')" min-width="21%">
G<template v-slot:default="scope">DD <template v-slot:default="scope">
<el-input <el-input
v-model="scope.row.actualResult" v-model="scope.row.actualResult"
clearable clearable

View File

@ -23,15 +23,16 @@
<functional-test-case-list <functional-test-case-list
class="table-list" class="table-list"
v-if="activeDom === 'left'" v-if="activeDom === 'left'"
@openTestCaseRelevanceDialog="openTestCaseRelevanceDialog"
@refresh="refresh"
@refreshTree="refreshTree"
@setCondition="setCondition"
:plan-id="planId" :plan-id="planId"
:plan-status="planStatus " :plan-status="planStatus "
:clickType="clickType" :clickType="clickType"
:select-node-ids="selectNodeIds" :select-node-ids="selectNodeIds"
:version-enable="versionEnable" :version-enable="versionEnable"
@refresh="refresh"
@refreshTree="refreshTree"
@setCondition="setCondition"
@search="refreshTreeByCaseFilter"
@openTestCaseRelevanceDialog="openTestCaseRelevanceDialog"
ref="testPlanTestCaseList"/> ref="testPlanTestCaseList"/>
<test-plan-minder <test-plan-minder
:tree-nodes="treeNodes" :tree-nodes="treeNodes"
@ -69,6 +70,7 @@ import TestPlanFunctionalRelevance
from "@/business/components/track/plan/view/comonents/functional/TestPlanFunctionalRelevance"; from "@/business/components/track/plan/view/comonents/functional/TestPlanFunctionalRelevance";
import IsChangeConfirm from "@/business/components/common/components/IsChangeConfirm"; import IsChangeConfirm from "@/business/components/common/components/IsChangeConfirm";
import {openMinderConfirm, saveMinderConfirm} from "@/business/components/track/common/minder/minderUtils"; import {openMinderConfirm, saveMinderConfirm} from "@/business/components/track/common/minder/minderUtils";
import {getTestPlanCaseNodesByCaseFilter} from "@/network/testCase";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/); const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
export default { export default {
@ -143,6 +145,9 @@ export default {
openTestCaseRelevanceDialog() { openTestCaseRelevanceDialog() {
this.$refs.testCaseRelevance.open(); this.$refs.testCaseRelevance.open();
}, },
refreshTreeByCaseFilter() {
this.getNodeTreeByPlanId(this.condition);
},
nodeChange(node, nodeIds, pNodes) { nodeChange(node, nodeIds, pNodes) {
this.selectNodeIds = nodeIds; this.selectNodeIds = nodeIds;
this.$store.commit('setTestPlanViewSelectNode', node); this.$store.commit('setTestPlanViewSelectNode', node);
@ -153,16 +158,19 @@ export default {
this.$refs.testPlanTestCaseList.pageSize = 10; this.$refs.testPlanTestCaseList.pageSize = 10;
} }
}, },
getNodeTreeByPlanId() { getNodeTreeByPlanId(condition) {
if (this.planId) { if (this.planId) {
let url = "/case/node/list/plan/" + this.planId;
if (this.clickType) { if (this.clickType) {
url = url + "/" + this.clickType; this.result = this.$get('/' + this.clickType, response => {
this.treeNodes = response.data;
this.setCurrentKey();
});
} else {
this.result = getTestPlanCaseNodesByCaseFilter(this.planId, condition, (data) => {
this.treeNodes = data;
this.setCurrentKey();
});
} }
this.result = this.$get(url, response => {
this.treeNodes = response.data;
this.setCurrentKey();
});
} }
}, },
setCurrentKey() { setCurrentKey() {

View File

@ -2,14 +2,14 @@
<ms-test-plan-common-component> <ms-test-plan-common-component>
<template v-slot:aside> <template v-slot:aside>
<ms-node-tree <ms-node-tree
v-loading="result.loading"
class="node-tree" class="node-tree"
:all-label="$t('commons.all_label.review')"
local-suffix="test_case" local-suffix="test_case"
default-label="未规划用例" default-label="未规划用例"
v-loading="result.loading"
@nodeSelectEvent="nodeChange"
:tree-nodes="treeNodes" :tree-nodes="treeNodes"
:default-expand-all="true" :default-expand-all="true"
:all-label="$t('commons.all_label.review')"
@nodeSelectEvent="nodeChange"
ref="nodeTree"/> ref="nodeTree"/>
</template> </template>
<template v-slot:main> <template v-slot:main>
@ -24,20 +24,21 @@
<test-review-test-case-list <test-review-test-case-list
class="table-list" class="table-list"
v-if="activeDom === 'left'" v-if="activeDom === 'left'"
@openTestReviewRelevanceDialog="openTestReviewRelevanceDialog"
@refresh="refresh"
@setCondition="setCondition"
:review-id="reviewId" :review-id="reviewId"
:clickType="clickType" :clickType="clickType"
:current-version="currentVersion" :current-version="currentVersion"
:version-enable="versionEnable" :version-enable="versionEnable"
@refresh="refresh"
@setCondition="setCondition"
@search="refreshTreeByCaseFilter"
@openTestReviewRelevanceDialog="openTestReviewRelevanceDialog"
ref="testPlanTestCaseList"/> ref="testPlanTestCaseList"/>
<test-review-minder <test-review-minder
v-if="activeDom === 'right'"
:tree-nodes="treeNodes" :tree-nodes="treeNodes"
:project-id="projectId" :project-id="projectId"
:condition="condition" :condition="condition"
:review-id="reviewId" :review-id="reviewId"
v-if="activeDom === 'right'"
ref="minder" ref="minder"
/> />
</ms-tab-button> </ms-tab-button>
@ -66,6 +67,7 @@ import TestReviewMinder from "@/business/components/track/common/minder/TestRevi
import {getCurrentProjectID} from "@/common/js/utils"; import {getCurrentProjectID} from "@/common/js/utils";
import IsChangeConfirm from "@/business/components/common/components/IsChangeConfirm"; import IsChangeConfirm from "@/business/components/common/components/IsChangeConfirm";
import {openMinderConfirm, saveMinderConfirm} from "@/business/components/track/common/minder/minderUtils"; import {openMinderConfirm, saveMinderConfirm} from "@/business/components/track/common/minder/minderUtils";
import {getTestReviewCaseNodesByCaseFilter} from "@/network/testCase";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/); const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const VersionSelect = requireComponent.keys().length > 0 ? requireComponent("./version/VersionSelect.vue") : {}; const VersionSelect = requireComponent.keys().length > 0 ? requireComponent("./version/VersionSelect.vue") : {};
@ -84,8 +86,6 @@ export default {
result: {}, result: {},
testReviews: [], testReviews: [],
currentReview: {}, currentReview: {},
// selectNodeIds: [],
// selectParentNodes: [],
treeNodes: [], treeNodes: [],
isMenuShow: true, isMenuShow: true,
activeDom: 'left', activeDom: 'left',
@ -133,13 +133,16 @@ export default {
this.$store.commit('setTestReviewSelectNode', node); this.$store.commit('setTestReviewSelectNode', node);
this.$store.commit('setTestReviewSelectNodeIds', nodeIds); this.$store.commit('setTestReviewSelectNodeIds', nodeIds);
}, },
getNodeTreeByReviewId() { getNodeTreeByReviewId(condition) {
if (this.reviewId) { if (this.reviewId) {
this.result = this.$get("/case/node/list/review/" + this.reviewId, response => { this.result = getTestReviewCaseNodesByCaseFilter(this.reviewId, condition, (data) => {
this.treeNodes = response.data; this.treeNodes = data;
}); });
} }
}, },
refreshTreeByCaseFilter() {
this.getNodeTreeByReviewId(this.condition);
},
openTestReviewRelevanceDialog() { openTestReviewRelevanceDialog() {
this.$refs.testReviewRelevance.openTestReviewRelevanceDialog(); this.$refs.testReviewRelevance.openTestReviewRelevanceDialog();
}, },

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="card-container"> <div class="card-container">
<ms-table-header :tester-permission="true" :condition.sync="condition" @search="initTableData" <ms-table-header :tester-permission="true" :condition.sync="condition" @search="search"
:show-create="false" :tip="$t('commons.search_by_name_or_id')"> :show-create="false" :tip="$t('commons.search_by_name_or_id')">
<template v-slot:button> <template v-slot:button>
<ms-table-button v-permission="['PROJECT_TRACK_REVIEW:READ+REVIEW']" icon="el-icon-video-play" <ms-table-button v-permission="['PROJECT_TRACK_REVIEW:READ+REVIEW']" icon="el-icon-video-play"
@ -33,7 +33,8 @@
:enable-order-drag="enableOrderDrag" :enable-order-drag="enableOrderDrag"
:row-order-func="editTestReviewTestCaseOrder" :row-order-func="editTestReviewTestCaseOrder"
:row-order-group-id="reviewId" :row-order-group-id="reviewId"
@refresh="initTableData" @order="initTableData"
@filter="search"
ref="table" ref="table"
> >
<span v-for="item in fields" :key="item.key"> <span v-for="item in fields" :key="item.key">
@ -136,7 +137,7 @@
</ms-table> </ms-table>
<ms-table-pagination :change="search" :current-page.sync="currentPage" :page-size.sync="pageSize" <ms-table-pagination :change="initTableData" :current-page.sync="currentPage" :page-size.sync="pageSize"
:total="total"/> :total="total"/>
<test-review-test-case-edit <test-review-test-case-edit
@ -152,7 +153,7 @@
@nextPage="nextPage" @nextPage="nextPage"
@prePage="prePage" @prePage="prePage"
@refresh="initTableData" @refresh="initTableData"
@refreshTable="search"/> @refreshTable="initTableData"/>
<batch-edit ref="batchEdit" @batchEdit="batchEdit" <batch-edit ref="batchEdit" @batchEdit="batchEdit"
@ -308,7 +309,7 @@ export default {
this.refreshTableAndReview(); this.refreshTableAndReview();
}, },
selectNodeIds() { selectNodeIds() {
this.search(); this.initTableData();
}, },
condition() { condition() {
this.$emit('setCondition', this.condition); this.$emit('setCondition', this.condition);
@ -431,10 +432,10 @@ export default {
let param = {}; let param = {};
param.id = this.reviewId; param.id = this.reviewId;
param.updateTime = Date.now(); param.updateTime = Date.now();
// this.$post('/test/case/review/edit', param);
}, },
search() { search() {
this.initTableData(); this.initTableData();
this.$emit('search');
}, },
buildPagePath(path) { buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize; return path + "/" + this.currentPage + "/" + this.pageSize;

View File

@ -84,8 +84,20 @@ export function editTestReviewTestCaseOrder(request, callback) {
return basePost('/test/review/case/edit/order', request, callback); return basePost('/test/review/case/edit/order', request, callback);
} }
export function getTestCaseNodes(projectId, callback) { export function getTestCaseNodesByCaseFilter(projectId, param, callback) {
return baseGet('/case/node/list/' + projectId, callback); return basePost('/case/node/list/' + projectId, param, callback);
}
export function getTestPlanCaseNodesByCaseFilter(planId, param, callback) {
return basePost('/case/node/list/plan/' + planId, param, callback);
}
export function getTestReviewCaseNodesByCaseFilter(reviewId, param, callback) {
return basePost('/case/node/list/review/' + reviewId, param, callback);
}
export function getTestCasePublicNodes(param, callback) {
return basePost('/test/case/public/case/node', param, callback);
} }
export function getRelationshipCase(id, relationshipType, callback) { export function getRelationshipCase(id, relationshipType, callback) {