From 664bf2711d286ded31d661ba79a6a014f65a7888 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Mon, 6 Feb 2023 09:38:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AF=BC=E5=87=BA=E5=A4=A7=E7=9A=84=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E6=8A=A5=E5=91=8A=E5=87=BA=E7=8E=B0=E7=A9=BA=E7=99=BD?= =?UTF-8?q?=E9=A1=B5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api-test/frontend/package.json | 5 +- .../automation/report/ApiReportDetail.vue | 19 ++++++- .../automation/report/ApiReportExport.vue | 13 +++-- .../src/components/report/MsReportTitle.vue | 50 ++++++++----------- 4 files changed, 52 insertions(+), 35 deletions(-) diff --git a/api-test/frontend/package.json b/api-test/frontend/package.json index 3884a05f96..88b86ac89a 100644 --- a/api-test/frontend/package.json +++ b/api-test/frontend/package.json @@ -26,6 +26,7 @@ "fit2cloud-ui": "^1.8.0", "html2canvas": "^1.0.0-rc.7", "js-base64": "^3.4.4", + "js-file-download": "^0.4.12", "jsencrypt": "^3.1.0", "json-bigint": "^1.0.0", "json-schema-faker": "^0.5.0-rcv.32", @@ -50,6 +51,7 @@ "pdfjs-dist": "2.5.207", "pinia": "^2.0.14", "pinia-plugin-persistedstate": "^1.6.3", + "print-js": "^1.6.0", "sha.js": "^2.4.11", "vue": "^2.7.3", "vue-calendar-heatmap": "^0.8.4", @@ -66,8 +68,7 @@ "vue2-ace-editor": "0.0.15", "vuedraggable": "^2.24.3", "xml-js": "^1.6.11", - "yan-progress": "^1.0.3", - "js-file-download": "^0.4.12" + "yan-progress": "^1.0.3" }, "devDependencies": { "@babel/core": "^7.12.16", diff --git a/api-test/frontend/src/business/automation/report/ApiReportDetail.vue b/api-test/frontend/src/business/automation/report/ApiReportDetail.vue index eab606c3e1..4eae2dbf7b 100644 --- a/api-test/frontend/src/business/automation/report/ApiReportDetail.vue +++ b/api-test/frontend/src/business/automation/report/ApiReportDetail.vue @@ -130,6 +130,7 @@ import { } from '../../../api/scenario-report'; import { STEP } from '../../automation/scenario/Setting'; import MsCodeEdit from 'metersphere-frontend/src/components/MsCodeEdit'; +import print from 'print-js'; export default { name: 'MsApiReport', @@ -708,11 +709,27 @@ export default { name = this.encodeSearchKey(name); this.$nextTick(() => { setTimeout(() => { - downloadPDF(document.getElementById('apiTestReport'), name || 'scenario-report'); + this.printHTML(); reset(); }, 5000); }); }, + printHTML() { + function closeFuc() { + location.reload(); + } + + print({ + printable: 'apiTestReport', + type: 'html', + maxWidth: 1200, + documentTitle: '', + scanStyles: true, + header: '', + targetStyles: ['*'], // 打印内容使用所有HTML样式,没有设置这个属性/值,设置分页打印没有效果 + onPrintDialogClose: closeFuc, + }); + }, // 对报告名称中的特殊字符进行编码 encodeSearchKey(key) { const encodeArr = [ diff --git a/api-test/frontend/src/business/automation/report/ApiReportExport.vue b/api-test/frontend/src/business/automation/report/ApiReportExport.vue index f7e103ed88..e3dda689e7 100644 --- a/api-test/frontend/src/business/automation/report/ApiReportExport.vue +++ b/api-test/frontend/src/business/automation/report/ApiReportExport.vue @@ -53,12 +53,12 @@ {{ request.passAssertions + ' / ' + request.totalAssertions }} - + {{ request.responseResult.responseCode }} - {{ $t('api_test.home_page.detail_card.unexecute') }} + Pending Pending FakeError Success @@ -122,7 +122,7 @@ export default { .scenario-result { margin-top: 20px; margin-bottom: 20px; - min-width: 1200px; + min-width: 1000px; } .method { @@ -158,4 +158,11 @@ export default { background-color: #fdf5ea; border-color: #fdf5ea; } + +:deep(.report-left) { + float: none; +} +:deep(.metric-box-total) { + min-width: 100px; +} diff --git a/framework/sdk-parent/frontend/src/components/report/MsReportTitle.vue b/framework/sdk-parent/frontend/src/components/report/MsReportTitle.vue index 8178face5e..c18ba58805 100644 --- a/framework/sdk-parent/frontend/src/components/report/MsReportTitle.vue +++ b/framework/sdk-parent/frontend/src/components/report/MsReportTitle.vue @@ -5,47 +5,38 @@
【{{ type }}】- {{ title }} - {{ $t("report.test_start_time") }}: + {{ $t("report.test_start_time") }}: {{ report.createTime | datetimeFormat }} - {{ $t("report.test_end_time") }}: + {{ $t("report.test_end_time") }}: {{ report.endTime | datetimeFormat }}
- +
-
- {{ $t("report.run_model") + ":" }} -
-
- {{ getModeName(this.mode) }} -
+ {{ $t("report.run_model") + ":" }} + + {{ getModeName(this.mode) }} +
-
- {{ $t("load_test.select_resource_pool") + ":" }} -
-
- {{ this.poolName }} -
+ {{ $t("load_test.select_resource_pool") + ":" }} + + {{ this.poolName }} +
-
- - {{ $t("commons.environment") + ":" }} -
+ + + {{ $t("commons.environment") + ":" }} + {{ key + ":" }} -
+ +
@@ -64,7 +56,7 @@ import MsTag from "../MsTag"; export default { name: "MsReportTitle", - components: { MsTag }, + components: {MsTag}, props: { title: String, type: String,