diff --git a/frontend/src/business/components/track/case/TestCase.vue b/frontend/src/business/components/track/case/TestCase.vue index bdcb1ea2bb..77ad6ae0da 100644 --- a/frontend/src/business/components/track/case/TestCase.vue +++ b/frontend/src/business/components/track/case/TestCase.vue @@ -38,6 +38,7 @@ @refresh="refresh" @refreshAll="refreshAll" @setCondition="setCondition" + @decrease="decrease" :custom-num="custom_num" ref="testCaseList"> @@ -310,6 +311,12 @@ export default { this.$refs.nodeTree.list(); this.setTable(data); }, + increase(id) { + this.$refs.nodeTree.increase(id); + }, + decrease(id) { + this.$refs.nodeTree.decrease(id); + }, editTestCase(testCase) { this.type = "edit"; this.testCaseReadOnly = false; diff --git a/frontend/src/business/components/track/case/components/TestCaseList.vue b/frontend/src/business/components/track/case/components/TestCaseList.vue index e3f2a7b1b0..b0f2713582 100644 --- a/frontend/src/business/components/track/case/components/TestCaseList.vue +++ b/frontend/src/business/components/track/case/components/TestCaseList.vue @@ -522,9 +522,9 @@ export default { _handleDelete(testCase) { let testCaseId = testCase.id; this.$post('/test/case/delete/' + testCaseId, {}, () => { - this.$emit('refreshTable'); this.initTableData(); this.$success(this.$t('commons.delete_success')); + this.$emit('decrease', testCase.nodeId); }); }, refresh() { diff --git a/frontend/src/business/components/track/common/NodeTree.vue b/frontend/src/business/components/track/common/NodeTree.vue index 53c884b429..16a6278220 100644 --- a/frontend/src/business/components/track/common/NodeTree.vue +++ b/frontend/src/business/components/track/common/NodeTree.vue @@ -205,6 +205,42 @@ export default { } }); }, + increase(id) { + this.traverse(id, node => { + if (node.caseNum) { + node.caseNum++; + } + }); + }, + decrease(id) { + this.traverse(id, node => { + if (node.caseNum) { + node.caseNum--; + } + }); + }, + traverse(id, callback) { + for (let i = 0; i < this.treeNodes.length; i++) { + let rootNode = this.treeNodes[i]; + this._traverse(rootNode, id, callback); + } + }, + _traverse(rootNode, id, callback) { + if (rootNode.id === id) { + if (callback) { + callback(rootNode); + } + return true; + } + if (!rootNode.children) {return false;} + for (let i = 0; i < rootNode.children.length; i++) { + let children = rootNode.children[i]; + let result = this._traverse(children); + if (result === true) { + return result; + } + } + }, append(node, data) { const newChild = { id: undefined, diff --git a/frontend/src/business/components/track/common/TestCaseNodeTree.vue b/frontend/src/business/components/track/common/TestCaseNodeTree.vue index 09155999fa..6e1f449c7e 100644 --- a/frontend/src/business/components/track/common/TestCaseNodeTree.vue +++ b/frontend/src/business/components/track/common/TestCaseNodeTree.vue @@ -138,6 +138,12 @@ export default { }); } }, + increase(id) { + this.$refs.nodeTree.increase(id); + }, + decrease(id) { + this.$refs.nodeTree.decrease(id); + }, edit(param) { param.projectId = this.projectId; this.$post("/case/node/edit", param, () => {