fix(接口测试): 大数据量时的接口报告列表虚拟滚动调优&支持全部展开/折叠功能

--bug=1027497 --user=白奇 【接口测试】  github#25304在使用平台做测试时chrome经常出现崩溃问题 https://www.tapd.cn/55049933/s/1389144
This commit is contained in:
baiqi 2023-07-04 12:12:50 +08:00 committed by 刘瑞斌
parent ae0d601c53
commit 6fa237bd2f
3 changed files with 35 additions and 33 deletions

View File

@ -10,27 +10,31 @@
</div> </div>
<div style="height: calc(100vh - 400px);"> <div style="height: calc(100vh - 400px);">
<vue-easy-tree <vue-easy-tree
:data="treeData" :data="treeData"
:expand-on-click-node="false" node-key="id"
:default-expand-all="defaultExpand" :sizeDependencies="['expanded']"
:filter-node-method="filterNode" height="calc(100vh - 400px)"
highlight-current :minItemSize="47"
class="ms-tree ms-report-tree" :buffer="500"
node-key="resourceId" :expand-on-click-node="false"
:sizeDependencies="['expanded']" :default-expand-all="defaultExpand"
height="calc(100vh - 400px)" :filter-node-method="filterNode"
:minItemSize="47" highlight-current
isDynamic class="ms-tree ms-report-tree"
ref="resultsTree"> isDynamic
<span slot-scope="{ node, data }" style="width: 99%" @click="nodeClick(node)"> ref="resultsTree"
@node-click="nodeClick"
>
<template slot-scope="{ node, data }">
<ms-scenario-result <ms-scenario-result
:key="data.resourceId"
:node="data" :node="data"
:expanded="node.expanded"
:console="console" :console="console"
v-on:requestResult="requestResult" v-on:requestResult="requestResult"
:isActive="isActive"
:is-share="isShare" :is-share="isShare"
:share-id="shareId" /> :share-id="shareId" />
</span> </template>
</vue-easy-tree> </vue-easy-tree>
</div> </div>
</el-card> </el-card>
@ -56,7 +60,6 @@ export default {
}, },
data() { data() {
return { return {
isActive: false,
}; };
}, },
created() { created() {
@ -98,7 +101,7 @@ export default {
requestResult(requestResult) { requestResult(requestResult) {
this.$emit('requestResult', requestResult); this.$emit('requestResult', requestResult);
}, },
nodeClick(node) { nodeClick(data, node) {
node.expanded = !node.expanded; node.expanded = !node.expanded;
}, },
// //
@ -114,7 +117,6 @@ export default {
} }
}, },
closeExpansion() { closeExpansion() {
this.isActive = false;
this.expandAll = false; this.expandAll = false;
this.changeTreeNodeStatus(this.$refs.resultsTree.store.root, 0); this.changeTreeNodeStatus(this.$refs.resultsTree.store.root, 0);
}, },

View File

@ -9,7 +9,7 @@
<div class="el-step__icon is-text ms-api-col-create"> <div class="el-step__icon is-text ms-api-col-create">
<div class="el-step__icon-inner">{{ indexNumber }}</div> <div class="el-step__icon-inner">{{ indexNumber }}</div>
</div> </div>
<i class="icon el-icon-arrow-right" :class="{ 'is-active': showActive }" @click="active" @click.stop /> <i class="icon el-icon-arrow-right" :class="{ 'is-active': showActive }" @click.stop="active" />
<span class="report-label-req" @click="isLink" v-if="redirect && resourceId"> <span class="report-label-req" @click="isLink" v-if="redirect && resourceId">
{{ request.name }} {{ request.name }}
</span> </span>
@ -76,8 +76,7 @@
:scenario-name="scenarioName" :scenario-name="scenarioName"
:request-type="requestType" :request-type="requestType"
:request="requestInfo" :request="requestInfo"
:console="console" :console="console" />
v-if="showActive" />
</div> </div>
</el-collapse-transition> </el-collapse-transition>
</div> </div>
@ -119,17 +118,13 @@ export default {
type: String, type: String,
default: '', default: '',
}, },
isActive: { expanded: {
type: Boolean, type: Boolean,
default: false, default: false,
}, },
isShare: Boolean, isShare: Boolean,
shareId: String, shareId: String,
}, },
created() {
this.showActive = this.isActive;
this.baseErrorCode = this.errorCode;
},
data() { data() {
return { return {
requestType: '', requestType: '',
@ -156,9 +151,9 @@ export default {
}; };
}, },
watch: { watch: {
isActive() { expanded() {
this.loadRequestInfoExpand(); this.loadRequestInfoExpand();
this.showActive = this.isActive; this.showActive = this.expanded;
}, },
errorCode() { errorCode() {
this.baseErrorCode = this.errorCode; this.baseErrorCode = this.errorCode;
@ -176,6 +171,13 @@ export default {
}, },
}, },
}, },
created() {
this.showActive = this.expanded;
this.baseErrorCode = this.errorCode;
if(this.expanded === true) {
this.loadRequestInfoExpand();
}
},
methods: { methods: {
statusColor(status) { statusColor(status) {
return getReportStatusColor(status); return getReportStatusColor(status);
@ -224,6 +226,7 @@ export default {
} }
} else { } else {
this.requestInfo = this.request; this.requestInfo = this.request;
this.requestInfo.loading = false;
} }
}, },
active() { active() {

View File

@ -40,8 +40,8 @@
:scenarioName="node.label" :scenarioName="node.label"
:resourceId="node.resourceId" :resourceId="node.resourceId"
:total-status="node.totalStatus" :total-status="node.totalStatus"
:expanded="expanded"
:console="console" :console="console"
:isActive="isActive"
:is-share="isShare" :is-share="isShare"
:share-id="shareId" :share-id="shareId"
v-on:requestResult="requestResult" /> v-on:requestResult="requestResult" />
@ -64,8 +64,8 @@ export default {
scenario: Object, scenario: Object,
node: Object, node: Object,
console: String, console: String,
isActive: Boolean,
isShare: Boolean, isShare: Boolean,
expanded: Boolean,
shareId: String, shareId: String,
}, },
data() { data() {
@ -111,9 +111,6 @@ export default {
let element = document.getElementById(id); let element = document.getElementById(id);
element.parentNode.removeChild(element); element.parentNode.removeChild(element);
}, },
active() {
this.isActive = !this.isActive;
},
requestResult(requestResult) { requestResult(requestResult) {
this.$emit('requestResult', requestResult); this.$emit('requestResult', requestResult);
}, },