fix(接口测试): 测试报告导出异常
This commit is contained in:
parent
754f067cdd
commit
5bf126fa2e
|
@ -46,10 +46,9 @@ import MsScenarioResults from "./components/ScenarioResults";
|
|||
import MsContainer from "@/business/components/common/components/MsContainer";
|
||||
import MsMainContainer from "@/business/components/common/components/MsMainContainer";
|
||||
import MsApiReportExport from "./ApiReportExport";
|
||||
import {exportPdf} from "@/common/js/utils";
|
||||
import html2canvas from "html2canvas";
|
||||
import MsApiReportViewHeader from "./ApiReportViewHeader";
|
||||
import {RequestFactory} from "../test/model/ScenarioModel";
|
||||
import {windowPrint} from "../../../../common/js/utils";
|
||||
|
||||
export default {
|
||||
name: "MsApiReportViewDetail",
|
||||
|
@ -154,23 +153,16 @@ export default {
|
|||
this.scenarioName = requestResult.scenarioName;
|
||||
});
|
||||
},
|
||||
handleExport(name) {
|
||||
this.loading = true;
|
||||
handleExport() {
|
||||
this.reportExportVisible = true;
|
||||
let reset = this.exportReportReset;
|
||||
|
||||
this.$nextTick(function () {
|
||||
html2canvas(document.getElementById('apiTestReport'), {
|
||||
// scale: 2,
|
||||
}).then(function (canvas) {
|
||||
exportPdf(name, [canvas]);
|
||||
this.$nextTick(() => {
|
||||
windowPrint('apiTestReport', 0.57);
|
||||
reset();
|
||||
});
|
||||
});
|
||||
},
|
||||
exportReportReset() {
|
||||
this.reportExportVisible = false;
|
||||
this.loading = false;
|
||||
this.$router.go(0);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -9,10 +9,8 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="report-right">
|
||||
<div class="test">
|
||||
<img class="logo" src="@/assets/logo-MeterSphere.png">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -272,7 +272,7 @@ export default {
|
|||
|
||||
this.$nextTick(function () {
|
||||
html2canvas(document.getElementById('performanceReportExport'), {
|
||||
// scale: 2
|
||||
scale: 2
|
||||
}).then(function (canvas) {
|
||||
exportPdf(name, [canvas]);
|
||||
reset();
|
||||
|
|
|
@ -211,7 +211,7 @@
|
|||
|
||||
this.$nextTick(function () {
|
||||
html2canvas(document.getElementById('testCaseReportExport'), {
|
||||
// scale: 2
|
||||
scale: 2
|
||||
}).then(function(canvas) {
|
||||
exportPdf(name, [canvas]);
|
||||
reset();
|
||||
|
@ -225,7 +225,7 @@
|
|||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</script>cd
|
||||
|
||||
<style scoped>
|
||||
|
||||
|
|
|
@ -259,3 +259,17 @@ export function exportPdf(name, canvasList) {
|
|||
|
||||
}
|
||||
|
||||
export function windowPrint(id, zoom) {
|
||||
//根据div标签ID拿到div中的局部内容
|
||||
let bdhtml=window.document.body.innerHTML;
|
||||
let el = document.getElementById(id);
|
||||
var jubuData = el.innerHTML;
|
||||
document.getElementsByTagName('body')[0].style.zoom=zoom;
|
||||
//把获取的 局部div内容赋给body标签, 相当于重置了 body里的内容
|
||||
window.document.body.innerHTML= jubuData;
|
||||
//调用打印功能
|
||||
window.print();
|
||||
window.document.body.innerHTML=bdhtml;//重新给页面内容赋值;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue