From 7d2b2a4cc956f148e93ae80dd42c30358712d605 Mon Sep 17 00:00:00 2001 From: BugKing Date: Mon, 21 Sep 2020 10:28:24 +0800 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=94=B9=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 4 ++-- backend/pom.xml | 2 +- frontend/pom.xml | 2 +- pom.xml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 705770d659..8b0f86e7e0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,11 +6,11 @@ ARG MS_VERSION=dev RUN mkdir -p /opt/apps && mkdir -p /opt/jmeter -ADD backend/target/backend-1.1.jar /opt/apps +ADD backend/target/backend-1.3.jar /opt/apps ADD backend/target/classes/jmeter/ /opt/jmeter/ -ENV JAVA_APP_JAR=/opt/apps/backend-1.1.jar +ENV JAVA_APP_JAR=/opt/apps/backend-1.3.jar ENV AB_OFF=true diff --git a/backend/pom.xml b/backend/pom.xml index ef2af712b3..a1772fb09f 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -7,7 +7,7 @@ metersphere-server io.metersphere - 1.1 + 1.3 4.0.0 diff --git a/frontend/pom.xml b/frontend/pom.xml index fad8d9c5c0..e22139f987 100644 --- a/frontend/pom.xml +++ b/frontend/pom.xml @@ -7,7 +7,7 @@ metersphere-server io.metersphere - 1.1 + 1.3 4.0.0 diff --git a/pom.xml b/pom.xml index d6a5c89a3e..f43ee92c7c 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 io.metersphere metersphere-server - 1.1 + 1.3 pom From 01cf93bf45e758eb8738f6c815043f0cb22bddf6 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Mon, 21 Sep 2020 17:50:32 +0800 Subject: [PATCH 2/3] =?UTF-8?q?refactor(=E6=80=A7=E8=83=BD=E6=B5=8B?= =?UTF-8?q?=E8=AF=95):=20=E5=93=8D=E5=BA=94=E6=97=B6=E9=97=B4=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../performance/test/components/PerformanceAdvancedConfig.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/src/business/components/performance/test/components/PerformanceAdvancedConfig.vue b/frontend/src/business/components/performance/test/components/PerformanceAdvancedConfig.vue index 5429c37056..4459d8ef45 100644 --- a/frontend/src/business/components/performance/test/components/PerformanceAdvancedConfig.vue +++ b/frontend/src/business/components/performance/test/components/PerformanceAdvancedConfig.vue @@ -96,8 +96,7 @@
{{ $t('load_test.response_timeout') }}
- + ms From e00265b577119d4db378d719ad3b34196bd583fb Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Tue, 22 Sep 2020 10:35:59 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):?= =?UTF-8?q?=20=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E6=8A=A5=E5=91=8A?= =?UTF-8?q?=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/main/java/io/metersphere/xpack | 2 +- frontend/package.json | 4 +- .../TemplateComponent/TemplateComponent.vue | 49 ++++++++++++++-- .../comonents/report/TestCaseReportView.vue | 56 +++++++------------ frontend/src/business/components/xpack | 2 +- frontend/src/common/js/utils.js | 55 ++++++++++++++++++ 6 files changed, 124 insertions(+), 44 deletions(-) diff --git a/backend/src/main/java/io/metersphere/xpack b/backend/src/main/java/io/metersphere/xpack index 321c869938..d5b4969642 160000 --- a/backend/src/main/java/io/metersphere/xpack +++ b/backend/src/main/java/io/metersphere/xpack @@ -1 +1 @@ -Subproject commit 321c869938357e8c2253e5bd86c963828664ae23 +Subproject commit d5b4969642fd8d10cc2f949d7377e0a0e5217a3a diff --git a/frontend/package.json b/frontend/package.json index cf5672e833..fa0ad64992 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -30,7 +30,9 @@ "md5": "^2.3.0", "sha.js": "^2.4.11", "js-base64": "^3.4.4", - "json-bigint": "^1.0.0" + "json-bigint": "^1.0.0", + "html2canvas": "^1.0.0-rc.7", + "jspdf": "^2.1.1" }, "devDependencies": { "@vue/cli-plugin-babel": "^4.1.0", diff --git a/frontend/src/business/components/track/plan/view/comonents/report/TemplateComponent/TemplateComponent.vue b/frontend/src/business/components/track/plan/view/comonents/report/TemplateComponent/TemplateComponent.vue index d2b48f293a..47da205f32 100644 --- a/frontend/src/business/components/track/plan/view/comonents/report/TemplateComponent/TemplateComponent.vue +++ b/frontend/src/business/components/track/plan/view/comonents/report/TemplateComponent/TemplateComponent.vue @@ -13,12 +13,12 @@
- - - - - - + + + + + +
@@ -31,6 +31,8 @@ import RichTextComponent from "./RichTextComponent"; import FailureResultComponent from "./FailureResultComponent"; import DefectListComponent from "./DefectListComponent"; + import html2canvas from 'html2canvas'; + export default { name: "TemplateComponent", components: { @@ -51,6 +53,41 @@ type: Boolean, default: true }, + index: { + type: Number, + default: 0 + }, + }, + methods: { + getCanvas(canvasList) { + let index = this.index; + let componentId = this.getComponentId(); + return new Promise(function(resolve, reject) { + html2canvas(document.getElementById(componentId), { + scale: 2 + }).then(function(canvas) { + //排序 + canvasList.splice(index, 0, canvas); + resolve('success'); + }); + }); + }, + getComponentId() { + switch (this.preview.id) { + case 1: + return "baseInfoComponent"; + case 2: + return "testResultComponent"; + case 3: + return "resultChartComponent"; + case 4: + return "failureResultComponent"; + case 5: + return "defectListComponent"; + default: + return "richTextComponent"; + } + }, } } diff --git a/frontend/src/business/components/track/plan/view/comonents/report/TestCaseReportView.vue b/frontend/src/business/components/track/plan/view/comonents/report/TestCaseReportView.vue index 7277e73c68..ce08b348c4 100644 --- a/frontend/src/business/components/track/plan/view/comonents/report/TestCaseReportView.vue +++ b/frontend/src/business/components/track/plan/view/comonents/report/TestCaseReportView.vue @@ -25,38 +25,33 @@ {{$t('test_track.plan_view.edit_component')}} - +
-
- +
+
-
diff --git a/frontend/src/business/components/xpack b/frontend/src/business/components/xpack index f2d5a342c8..0a375848d0 160000 --- a/frontend/src/business/components/xpack +++ b/frontend/src/business/components/xpack @@ -1 +1 @@ -Subproject commit f2d5a342c82e629f510550d5778d752bb73bf5e7 +Subproject commit 0a375848d034d20eaf05caf11769e1c75c39235c diff --git a/frontend/src/common/js/utils.js b/frontend/src/common/js/utils.js index 10a28eb25b..6a344e4a0c 100644 --- a/frontend/src/common/js/utils.js +++ b/frontend/src/common/js/utils.js @@ -9,6 +9,7 @@ import { LicenseKey } from "./constants"; import axios from "axios"; +import {jsPDF} from "jspdf"; export function hasRole(role) { let user = getCurrentUser(); @@ -203,3 +204,57 @@ export function getUUID() { } +export function exportPdf(canvasList) { + + let pdf = new jsPDF('', 'pt', 'a4'); + + // 当前页面的当前高度 + let currentHeight = 0; + for (let canvas of canvasList) { + if (canvas) { + let contentWidth = canvas.width; + let contentHeight = canvas.height; + + //a4纸的尺寸[595.28,841.89] + let a4Width = 592.28; + let a4Height = 841.89; + + // html页面生成的canvas在pdf中图片的宽高 + let imgWidth = a4Width; + let imgHeight = a4Width/contentWidth * contentHeight; + + let pageData = canvas.toDataURL('image/jpeg', 1.0); + + // 当前图片的剩余高度 + let leftHeight = imgHeight; + + // 当前页面的剩余高度 + let blankHeight = a4Height - currentHeight; + + if (leftHeight > blankHeight) { + //页面偏移 + let position = 0; + while(leftHeight > 0) { + // 本次添加占用的高度 + let occupation = a4Height - currentHeight; + pdf.addImage(pageData, 'JPEG', 0, position + currentHeight, imgWidth, imgHeight); + currentHeight = leftHeight; + leftHeight -= occupation; + position -= occupation; + //避免添加空白页 + if(leftHeight > 0) { + pdf.addPage(); + currentHeight = 0; + } + } + } else { + pdf.addImage(pageData, 'JPEG', 0, currentHeight, imgWidth, imgHeight); + currentHeight += imgHeight; + } + } + } + + pdf.save('stone.pdf'); + +} +