From 083bcfb0778ab6ee8049183b1263a26b1868546c Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Fri, 17 Sep 2021 17:17:34 +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#1006462=20=20=E4=BD=BF=E7=94=A8=E4=B8=A4?= =?UTF-8?q?=E5=B1=82=E4=BA=8B=E5=8A=A1=E6=8E=A7=E5=88=B6=E5=99=A8=EF=BC=8C?= =?UTF-8?q?=E5=86=85=E5=B1=82=E4=BA=8B=E5=8A=A1=E6=8E=A7=E5=88=B6=E5=99=A8?= =?UTF-8?q?=E4=B8=8B=E5=A4=8D=E5=88=B6=E6=88=96=E5=BC=95=E7=94=A8=E7=9A=84?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E5=9C=A8=E6=8A=A5=E5=91=8A=E4=B8=AD=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B=E4=B8=8D=E4=BA=86=E5=85=B7=E4=BD=93=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【【github#6014】使用两层事务控制器,内层事务控制器下复制或引用的场景在报告中查看不了具体内容】https://www.tapd.cn/55049933/bugtrace/bugs/view?bug_id=1155049933001006462 --- .../api/automation/report/ApiReportDetail.vue | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/frontend/src/business/components/api/automation/report/ApiReportDetail.vue b/frontend/src/business/components/api/automation/report/ApiReportDetail.vue index 2b9ce97bac..928f587b43 100644 --- a/frontend/src/business/components/api/automation/report/ApiReportDetail.vue +++ b/frontend/src/business/components/api/automation/report/ApiReportDetail.vue @@ -157,10 +157,18 @@ export default { label: nodeArray[i], value: item, }; + if (i !== nodeArray.length) { node.children = []; } + if(item.subRequestResults && item.subRequestResults.length > 0){ + let itemChildren = this.deepFormatTreeNode(item.subRequestResults); + node.children = itemChildren; + if (node.label.indexOf("UUID=")) { + node.label = node.label.split("UUID=")[0]; + } + } if (children.length === 0) { children.push(node); } @@ -215,6 +223,95 @@ export default { } }) }, + + deepFormatTreeNode(array) { + let children = []; + array.map((item) => { + let key = item.name; + let nodeArray = key.split('^@~@^'); + //运行场景中如果连续将1个场景引入多次,会出现运行结果合并的情况。 + //为了解决这种问题,在转hashTree的时候给场景放了个新ID,前台加载解析的时候也要做处理 + let scenarioId = ""; + let scenarioName = ""; + if (item.scenario) { + let scenarioArr = JSON.parse(item.scenario); + if (scenarioArr.length > 1) { + let scenarioIdArr = scenarioArr[0].split("_"); + scenarioId = scenarioIdArr[0]; + scenarioName = scenarioIdArr[1]; + } + } + // 循环构建子节点 + for (let i = 0; i < nodeArray.length; i++) { + if (!nodeArray[i]) { + continue; + } + let node = { + label: nodeArray[i], + value: item, + }; + if (i !== nodeArray.length) { + node.children = []; + } + if(item.subRequestResults && item.subRequestResults.length > 0){ + let itemChildren = this.deepFormatTreeNode(item.subRequestResults); + node.children = itemChildren; + } + if (children.length === 0) { + children.push(node); + } + + let isExist = false; + for (let j in children) { + if (children[j].label === node.label) { + + let idIsPath = true; + //判断ID是否匹配 目前发现问题的只有重复场景,而重复场景是在第二个节点开始合并的。所以这里暂时只判断第二个场景问题。 + //如果出现了其他问题,则需要检查其他问题的数据结构。暂时采用具体问题具体分析的策略 + if (i === nodeArray.length - 2) { + idIsPath = false; + let childId = ""; + let childName = ""; + if (children[j].value && children[j].value.scenario) { + let scenarioArr = JSON.parse(children[j].value.scenario); + if (scenarioArr.length > 1) { + let childArr = scenarioArr[0].split("_"); + childId = childArr[0]; + if (childArr.length > 1) { + childName = childArr[1]; + } + } + } + if (scenarioId === "") { + idIsPath = true; + } else if (scenarioId === childId) { + idIsPath = true; + } else if (scenarioName !== childName) { + //如果两个名字不匹配则默认通过,不匹配ID + idIsPath = true; + } + } + if (idIsPath) { + if (i !== nodeArray.length - 1 && !children[j].children) { + children[j].children = []; + } + children = (i === nodeArray.length - 1 ? children : children[j].children); + isExist = true; + break; + } + } + } + if (!isExist) { + children.push(node); + if (i !== nodeArray.length - 1 && !children[children.length - 1].children) { + children[children.length - 1].children = []; + } + children = (i === nodeArray.length - 1 ? children : children[children.length - 1].children); + } + } + }); + return children; + }, recursiveSorting(arr) { for (let i in arr) { if (arr[i]) {