From 22c9caa199ab5630ba666e23ae92effadfe61a1a Mon Sep 17 00:00:00 2001 From: "nathan.liu" Date: Thu, 16 Jun 2022 10:39:28 +0800 Subject: [PATCH] =?UTF-8?q?fix(UI=E8=87=AA=E5=8A=A8=E5=8C=96):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8DUI=E6=8A=A5=E5=91=8A=E6=B5=81=E7=A8=8B=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E4=B8=AD=E6=AD=A5=E9=AA=A4=E9=A1=BA=E5=BA=8F=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1014053 --user=刘瑶 【UI测试】UI报告,循环里套循环的时候,报告显示顺序不是循环的顺序 https://www.tapd.cn/55049933/s/1183453 --- .../api/automation/report/ApiReportDetail.vue | 61 ++++++++++++++++--- frontend/src/business/components/xpack | 2 +- 2 files changed, 53 insertions(+), 10 deletions(-) diff --git a/frontend/src/business/components/api/automation/report/ApiReportDetail.vue b/frontend/src/business/components/api/automation/report/ApiReportDetail.vue index 946fd60692..e23241dc5b 100644 --- a/frontend/src/business/components/api/automation/report/ApiReportDetail.vue +++ b/frontend/src/business/components/api/automation/report/ApiReportDetail.vue @@ -456,8 +456,12 @@ if(data.reportType === "UI_INDEPENDENT"){ this.tempResult = report.steps; //校对执行次序 - this.checkOrder(this.tempResult); - this.fullTreeNodes = this.tempResult; + try{ + this.checkOrder(this.tempResult); + this.fullTreeNodes = this.tempResult; + }catch(e){ + this.fullTreeNodes = report.steps; + } }else{ this.fullTreeNodes = report.steps; } @@ -485,19 +489,58 @@ if(!origin){ return; } - if(origin.children && Array.isArray(origin.children)){ - origin.children.sort((m,n)=>{ - let mTime = m.value ? m.value.startTime ? m.value.startTime : 0 : 0; - let nTime = n.value ? n.value.startTime ? n.value.startTime : 0 : 0; - return mTime <= nTime; - }) - origin.children.forEach(v => { + if(Array.isArray(origin)){ + this.sortChildren(origin); + origin.forEach(v => { if(v.children){ this.checkOrder(v.children) } }) } }, + sortChildren(source){ + if(!source){ + return; + } + source.forEach( item =>{ + let children = item.children; + if(children && children.length > 0){ + let tempArr = new Array(children.length); + let tempMap = new Map(); + + for(let i = 0; i < children.length; i++){ + if(!children[i].value || !children[i].value.startTime || children[i].value.startTime === 0){ + //若没有value或未执行的,则step留在当前位置 + tempArr[i] = children[i]; + //进行标识 + tempMap.set(children[i].stepId, children[i]) + } + } + + //过滤出还没有指定好位置的step + let arr = children.filter(m => { + return !tempMap.get(m.stepId); + }).sort((m, n) => { + //按时间排序 + return m.value.startTime - n.value.startTime; + }); + + //找出arr(已经有序,从头取即可)中时间最小的插入 tempArr 可用位置 + for(let j = 0, i = 0; j < tempArr.length; j++){ + if(!tempArr[j]){ + //占位 + tempArr[j] = arr[i]; + i++; + } + //重新排序 + tempArr[j].index = j + 1; + } + + //赋值 + item.children = tempArr; + } + }) + }, buildReport() { if (this.report) { if (this.isNotRunning) { diff --git a/frontend/src/business/components/xpack b/frontend/src/business/components/xpack index b946a7eef6..b6a9ea1cac 160000 --- a/frontend/src/business/components/xpack +++ b/frontend/src/business/components/xpack @@ -1 +1 @@ -Subproject commit b946a7eef6e682b10ae8b49445e398c28aa50cb2 +Subproject commit b6a9ea1cac4be67f8fc64cc75b9994827f381e09