From f9408cfffa0d5d57f5cb9eb4815ac0d5d556b605 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 22 Jul 2021 17:58:49 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BF=AE=E5=A4=8D=E5=A4=9A=E5=B1=82=E4=BA=8B?= =?UTF-8?q?=E7=89=A9=E8=B0=83=E8=AF=95=E9=97=AE=E9=A2=98=20#1005206=20--bu?= =?UTF-8?q?g=3D1005206=20--user=3D=E8=B5=B5=E5=8B=87=20=E3=80=90=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=87=AA=E5=8A=A8=E5=8C=96=E3=80=91=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E4=BA=8B...=20https://www.tapd.cn/55049933/s/1028173?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../automation/report/SysnApiReportDetail.vue | 50 +++++++------- .../automation/scenario/EditApiScenario.vue | 65 ++++++++++++------- .../scenario/component/ApiComponent.vue | 2 +- .../scenario/component/LoopController.vue | 2 +- 4 files changed, 71 insertions(+), 48 deletions(-) diff --git a/frontend/src/business/components/api/automation/report/SysnApiReportDetail.vue b/frontend/src/business/components/api/automation/report/SysnApiReportDetail.vue index af1448f423..8d9ac2ef10 100644 --- a/frontend/src/business/components/api/automation/report/SysnApiReportDetail.vue +++ b/frontend/src/business/components/api/automation/report/SysnApiReportDetail.vue @@ -245,6 +245,33 @@ export default { this.$success(this.$t('schedule.event_success')); }); }, + getTransaction(transRequests, startTime, endTime, resMap) { + transRequests.forEach(subItem => { + if (subItem.method === 'Request') { + this.getTransaction(subItem.subRequestResults, startTime, endTime, resMap); + } + this.reqTotal++; + let key = subItem.resourceId; + if (resMap.get(key)) { + if (resMap.get(key).indexOf(subItem) === -1) { + resMap.get(key).push(subItem); + } + } else { + resMap.set(key, [subItem]); + } + if (subItem.success) { + this.reqSuccess++; + } else { + this.reqError++; + } + if (subItem.startTime && Number(subItem.startTime) < startTime) { + startTime = subItem.startTime; + } + if (subItem.endTime && Number(subItem.endTime) > endTime) { + endTime = subItem.endTime; + } + }) + }, formatResult(res) { let resMap = new Map; let startTime = 99991611737506593; @@ -259,28 +286,7 @@ export default { item.requestResults.forEach(req => { req.responseResult.console = res.console; if (req.method === 'Request') { - req.subRequestResults.forEach(subItem => { - this.reqTotal++; - let key = subItem.resourceId; - if (resMap.get(key)) { - if (resMap.get(key).indexOf(subItem) === -1) { - resMap.get(key).push(subItem); - } - } else { - resMap.set(key, [subItem]); - } - if (subItem.success) { - this.reqSuccess++; - } else { - this.reqError++; - } - if (subItem.startTime && Number(subItem.startTime) < startTime) { - startTime = subItem.startTime; - } - if (subItem.endTime && Number(subItem.endTime) > endTime) { - endTime = subItem.endTime; - } - }) + this.getTransaction(req.subRequestResults, startTime, endTime, resMap); } else { this.reqTotal++; let key = req.resourceId; diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index bd493c6095..63577755ad 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -452,7 +452,7 @@ export default { clearResult(arr) { if (arr) { arr.forEach(item => { - item.requestResult = undefined; + item.requestResult = []; item.result = undefined; item.code = undefined; if (item.hashTree && item.hashTree.length > 0) { @@ -524,6 +524,33 @@ export default { return; } }, + getTransaction(transRequests, startTime, endTime, resMap) { + transRequests.forEach(subItem => { + if (subItem.method === 'Request') { + this.getTransaction(subItem.subRequestResults, startTime, endTime, resMap); + } + this.reqTotal++; + let key = subItem.resourceId; + if (resMap.get(key)) { + if (resMap.get(key).indexOf(subItem) === -1) { + resMap.get(key).push(subItem); + } + } else { + resMap.set(key, [subItem]); + } + if (subItem.success) { + this.reqSuccess++; + } else { + this.reqError++; + } + if (subItem.startTime && Number(subItem.startTime) < startTime) { + startTime = subItem.startTime; + } + if (subItem.endTime && Number(subItem.endTime) > endTime) { + endTime = subItem.endTime; + } + }) + }, formatResult(res) { let resMap = new Map; let startTime = 99991611737506593; @@ -535,28 +562,7 @@ export default { item.requestResults.forEach(req => { req.responseResult.console = res.console; if (req.method === 'Request') { - req.subRequestResults.forEach(subItem => { - this.reqTotal++; - let key = subItem.resourceId; - if (resMap.get(key)) { - if (resMap.get(key).indexOf(subItem) === -1) { - resMap.get(key).push(subItem); - } - } else { - resMap.set(key, [subItem]); - } - if (subItem.success) { - this.reqSuccess++; - } else { - this.reqError++; - } - if (subItem.startTime && Number(subItem.startTime) < startTime) { - startTime = subItem.startTime; - } - if (subItem.endTime && Number(subItem.endTime) > endTime) { - endTime = subItem.endTime; - } - }) + this.getTransaction(req.subRequestResults, startTime, endTime, resMap); } else { this.reqTotal++; let key = req.resourceId; @@ -830,7 +836,7 @@ export default { request.active = false; request.resourceId = getUUID(); request.projectId = item.projectId; - request.requestResult = undefined; + request.requestResult = []; if (!request.url) { request.url = ""; } @@ -880,12 +886,23 @@ export default { } }); }, + copySetRes(hashTree) { + hashTree.forEach(item => { + item.resourceId = getUUID(); + if (item.hashTree && item.hashTree.length > 0) { + this.copySetRes(item.hashTree); + } + }) + }, copyRow(row, node) { const parent = node.parent const hashTree = parent.data.hashTree || parent.data; // 深度复制 let obj = JSON.parse(JSON.stringify(row)); obj.resourceId = getUUID(); + if (obj.hashTree && obj.hashTree.length > 0) { + this.copySetRes(obj.hashTree); + } if (obj.name) { obj.name = obj.name + '_copy'; } 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 19abf5b607..456ce20538 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue @@ -406,7 +406,7 @@ export default { enableCookieShare: this.enableCookieShare, environmentId: this.currentEnvironmentId, hashTree: [this.request], }; this.runData.push(debugData); - this.request.requestResult = undefined; + this.request.requestResult = []; this.request.result = undefined; /*触发执行操作*/ this.reportId = getUUID(); diff --git a/frontend/src/business/components/api/automation/scenario/component/LoopController.vue b/frontend/src/business/components/api/automation/scenario/component/LoopController.vue index 7d075fc711..1cb5fc6aa8 100644 --- a/frontend/src/business/components/api/automation/scenario/component/LoopController.vue +++ b/frontend/src/business/components/api/automation/scenario/component/LoopController.vue @@ -303,7 +303,7 @@ export default { item.result = this.requestResult; item.activeName = this.activeName; item.active = true; - item.requestResult = undefined; + item.requestResult = []; } if (item.hashTree && item.hashTree.length > 0) { this.setResult(item.hashTree);