refactor(性能测试): 导出报告时关闭动画

This commit is contained in:
Captain.B 2021-05-17 19:15:05 +08:00 committed by 刘瑞斌
parent 7be66acff6
commit 00c2a909a3
2 changed files with 35 additions and 34 deletions

View File

@ -4,7 +4,7 @@
<template v-slot:header > <template v-slot:header >
<span class="title">{{$t('report.test_overview')}}</span> <span class="title">{{$t('report.test_overview')}}</span>
</template> </template>
<ms-report-test-overview :report="report" ref="testOverview"/> <ms-report-test-overview :report="report" :export="true" ref="testOverview"/>
</el-card> </el-card>
<el-card id="requestStatistics" title="'requestStatistics'"> <el-card id="requestStatistics" title="'requestStatistics'">
<template v-slot:header > <template v-slot:header >

View File

@ -96,7 +96,7 @@ export default {
errorOption: {}, errorOption: {},
resCodeOption: {}, resCodeOption: {},
id: '' id: ''
} };
}, },
methods: { methods: {
initTableData() { initTableData() {
@ -118,7 +118,7 @@ export default {
this.responseTime90 = '0'; this.responseTime90 = '0';
this.avgBandwidth = '0'; this.avgBandwidth = '0';
// this.$warning(this.$t('report.generation_error')); // this.$warning(this.$t('report.generation_error'));
}) });
this.getLoadChart(); this.getLoadChart();
this.getResChart(); this.getResChart();
this.getErrorChart(); this.getErrorChart();
@ -190,18 +190,18 @@ export default {
color: '#E6113C', color: '#E6113C',
} }
] ]
} };
yAxisIndex0List.forEach(item => { yAxisIndex0List.forEach(item => {
setting["series"].splice(0, 0, {name: item, yAxisIndex: '0'}) setting["series"].splice(0, 0, {name: item, yAxisIndex: '0'});
}) });
yAxisIndex1List.forEach(item => { yAxisIndex1List.forEach(item => {
setting["series"].splice(0, 0, {name: item, yAxisIndex: '1'}) setting["series"].splice(0, 0, {name: item, yAxisIndex: '1'});
}) });
this.loadOption = this.generateOption(loadOption, data, setting); this.loadOption = this.generateOption(loadOption, data, setting);
}).catch(() => { }).catch(() => {
this.loadOption = {}; this.loadOption = {};
}) });
}, },
getResChart() { getResChart() {
this.$get("/performance/report/content/res_chart/" + this.id).then(res => { this.$get("/performance/report/content/res_chart/" + this.id).then(res => {
@ -265,7 +265,7 @@ export default {
} }
], ],
series: [] series: []
} };
let setting = { let setting = {
series: [ series: [
{ {
@ -273,20 +273,20 @@ export default {
color: '#0CA74A', color: '#0CA74A',
} }
] ]
} };
yAxisIndex0List.forEach(item => { yAxisIndex0List.forEach(item => {
setting["series"].splice(0, 0, {name: item, yAxisIndex: '0'}) setting["series"].splice(0, 0, {name: item, yAxisIndex: '0'});
}) });
yAxisIndex1List.forEach(item => { yAxisIndex1List.forEach(item => {
setting["series"].splice(0, 0, {name: item, yAxisIndex: '1'}) setting["series"].splice(0, 0, {name: item, yAxisIndex: '1'});
}) });
this.resOption = this.generateOption(resOption, data, setting); this.resOption = this.generateOption(resOption, data, setting);
}).catch(() => { }).catch(() => {
this.resOption = {}; this.resOption = {};
}) });
}, },
getErrorChart() { getErrorChart() {
this.$get("/performance/report/content/error_chart/" + this.id).then(res => { this.$get("/performance/report/content/error_chart/" + this.id).then(res => {
@ -340,7 +340,7 @@ export default {
} }
], ],
series: [] series: []
} };
let setting = { let setting = {
series: [ series: [
{ {
@ -348,16 +348,16 @@ export default {
color: '#0CA74A', color: '#0CA74A',
} }
] ]
} };
yAxisIndex0List.forEach(item => { yAxisIndex0List.forEach(item => {
setting["series"].splice(0, 0, {name: item, yAxisIndex: '0'}) setting["series"].splice(0, 0, {name: item, yAxisIndex: '0'});
}) });
this.errorOption = this.generateOption(errorOption, data, setting); this.errorOption = this.generateOption(errorOption, data, setting);
}).catch(() => { }).catch(() => {
this.errorOption = {}; this.errorOption = {};
}) });
}, },
getResponseCodeChart() { getResponseCodeChart() {
this.$get("/performance/report/content/response_code_chart/" + this.id).then(res => { this.$get("/performance/report/content/response_code_chart/" + this.id).then(res => {
@ -411,7 +411,7 @@ export default {
} }
], ],
series: [] series: []
} };
let setting = { let setting = {
series: [ series: [
{ {
@ -419,16 +419,16 @@ export default {
color: '#0CA74A', color: '#0CA74A',
} }
] ]
} };
yAxisIndex0List.forEach(item => { yAxisIndex0List.forEach(item => {
setting["series"].splice(0, 0, {name: item, yAxisIndex: '0'}) setting["series"].splice(0, 0, {name: item, yAxisIndex: '0'});
}) });
this.resCodeOption = this.generateOption(resCodeOption, data, setting); this.resCodeOption = this.generateOption(resCodeOption, data, setting);
}).catch(() => { }).catch(() => {
this.resCodeOption = {}; this.resCodeOption = {};
}) });
}, },
generateOption(option, data, setting) { generateOption(option, data, setting) {
let chartData = data; let chartData = data;
@ -445,18 +445,18 @@ export default {
if (!xAxis.includes(item.xAxis)) { if (!xAxis.includes(item.xAxis)) {
xAxis.push(item.xAxis); xAxis.push(item.xAxis);
} }
xAxis.sort() xAxis.sort();
let name = item.groupName let name = item.groupName;
if (!legend.includes(name)) { if (!legend.includes(name)) {
legend.push(name) legend.push(name);
series[name] = [] series[name] = [];
} }
if (item.yAxis === -1) { if (item.yAxis === -1) {
series[name].splice(xAxis.indexOf(item.xAxis), 0, [item.xAxis, item.yAxis2.toFixed(2)]); series[name].splice(xAxis.indexOf(item.xAxis), 0, [item.xAxis, item.yAxis2.toFixed(2)]);
} else { } else {
series[name].splice(xAxis.indexOf(item.xAxis), 0, [item.xAxis, item.yAxis.toFixed(2)]); series[name].splice(xAxis.indexOf(item.xAxis), 0, [item.xAxis, item.yAxis.toFixed(2)]);
} }
}) });
this.$set(option.legend, "data", legend); this.$set(option.legend, "data", legend);
this.$set(option.legend, "type", "scroll"); this.$set(option.legend, "type", "scroll");
this.$set(option.legend, "bottom", "10px"); this.$set(option.legend, "bottom", "10px");
@ -469,7 +469,8 @@ export default {
type: 'line', type: 'line',
data: d, data: d,
smooth: true, smooth: true,
sampling: 'lttb' sampling: 'lttb',
animation: !this.export,
}; };
let seriesArrayNames = seriesArray.map(m => m.name); let seriesArrayNames = seriesArray.map(m => m.name);
if (seriesArrayNames.includes(name)) { if (seriesArrayNames.includes(name)) {
@ -520,8 +521,8 @@ export default {
deep: true deep: true
} }
}, },
props: ['report'] props: ['report', 'export']
} };
</script> </script>
<style scoped> <style scoped>