refactor(测试跟踪): 脑图模块下没有用例也显示展开图标
--bug=1013126 --user=陈建星 【测试跟踪】脑图中 模块下没有用例 也显示+ https://www.tapd.cn/55049933/s/1157860
This commit is contained in:
parent
0f489ee9ec
commit
79787d1ddb
|
@ -149,4 +149,6 @@ public interface ExtTestCaseMapper {
|
|||
List<TestCase> getMaintainerMap(@Param("request") QueryTestCaseRequest request);
|
||||
|
||||
List<TestCaseDTO> getForNodeEdit(@Param("ids") List<String> ids);
|
||||
|
||||
List<Map<String, Object>> moduleExtraNodeCount(@Param("nodeIds") List<String> nodeIds);
|
||||
}
|
||||
|
|
|
@ -1007,4 +1007,13 @@
|
|||
SET test_case.latest = TRUE
|
||||
WHERE ref_id = #{refId,jdbcType=VARCHAR}
|
||||
</update>
|
||||
|
||||
<select id="moduleExtraNodeCount" resultType="java.util.Map">
|
||||
select parent_id as moduleId, count(id) as countNum from minder_extra_node
|
||||
where parent_id in
|
||||
<foreach collection="nodeIds" item="id" open="(" close=")" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
GROUP BY parent_id
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RequestMapping("/case/node")
|
||||
@RestController
|
||||
|
@ -30,6 +31,11 @@ public class TestCaseNodeController {
|
|||
return testCaseNodeService.getNodeTreeByProjectId(projectId);
|
||||
}
|
||||
|
||||
@PostMapping("/minder/extraNode/count")
|
||||
public Map<String, Integer> getMinderTreeExtraNodeCount(@RequestBody List<String> nodeIds) {
|
||||
return testCaseNodeService.getMinderTreeExtraNodeCount(nodeIds);
|
||||
}
|
||||
|
||||
@GetMapping("/trashCount/{projectId}")
|
||||
public long trashCount(@PathVariable String projectId) {
|
||||
checkPermissionService.checkProjectOwner(projectId);
|
||||
|
|
|
@ -740,4 +740,17 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
|
|||
|
||||
return extTestCaseMapper.countByWorkSpaceId(workSpaceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计某些节点下的临时节点的数量
|
||||
* @param nodeIds
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Integer> getMinderTreeExtraNodeCount(List<String> nodeIds) {
|
||||
if (nodeIds.isEmpty()) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
List<Map<String, Object>> moduleCountList = extTestCaseMapper.moduleExtraNodeCount(nodeIds);
|
||||
return this.parseModuleCountList(moduleCountList);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<div>
|
||||
<div class="minder" :class="{'full-screen': isFullScreen}">
|
||||
<div v-loading="loading" class="minder" :class="{'full-screen': isFullScreen}">
|
||||
<ms-full-screen-button :is-full-screen.sync="isFullScreen"/>
|
||||
<minder-editor
|
||||
v-if="isActive"
|
||||
|
@ -81,6 +81,9 @@ export default {
|
|||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
getExtraNodeCount: {
|
||||
type: Function
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
@ -104,6 +107,7 @@ export default {
|
|||
isFullScreen: false,
|
||||
height: '',
|
||||
defaultMode: 3,
|
||||
loading: false,
|
||||
tmpNode: {}
|
||||
}
|
||||
},
|
||||
|
@ -124,10 +128,31 @@ export default {
|
|||
} else {
|
||||
this.parse(this.importJson.root, this.treeNodes);
|
||||
}
|
||||
this.reload();
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
getNoCaseModuleIds(ids, nodes) {
|
||||
if (nodes) {
|
||||
nodes.forEach(node => {
|
||||
if (node.caseNum < 1) {
|
||||
ids.push(node.id);
|
||||
}
|
||||
if (node.children) {
|
||||
this.getNoCaseModuleIds(ids, node.children);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
setExtraNodeCount(countMap, nodes) {
|
||||
nodes.forEach(node => {
|
||||
if (countMap[node.id]) {
|
||||
node.extraNodeCount = countMap[node.id];
|
||||
}
|
||||
if (node.children) {
|
||||
this.setExtraNodeCount(countMap, node.children);
|
||||
}
|
||||
});
|
||||
},
|
||||
handleMoldChange(index) {
|
||||
if (this.minderKey) {
|
||||
localStorage.setItem(this.minderKey + 'minderModel', index);
|
||||
|
@ -137,7 +162,32 @@ export default {
|
|||
save(data) {
|
||||
this.$emit('save', data)
|
||||
},
|
||||
parse(root, children) {
|
||||
parse(root, nodes) {
|
||||
this.loading = true;
|
||||
if (this.getExtraNodeCount) {
|
||||
// 如果有临时节点,筛选出用例数为空的模块,
|
||||
// 去查找下这些模块下的临时节点数量,来判断模块是不是要有展开图标
|
||||
let noCaseModuleIds = [];
|
||||
this.getNoCaseModuleIds(noCaseModuleIds, nodes);
|
||||
if (noCaseModuleIds.length < 1) {
|
||||
this._parse(root, nodes);
|
||||
this.loading = false;
|
||||
this.reload();
|
||||
} else {
|
||||
this.getExtraNodeCount(noCaseModuleIds, (data) => {
|
||||
this.setExtraNodeCount(data, nodes);
|
||||
this._parse(root, nodes);
|
||||
this.loading = false;
|
||||
this.reload();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this._parse(root, nodes);
|
||||
this.loading = false;
|
||||
this.reload();
|
||||
}
|
||||
},
|
||||
_parse(root, children) {
|
||||
root.children = [];
|
||||
if (!children) {
|
||||
children = [];
|
||||
|
@ -145,7 +195,14 @@ export default {
|
|||
if (root.data.text === '未规划用例' && root.data.level === 1) {
|
||||
root.data.disable = true;
|
||||
}
|
||||
if (children.length < 1) {
|
||||
let caseNum = root.data.caseNum;
|
||||
let hasChildren = caseNum && caseNum > 0;
|
||||
if (this.getExtraNodeCount) {
|
||||
// 如果有临时节点的脑图,就判断下临时节点数量
|
||||
let extraNodeCount = root.data.extraNodeCount;
|
||||
hasChildren = hasChildren || (extraNodeCount && extraNodeCount > 0);
|
||||
}
|
||||
if (children.length < 1 && (this.ignoreNum || hasChildren)) {
|
||||
root.children.push({
|
||||
data: {
|
||||
text: '',
|
||||
|
@ -169,6 +226,7 @@ export default {
|
|||
level: item.level,
|
||||
resource: this.showModuleTag ? [this.$t('test_track.module.module')] : [],
|
||||
caseNum: item.caseNum,
|
||||
extraNodeCount: item.extraNodeCount,
|
||||
path: root.data.path + "/" + item.name,
|
||||
expandState:"collapse"
|
||||
},
|
||||
|
@ -177,7 +235,7 @@ export default {
|
|||
node.data.tagEnable = this.tagEnable;
|
||||
}
|
||||
root.children.push(node);
|
||||
this.parse(node, item.children);
|
||||
this._parse(node, item.children);
|
||||
});
|
||||
},
|
||||
reload() {
|
||||
|
@ -210,9 +268,8 @@ export default {
|
|||
if (node && node.data) {
|
||||
let nodeData = node.data;
|
||||
let importJson = this.getImportJsonBySelectNode(nodeData);
|
||||
this.parse(importJson.root, nodeData.children);
|
||||
this.setJsonImport(importJson);
|
||||
this.reload();
|
||||
this.parse(importJson.root, nodeData.children);
|
||||
}
|
||||
},
|
||||
getImportJsonBySelectNode(nodeData) {
|
||||
|
|
|
@ -2,18 +2,19 @@
|
|||
<div>
|
||||
<ms-module-minder
|
||||
v-loading="result.loading"
|
||||
minder-key="TEST_CASE"
|
||||
:tree-nodes="treeNodes"
|
||||
:tags="tags"
|
||||
minder-key="testCase"
|
||||
:select-node="selectNode"
|
||||
:distinct-tags="tags"
|
||||
:module-disable="false"
|
||||
:show-module-tag="true"
|
||||
:move-enable="moveEnable"
|
||||
:tag-edit-check="tagEditCheck()"
|
||||
@afterMount="handleAfterMount"
|
||||
:priority-disable-check="priorityDisableCheck()"
|
||||
:disabled="disabled"
|
||||
:get-extra-node-count="getMinderTreeExtraNodeCount()"
|
||||
@afterMount="handleAfterMount"
|
||||
@save="save"
|
||||
ref="minder"
|
||||
/>
|
||||
|
@ -54,7 +55,7 @@ import {
|
|||
tagEditCheck,
|
||||
} from "@/business/components/track/common/minder/minderUtils";
|
||||
import {getNodePath, getUUID, hasPermission} from "@/common/js/utils";
|
||||
import {getTestCasesForMinder, getMinderExtraNode} from "@/network/testCase";
|
||||
import {getTestCasesForMinder, getMinderExtraNode, getMinderTreeExtraNodeCount} from "@/network/testCase";
|
||||
import {addIssueHotBox, getSelectedNodeData, handleIssueAdd, handleIssueBatch} from "./minderUtils";
|
||||
import IssueRelateList from "@/business/components/track/case/components/IssueRelateList";
|
||||
import TestPlanIssueEdit from "@/business/components/track/case/components/TestPlanIssueEdit";
|
||||
|
@ -131,6 +132,9 @@ name: "TestCaseMinder",
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
getMinderTreeExtraNodeCount() {
|
||||
return getMinderTreeExtraNodeCount;
|
||||
},
|
||||
handleAfterMount() {
|
||||
listenNodeSelected(() => {
|
||||
// 点击模块,加载模块下的用例
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
<div>
|
||||
<ms-module-minder
|
||||
v-loading="result.loading"
|
||||
minder-key="PLAN_CASE"
|
||||
:tree-nodes="treeNodes"
|
||||
:data-map="dataMap"
|
||||
:tags="tags"
|
||||
:tag-enable="true"
|
||||
minder-key="testPlan"
|
||||
:disabled=disableMinder
|
||||
:disabled="disableMinder"
|
||||
:select-node="selectNode"
|
||||
:distinct-tags="[...tags, this.$t('test_track.plan.plan_status_prepare')]"
|
||||
:ignore-num="true"
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
:data-map="dataMap"
|
||||
:tags="tags"
|
||||
:tag-enable="true"
|
||||
minder-key="testReview"
|
||||
minder-key="REVIEW_CASE"
|
||||
:select-node="selectNode"
|
||||
:distinct-tags="[...tags, $t('test_track.plan.plan_status_prepare')]"
|
||||
:ignore-num="true"
|
||||
|
|
|
@ -86,7 +86,9 @@ export function loadSelectNodes(param, getCaseFuc, setParamCallback, getExtraNod
|
|||
let minder = window.minder;
|
||||
let selectNodes = minder.getSelectedNodes();
|
||||
selectNodes.forEach(node => {
|
||||
loadNode(node, param, getCaseFuc, setParamCallback, getExtraNodeFuc);
|
||||
if (node.children && node.children.length > 0) {
|
||||
loadNode(node, param, getCaseFuc, setParamCallback, getExtraNodeFuc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -82,3 +82,7 @@ export function getTestPlanTestCase(pageNum, pageSize, param, callback) {
|
|||
export function getTestReviewTestCase(pageNum, pageSize, param, callback) {
|
||||
return basePost('/test/review/case/list/' + pageNum + '/' + pageSize, param, callback);
|
||||
}
|
||||
|
||||
export function getMinderTreeExtraNodeCount(param, callback) {
|
||||
return basePost('/case/node/minder/extraNode/count', param, callback);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue