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"
@refreshAll="refreshAll"
@setCondition="setCondition"
@decrease="decrease"
:custom-num="custom_num"
ref="testCaseList">
</test-case-list>
@ -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;

View File

@ -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() {

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) {
const newChild = {
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) {
param.projectId = this.projectId;
this.$post("/case/node/edit", param, () => {