fix(测试跟踪): 公共用例库左侧添加模块树

--bug=1012715 --user=李玉号 【测试跟踪】公共用例库页面优化-左侧有模块数
https://www.tapd.cn/55049933/s/1172004
This commit is contained in:
shiziyuan9527 2022-06-01 19:10:52 +08:00 committed by fit2-zhao
parent 5983a60e1d
commit 5b2f64b722
6 changed files with 81 additions and 7 deletions

View File

@ -524,6 +524,9 @@
<if test="request.notEqStatus != null">
and (test_case.status is null or test_case.status != #{request.notEqStatus})
</if>
<if test="request.casePublic != null and request.casePublic == true">
and test_case.case_public = true
</if>
<if test="request.name != null">
and (test_case.name like CONCAT('%', #{request.name},'%')
or test_case.num like CONCAT('%', #{request.name},'%')

View File

@ -28,6 +28,7 @@ import io.metersphere.notice.annotation.SendNotice;
import io.metersphere.service.CheckPermissionService;
import io.metersphere.service.FileService;
import io.metersphere.track.dto.TestCaseDTO;
import io.metersphere.track.dto.TestCaseNodeDTO;
import io.metersphere.track.request.testcase.*;
import io.metersphere.track.request.testplan.FileOperationRequest;
import io.metersphere.track.request.testplan.LoadCaseRequest;
@ -73,6 +74,12 @@ public class TestCaseController {
return PageUtils.setPageInfo(page, testCaseService.publicListTestCase(request));
}
@PostMapping("/public/case/node")
public List<TestCaseNodeDTO> getPublicCaseNode(@RequestBody QueryTestCaseRequest request) {
return testCaseService.getPublicCaseNode(request);
}
@GetMapping("/list/{projectId}")
@RequiresPermissions("PROJECT_TRACK_CASE:READ")
public List<TestCaseDTO> list(@PathVariable String projectId) {

View File

@ -143,10 +143,14 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
}
}
public List<TestCaseNodeDTO> getNodeTreeByProjectId(String projectId) {
QueryTestCaseRequest request = new QueryTestCaseRequest();
return getNodeTreeByProjectId(projectId, request);
}
public List<TestCaseNodeDTO> getNodeTreeByProjectId(String projectId, QueryTestCaseRequest request) {
// 判断当前项目下是否有默认模块没有添加默认模块
this.getDefaultNode(projectId);
List<TestCaseNodeDTO> testCaseNodes = extTestCaseNodeMapper.getNodeTreeByProjectId(projectId);
QueryTestCaseRequest request = new QueryTestCaseRequest();
request.setUserId(SessionUtils.getUserId());
request.setProjectId(projectId);
@ -305,6 +309,25 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
return getNodeTreeWithPruningTree(projectNodeMap);
}
public List<TestCaseNodeDTO> getNodeByTestCases(List<TestCaseDTO> testCaseDTOS) {
Map<String, List<String>> projectNodeMap = new HashMap<>();
for (TestCase testCase : testCaseDTOS) {
List<String> nodeIds = Optional.ofNullable(projectNodeMap.get(testCase.getProjectId())).orElse(new ArrayList<>());
nodeIds.add(testCase.getNodeId());
projectNodeMap.put(testCase.getProjectId(), nodeIds);
}
List<TestCaseNodeDTO> tree = getNodeTreeWithPruningTree(projectNodeMap);
QueryTestCaseRequest request = new QueryTestCaseRequest();
request.setCasePublic(true);
for (TestCaseNodeDTO dto : tree) {
List<TestCaseNodeDTO> children = this.getNodeTreeByProjectId(dto.getId(), request);
dto.setChildren(children);
int sum = children.stream().mapToInt(TestCaseNodeDTO::getCaseNum).sum();
dto.setCaseNum(sum);
}
return tree;
}
public List<TestCaseNodeDTO> getNodeByReviewId(String reviewId) {
List<TestCase> testCases = extTestCaseReviewTestCaseMapper.getTestCaseWithNodeInfo(reviewId);
Map<String, List<String>> projectNodeMap = getProjectNodeMap(testCases);

View File

@ -45,6 +45,7 @@ import io.metersphere.performance.service.PerformanceTestService;
import io.metersphere.service.*;
import io.metersphere.track.dto.TestCaseCommentDTO;
import io.metersphere.track.dto.TestCaseDTO;
import io.metersphere.track.dto.TestCaseNodeDTO;
import io.metersphere.track.issue.AbstractIssuePlatform;
import io.metersphere.track.issue.IssueFactory;
import io.metersphere.track.issue.service.XpackIssueService;
@ -2673,4 +2674,9 @@ public class TestCaseService {
}
return false;
}
public List<TestCaseNodeDTO> getPublicCaseNode(QueryTestCaseRequest request) {
List<TestCaseDTO> testCaseDTOS = publicListTestCase(request);
return testCaseNodeService.getNodeByTestCases(testCaseDTOS);
}
}

View File

@ -21,6 +21,15 @@
/>
</ms-aside-container>
<ms-aside-container v-if="showPublicNode">
<node-tree class="node-tree"
:is-display="'public'"
v-loading="result.loading"
@nodeSelectEvent="publicNodeChange"
:tree-nodes="publicTreeNodes"
ref="publicNodeTree"/>
</ms-aside-container>
<ms-main-container>
<el-tabs v-model="activeName" @tab-click="addTab" @tab-remove="closeConfirm">
<el-tab-pane name="trash" v-if="trashEnable" :label="$t('commons.trash')">
@ -66,6 +75,7 @@
@getPublicList="getPublicList"
@refresh="refresh"
@refreshAll="refreshAll"
@refreshPublic="refreshPublic"
@setCondition="setCondition"
ref="testCasePublicList">
</test-case-list>
@ -253,6 +263,8 @@ export default {
currentTrashVersion: null,
versionEnable: false,
isAsideHidden: true,
showPublicNode: false,
publicTreeNodes: []
};
},
mounted() {
@ -286,6 +298,7 @@ export default {
},
activeName(newVal, oldVal) {
this.isAsideHidden = this.activeName === 'default';
this.showPublicNode = this.activeName === 'public';
if (oldVal !== 'default' && newVal === 'default' && this.$refs.minder) {
this.$refs.minder.refresh();
}
@ -307,6 +320,9 @@ export default {
publicEnable() {
if (this.publicEnable) {
this.activeName = 'public';
this.result = this.$post('/test/case/public/case/node', {workspaceId: getCurrentWorkspaceId()}, res => {
this.publicTreeNodes = res.data;
})
} else {
this.activeName = 'default';
}
@ -561,6 +577,13 @@ export default {
this.publicEnable = false;
this.activeName = "default";
},
publicNodeChange(node, nodeIds, pNodes) {
this.activeName = 'public';
this.publicEnable = true;
if (this.$refs.testCasePublicList) {
this.$refs.testCasePublicList.initTableData(nodeIds);
}
},
increase(id) {
this.$refs.nodeTree.increase(id);
},
@ -658,6 +681,14 @@ export default {
this.$refs.nodeTree.list();
this.setTable(data);
},
refreshPublic() {
if (this.$refs.testCasePublicList) {
this.$refs.testCasePublicList.initTableData([]);
}
this.result = this.$post('/test/case/public/case/node', {workspaceId: getCurrentWorkspaceId()}, res => {
this.publicTreeNodes = res.data;
})
},
setTreeNodes(data) {
this.treeNodes = data;
},

View File

@ -708,7 +708,7 @@ export default {
let dataType = this.$route.params.dataType;
this.selectDataRange = dataType === 'case' ? dataRange : 'all';
},
initTableData() {
initTableData(nodeIds) {
this.condition.planId = "";
this.condition.nodeIds = [];
initCondition(this.condition, this.condition.selectAll);
@ -728,6 +728,11 @@ export default {
}
}
}
if (nodeIds && nodeIds.length > 0) {
this.condition.nodeIds = nodeIds;
this.condition.workspaceId = getCurrentWorkspaceId();
}
this.getData();
},
open() {
@ -1101,7 +1106,7 @@ export default {
let param = buildBatchParam(this, this.$refs.table.selectIds);
this.$post('/test/case/batch/movePublic/deleteToGc', param, () => {
this.$refs.table.clear();
this.$emit("refresh");
this.$emit("refreshPublic");
this.$success(this.$t('commons.delete_success'));
});
}
@ -1123,7 +1128,7 @@ export default {
this.$get('/test/case/deletePublic/' + testCase.versionId + '/' + testCase.refId, () => {
this.$success(this.$t('commons.delete_success'));
this.$refs.apiDeleteConfirm.close();
this.$emit("refreshAll");
this.$emit("refreshPublic");
});
} else {
this.$get('/test/case/delete/' + testCase.versionId + '/' + testCase.refId, () => {
@ -1137,12 +1142,11 @@ export default {
else {
if (this.publicEnable) {
let param = buildBatchParam(this, this.$refs.table.selectIds);
param.ids.push(testCase.id);
this.$post('/test/case/batch/movePublic/deleteToGc', param, () => {
this.$success(this.$t('commons.delete_success'));
// this.initTable();
this.$refs.apiDeleteConfirm.close();
this.$emit("refreshAll");
this.$emit("refreshPublic");
});
} else {
this._handleDeleteToGc(testCase);