From 7a3d86dc266a6a9858f2c693f8b6855b3e3ee0e1 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Fri, 18 Mar 2022 14:54:47 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E5=BC=95=E7=94=A8=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E7=9A=84=E6=89=B9=E9=87=8F=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../automation/scenario/EditApiScenario.vue | 62 ++++++++++--------- .../scenario/component/ApiComponent.vue | 8 --- .../scenario/component/ComponentConfig.vue | 2 - .../scenario/component/PluginComponent.vue | 8 ++- 4 files changed, 37 insertions(+), 43 deletions(-) diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 1aa6ed77c7..88bfeeccbe 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -161,15 +161,12 @@
@@ -191,7 +188,6 @@ :scenario="data" :response="response" :currentScenario="currentScenario" - :expandedNode="expandedNode" :currentEnvironmentId="currentEnvironmentId" :node="node" :project-list="projectList" @@ -455,7 +451,6 @@ export default { operatingElements: [], selectedTreeNode: undefined, selectedNode: undefined, - expandedNode: [], scenarioDefinition: [], path: "/api/automation/create", repositoryCreatePath: "/repository/api/automation/create", @@ -589,30 +584,35 @@ export default { }, checkedAll(v) { if (this.$refs.stepTree && this.$refs.stepTree.root && this.$refs.stepTree.root.childNodes) { - this.stepCheckedAll(v, this.$refs.stepTree.root.childNodes); + this.recursionChecked(v, this.$refs.stepTree.root.childNodes); } }, - stepCheckedAll(v, array) { + recursionChecked(v, array) { if (array) { array.forEach(item => { if (item.childNodes && item.childNodes.length > 0) { - this.stepCheckedAll(v, item.childNodes); + this.recursionChecked(v, item.childNodes); } item.checked = v; + if (item.data && item.data.type === 'scenario' && item.data.referenced === 'REF') { + item.expanded = false; + } }) } }, batchProcessing() { this.isBatchProcess = true; - this.expandedNode = []; this.hideAllTreeNode(this.scenarioDefinition); + if (this.$refs.stepTree && this.$refs.stepTree.root && this.$refs.stepTree.root.childNodes) { + this.recursionExpansion([], this.$refs.stepTree.root.childNodes); + } this.reloadTreeStatus(); }, cancelBatchProcessing() { this.isBatchProcess = false; this.isCheckedAll = false; if (this.$refs.stepTree && this.$refs.stepTree.root && this.$refs.stepTree.root.childNodes) { - this.stepCheckedAll(false, this.$refs.stepTree.root.childNodes); + this.recursionChecked(false, this.$refs.stepTree.root.childNodes); } this.selectDataCounts = 0; this.commandTreeNode(); @@ -641,12 +641,12 @@ export default { }, hideAllTreeNode(array) { array.forEach(item => { - if (item.hashTree && item.hashTree.length > 0) { - this.hideAllTreeNode(item.hashTree); - } item.isLeaf = this.isBatchProcess; item.isBatchProcess = this.isBatchProcess; item.checkBox = this.isBatchProcess; + if (item.hashTree && item.hashTree.length > 0) { + this.hideAllTreeNode(item.hashTree); + } }) }, commandTreeNode(node, array) { @@ -1452,16 +1452,6 @@ export default { this.forceRerender(); } }, - nodeExpand(data, node) { - if (data && data.resourceId && this.expandedNode.indexOf(data.resourceId) === -1) { - this.expandedNode.push(data.resourceId); - } - }, - nodeCollapse(data, node) { - if (data && data.resourceId) { - this.expandedNode.splice(this.expandedNode.indexOf(data.resourceId), 1); - } - }, editScenario() { if (!document.getElementById("inputDelay")) { return; @@ -1771,11 +1761,8 @@ export default { }, changeNodeStatus(resourceIds, nodes) { for (let i in nodes) { - if (nodes[i]) { + if (nodes[i] && !(nodes[i].type === 'scenario' && nodes[i].referenced === 'REF')) { if (resourceIds.indexOf(nodes[i].resourceId) !== -1) { - if (this.expandedStatus) { - this.expandedNode.push(nodes[i].resourceId); - } nodes[i].active = this.expandedStatus; if (this.stepSize > 35 && this.expandedStatus) { nodes[i].active = false; @@ -1797,18 +1784,33 @@ export default { } return selectValueArr; }, + recursionExpansion(resourceIds, array) { + if (array) { + array.forEach(item => { + if (item.data && item.data.type === 'scenario' && item.data.referenced === 'REF') { + item.expanded = false; + } else { + if (resourceIds.indexOf(item.data.resourceId) !== -1) { + item.expanded = this.expandedStatus; + } + } + if (item.childNodes && item.childNodes.length > 0) { + this.recursionExpansion(resourceIds, item.childNodes); + } + }) + } + }, openExpansion() { - this.expandedNode = []; this.expandedStatus = true; let resourceIds = this.getAllResourceIds(); this.changeNodeStatus(resourceIds, this.scenarioDefinition); + this.recursionExpansion(resourceIds, this.$refs.stepTree.root.childNodes); }, closeExpansion() { this.expandedStatus = false; - this.expandedNode = []; let resourceIds = this.getAllResourceIds(); this.changeNodeStatus(resourceIds, this.scenarioDefinition); - this.forceRerender(); + this.recursionExpansion(resourceIds, this.$refs.stepTree.root.childNodes); }, stepStatus(resourceIds, nodes) { for (let i in nodes) { diff --git a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue index ab7c968a78..197ec9f5b1 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue @@ -192,7 +192,6 @@ export default { }, currentEnvironmentId: String, projectList: Array, - expandedNode: Array, envMap: Map, message: String, environmentGroupId: String, @@ -608,13 +607,6 @@ export default { if (this.node) { this.node.expanded = this.request.active; } - if (this.node.expanded && this.expandedNode && this.expandedNode.indexOf(this.request.resourceId) === -1) { - this.expandedNode.push(this.request.resourceId); - } else { - if (this.expandedNode && this.expandedNode.indexOf(this.request.resourceId) !== -1) { - this.expandedNode.splice(this.expandedNode.indexOf(this.request.resourceId), 1); - } - } this.apiActive = this.request.active; this.reload(); }, diff --git a/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue b/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue index a108b8b571..980f748b0c 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ComponentConfig.vue @@ -5,7 +5,6 @@ :isMax="isMax" :show-btn="showBtn" :show-version="showVersion" - :expandedNode="expandedNode" :scenario="scenario" :controller="scenario" :timer="scenario" @@ -90,7 +89,6 @@ export default { default: true, }, currentScenario: {}, - expandedNode: Array, currentEnvironmentId: String, response: {}, node: {}, diff --git a/frontend/src/business/components/api/automation/scenario/component/PluginComponent.vue b/frontend/src/business/components/api/automation/scenario/component/PluginComponent.vue index ac46cbd7a9..0ee4e94df1 100644 --- a/frontend/src/business/components/api/automation/scenario/component/PluginComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/PluginComponent.vue @@ -280,10 +280,10 @@ export default { change(fileName) { }, changeDisplay(fileName) { - if (fileName === 'number of received messages') { + if (fileName === 'number of received messages' && this.pluginForm && this.pluginForm.hidden instanceof Function) { this.pluginForm.hidden(true, "conditionTime"); } - if (fileName === 'specified elapsed time (ms)') { + if (fileName === 'specified elapsed time (ms)' && this.pluginForm && this.pluginForm.hidden instanceof Function) { this.pluginForm.hidden(false, "conditionTime"); } }, @@ -382,7 +382,9 @@ export default { this.pluginForm.setValue(this.request); } if (this.request.condition) { - this.changeDisplay(this.request.condition); + this.$nextTick(() => { + this.changeDisplay(this.request.condition); + }); } } else { this.request.enable = false;