style(接口测试): 报告页面高度自动适应,导出报告样式优化

This commit is contained in:
fit2-zhao 2022-10-25 11:59:11 +08:00 committed by fit2-zhao
parent d8549e02dc
commit d5513d7a5b
6 changed files with 179 additions and 175 deletions

View File

@ -1,7 +1,8 @@
<template> <template>
<div>
<ms-container v-loading="loading || reportExportVisible"> <ms-container v-loading="loading || reportExportVisible">
<ms-main-container class="api-report-content"> <ms-main-container>
<el-card class="report-body"> <el-card>
<section class="report-container" v-if="this.report.testId"> <section class="report-container" v-if="this.report.testId">
<!-- header --> <!-- header -->
<ms-api-report-view-header <ms-api-report-view-header
@ -20,7 +21,7 @@
<!-- content header chart --> <!-- content header chart -->
<ms-metric-chart :content="content" :totalTime="totalTime" :report="report"/> <ms-metric-chart :content="content" :totalTime="totalTime" :report="report"/>
<el-tabs v-model="activeName" @tab-click="handleClick" style="min-width: 1500px"> <el-tabs v-model="activeName" @tab-click="handleClick" style="min-width: 1200px">
<!-- all step--> <!-- all step-->
<el-tab-pane label="All" name="total"> <el-tab-pane label="All" name="total">
<ms-scenario-results <ms-scenario-results
@ -89,6 +90,12 @@
height="calc(100vh - 500px)"/> height="calc(100vh - 500px)"/>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</main>
</section>
</el-card>
</ms-main-container>
</ms-container>
<!--export report--> <!--export report-->
<ms-api-report-export <ms-api-report-export
@ -98,12 +105,8 @@
:title="report.name" :title="report.name"
:content="content" :content="content"
:report="report" :report="report"
:total-time="totalTime" class="ms-copy-bottom"/> :total-time="totalTime" class="target-node-item"/>
</main> </div>
</section>
</el-card>
</ms-main-container>
</ms-container>
</template> </template>
<script> <script>
@ -756,7 +759,7 @@ export default {
<style scoped> <style scoped>
.report-container { .report-container {
height: calc(100vh - 155px); height: calc(100vh - 70px);
min-height: 600px; min-height: 600px;
overflow-y: auto; overflow-y: auto;
} }
@ -799,9 +802,7 @@ export default {
min-width: 750px !important; min-width: 750px !important;
} }
.ms-copy-bottom { .target-node-item {
position: absolute; background: #FFFFFF;
bottom: 0;
} }
</style> </style>

View File

@ -3,14 +3,12 @@
:type="$t('report.api_test_report')"> :type="$t('report.api_test_report')">
<ms-metric-chart :content="content" :is-export="true" :totalTime="totalTime" :report="report"/> <ms-metric-chart :content="content" :is-export="true" :totalTime="totalTime" :report="report"/>
<div class="scenario-result" v-for="(scenario, index) in content.scenarios" :key="index" :scenario="scenario"> <div class="scenario-result" v-for="(scenario, index) in content.scenarios" :key="index" :scenario="scenario">
<div>
<el-card> <el-card>
<template v-slot:header> <template v-slot:header>
{{ $t('api_report.scenario_name') }}{{ scenario.name }} {{ $t('api_report.scenario_name') }}{{ scenario.name }}
</template> </template>
<div class="ms-border clearfix" v-for="(request, index) in scenario.requestResults" :key="index" <div class="ms-border clearfix" v-for="(request, index) in scenario.requestResults" :key="index"
:request="request"> :request="request">
<div class="request-top"> <div class="request-top">
<div> <div>
{{ getName(request.name) }} {{ getName(request.name) }}
@ -76,7 +74,6 @@
</div> </div>
</el-card> </el-card>
</div> </div>
</div>
</ms-report-export-template> </ms-report-export-template>
</template> </template>

View File

@ -233,6 +233,6 @@ export default {
} }
.report-header { .report-header {
min-width: 1500px; min-width: 1200px;
} }
</style> </style>

View File

@ -318,7 +318,7 @@ export default {
<style scoped> <style scoped>
.metric-container { .metric-container {
padding: 5px 10px; padding: 5px 10px;
min-width: 1500px; min-width: 1200px;
} }
.metric-container #chart { .metric-container #chart {

View File

@ -559,4 +559,10 @@ export default {
.report-bottom { .report-bottom {
margin-top: 10px; margin-top: 10px;
} }
:deep(.report-container) {
height: calc(100vh - 155px) !important;
min-height: 600px;
overflow-y: auto;
}
</style> </style>

View File

@ -1,6 +1,5 @@
import {COUNT_NUMBER, COUNT_NUMBER_SHALLOW, ORIGIN_COLOR, ORIGIN_COLOR_SHALLOW, PRIMARY_COLOR} from "./constants"; import {COUNT_NUMBER, COUNT_NUMBER_SHALLOW, ORIGIN_COLOR, ORIGIN_COLOR_SHALLOW, PRIMARY_COLOR} from "./constants";
import i18n from '../i18n' import i18n from '../i18n'
import {MessageBox} from "element-ui";
import html2canvas from 'html2canvas'; import html2canvas from 'html2canvas';
import JsPDF from 'jspdf'; import JsPDF from 'jspdf';
@ -344,7 +343,7 @@ export function getUrlParams(url) {
/** /**
* @param ele 要生成 pdf 的DOM元素容器 * @param ele 要生成 pdf 的DOM元素容器
* @param padfName PDF文件生成后的文件名字 * @param pdfName PDF文件生成后的文件名字
* */ * */
export function downloadPDF(ele, pdfName) { export function downloadPDF(ele, pdfName) {
let eleW = ele.offsetWidth;// 获得该容器的宽 let eleW = ele.offsetWidth;// 获得该容器的宽
@ -393,6 +392,7 @@ export function downloadPDF(ele, pdfName) {
html2canvas(ele, { html2canvas(ele, {
dpi: 300, dpi: 300,
backgroundColor: 'white',
// allowTaint: true, //允许 canvas 污染, allowTaint参数要去掉否则是无法通过toDataURL导出canvas数据的 // allowTaint: true, //允许 canvas 污染, allowTaint参数要去掉否则是无法通过toDataURL导出canvas数据的
useCORS: true //允许canvas画布内 可以跨域请求外部链接图片, 允许跨域请求。 useCORS: true //允许canvas画布内 可以跨域请求外部链接图片, 允许跨域请求。
}).then((canvas) => { }).then((canvas) => {