fix: 选中模块后删除用例会显示全部用例 (#4348)

Co-authored-by: chenjianxing <jianxing.chen@fit2cloud.com>
This commit is contained in:
metersphere-bot 2021-07-02 15:57:20 +08:00 committed by GitHub
parent a33bdc39c5
commit a6cc91eca4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 1 deletions

View File

@ -38,6 +38,7 @@
@refresh="refresh" @refresh="refresh"
@refreshAll="refreshAll" @refreshAll="refreshAll"
@setCondition="setCondition" @setCondition="setCondition"
@decrease="decrease"
:custom-num="custom_num" :custom-num="custom_num"
ref="testCaseList"> ref="testCaseList">
</test-case-list> </test-case-list>
@ -310,6 +311,12 @@ export default {
this.$refs.nodeTree.list(); this.$refs.nodeTree.list();
this.setTable(data); this.setTable(data);
}, },
increase(id) {
this.$refs.nodeTree.increase(id);
},
decrease(id) {
this.$refs.nodeTree.decrease(id);
},
editTestCase(testCase) { editTestCase(testCase) {
this.type = "edit"; this.type = "edit";
this.testCaseReadOnly = false; this.testCaseReadOnly = false;

View File

@ -522,9 +522,9 @@ export default {
_handleDelete(testCase) { _handleDelete(testCase) {
let testCaseId = testCase.id; let testCaseId = testCase.id;
this.$post('/test/case/delete/' + testCaseId, {}, () => { this.$post('/test/case/delete/' + testCaseId, {}, () => {
this.$emit('refreshTable');
this.initTableData(); this.initTableData();
this.$success(this.$t('commons.delete_success')); this.$success(this.$t('commons.delete_success'));
this.$emit('decrease', testCase.nodeId);
}); });
}, },
refresh() { refresh() {

View File

@ -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) { append(node, data) {
const newChild = { const newChild = {
id: undefined, id: undefined,

View File

@ -138,6 +138,12 @@ export default {
}); });
} }
}, },
increase(id) {
this.$refs.nodeTree.increase(id);
},
decrease(id) {
this.$refs.nodeTree.decrease(id);
},
edit(param) { edit(param) {
param.projectId = this.projectId; param.projectId = this.projectId;
this.$post("/case/node/edit", param, () => { this.$post("/case/node/edit", param, () => {