refactor(接口自动化): 部分冗余代码优化

This commit is contained in:
fit2-zhao 2021-07-28 14:45:57 +08:00 committed by fit2-zhao
parent 861ddfec53
commit 92db1a084b
1 changed files with 6 additions and 32 deletions

View File

@ -803,6 +803,7 @@ export default {
if (!item.hashTree) { if (!item.hashTree) {
item.hashTree = []; item.hashTree = [];
} }
this.resetResourceId(item.hashTree);
item.enable === undefined ? item.enable = true : item.enable; item.enable === undefined ? item.enable = true : item.enable;
if (this.selectedTreeNode !== undefined) { if (this.selectedTreeNode !== undefined) {
this.selectedTreeNode.hashTree.push(item); this.selectedTreeNode.hashTree.push(item);
@ -1234,29 +1235,13 @@ export default {
this.envResult.loading = false; this.envResult.loading = false;
}) })
}, },
shrinkTreeNode() {
//
for (let i in this.scenarioDefinition) {
if (this.scenarioDefinition[i]) {
if (this.expandedStatus && this.expandedNode.indexOf(this.scenarioDefinition[i].resourceId) === -1) {
this.expandedNode.push(this.scenarioDefinition[i].resourceId);
}
if (this.stepSize < 35) {
this.scenarioDefinition[i].active = this.expandedStatus;
}
if (this.scenarioDefinition[i].hashTree && this.scenarioDefinition[i].hashTree.length > 0) {
this.changeNodeStatus(this.scenarioDefinition[i].hashTree);
}
}
}
},
changeNodeStatus(nodes) { changeNodeStatus(nodes) {
for (let i in nodes) { for (let i in nodes) {
if (nodes[i]) { if (nodes[i]) {
if (this.expandedStatus) { if (this.expandedStatus) {
this.expandedNode.push(nodes[i].resourceId); this.expandedNode.push(nodes[i].resourceId);
} }
if (this.stepSize < 35) { if (this.stepSize < 35 || !this.expandedStatus) {
nodes[i].active = this.expandedStatus; nodes[i].active = this.expandedStatus;
} }
if (nodes[i].hashTree != undefined && nodes[i].hashTree.length > 0) { if (nodes[i].hashTree != undefined && nodes[i].hashTree.length > 0) {
@ -1268,25 +1253,14 @@ export default {
openExpansion() { openExpansion() {
this.expandedNode = []; this.expandedNode = [];
this.expandedStatus = true; this.expandedStatus = true;
this.shrinkTreeNode(); this.changeNodeStatus(this.scenarioDefinition);
}, },
closeExpansion() { closeExpansion() {
this.expandedStatus = false; this.expandedStatus = false;
this.expandedNode = []; this.expandedNode = [];
this.shrinkTreeNode(); this.changeNodeStatus(this.scenarioDefinition);
this.reload(); this.reload();
}, },
stepNode() {
//
for (let i in this.scenarioDefinition) {
if (this.scenarioDefinition[i]) {
this.scenarioDefinition[i].enable = this.stepEnable;
if (this.scenarioDefinition[i].hashTree && this.scenarioDefinition[i].hashTree.length > 0) {
this.stepStatus(this.scenarioDefinition[i].hashTree);
}
}
}
},
stepStatus(nodes) { stepStatus(nodes) {
for (let i in nodes) { for (let i in nodes) {
if (nodes[i]) { if (nodes[i]) {
@ -1299,11 +1273,11 @@ export default {
}, },
enableAll() { enableAll() {
this.stepEnable = true; this.stepEnable = true;
this.stepNode(); this.stepStatus(this.scenarioDefinition);
}, },
disableAll() { disableAll() {
this.stepEnable = false; this.stepEnable = false;
this.stepNode(); this.stepStatus(this.scenarioDefinition);
}, },
handleScroll() { handleScroll() {
let stepInfo = this.$refs.stepInfo; let stepInfo = this.$refs.stepInfo;