Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
a31cd2e8bc
|
@ -3,12 +3,14 @@ package io.metersphere.notice.service;
|
|||
import io.metersphere.api.dto.APIReportResult;
|
||||
import io.metersphere.base.domain.Notice;
|
||||
import io.metersphere.base.domain.SystemParameter;
|
||||
import io.metersphere.base.domain.TestCaseWithBLOBs;
|
||||
import io.metersphere.commons.constants.ParamConstants;
|
||||
import io.metersphere.commons.utils.EncryptUtils;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.dto.LoadTestDTO;
|
||||
import io.metersphere.service.SystemParameterService;
|
||||
import io.metersphere.service.UserService;
|
||||
import io.metersphere.track.request.testreview.SaveCommentRequest;
|
||||
import io.metersphere.track.request.testreview.SaveTestCaseReviewRequest;
|
||||
import org.springframework.mail.MailException;
|
||||
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
||||
|
@ -138,12 +140,20 @@ public class MailService {
|
|||
}
|
||||
|
||||
|
||||
public void sendHtml(List<String> userIds, String type, SaveTestCaseReviewRequest reviewRequest) {
|
||||
public void sendHtml(List<String> userIds, String type, SaveTestCaseReviewRequest reviewRequest, SaveCommentRequest request, TestCaseWithBLOBs testCaseWithBLOBs) {
|
||||
Long startTime = reviewRequest.getCreateTime();
|
||||
Long endTime = reviewRequest.getEndTime();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String start = sdf.format(new Date(Long.parseLong(String.valueOf(startTime))));
|
||||
String end = sdf.format(new Date(Long.parseLong(String.valueOf(endTime))));
|
||||
String start = null;
|
||||
String sTime = String.valueOf(startTime);
|
||||
String eTime = String.valueOf(endTime);
|
||||
if (!sTime.equals("null")) {
|
||||
start = sdf.format(new Date(Long.parseLong(sTime)));
|
||||
}
|
||||
String end = null;
|
||||
if (!eTime.equals("null")) {
|
||||
end = sdf.format(new Date(Long.parseLong(eTime)));
|
||||
}
|
||||
JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
|
||||
List<SystemParameter> paramList = systemParameterService.getParamList(ParamConstants.Classify.MAIL.getValue());
|
||||
javaMailSender.setDefaultEncoding("UTF-8");
|
||||
|
@ -182,8 +192,31 @@ public class MailService {
|
|||
" </div>\n" +
|
||||
"</body>\n" +
|
||||
"</html>";
|
||||
String html2 = "";
|
||||
String html3 = "";
|
||||
String html2 = "<!DOCTYPE html>\n" +
|
||||
"<html lang=\"en\">\n" +
|
||||
"<head>\n" +
|
||||
" <meta charset=\"UTF-8\">\n" +
|
||||
" <title>MeterSphere</title>\n" +
|
||||
"</head>\n" +
|
||||
"<body style=\"text-align: left\">\n" +
|
||||
" <div>\n" +
|
||||
" <p>" + testCaseWithBLOBs.getMaintainer() + "发起的" + testCaseWithBLOBs.getName() + "添加评论:" + request.getDescription() + "</p>\n" +
|
||||
" </div>\n" +
|
||||
"</body>\n" +
|
||||
"</html>";
|
||||
String html3 = "<!DOCTYPE html>\n" +
|
||||
"<html lang=\"en\">\n" +
|
||||
"<head>\n" +
|
||||
" <meta charset=\"UTF-8\">\n" +
|
||||
" <title>MeterSphere</title>\n" +
|
||||
"</head>\n" +
|
||||
"<body style=\"text-align: left\">\n" +
|
||||
" <div>\n" +
|
||||
" <p>" + reviewRequest.getCreator() + "发起的" + reviewRequest.getName() + "的计划开始时间是" + start + ",计划结束时间为" + end + "已完成" + "</p>\n" +
|
||||
" </div>\n" +
|
||||
"</body>\n" +
|
||||
"</html>";
|
||||
;
|
||||
try {
|
||||
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
|
||||
helper.setFrom(javaMailSender.getUsername());
|
||||
|
@ -198,6 +231,10 @@ public class MailService {
|
|||
users = emails.toArray(new String[emails.size()]);
|
||||
if (type.equals("reviewer")) {
|
||||
helper.setText(html1, true);
|
||||
} else if (type.equals("comment")) {
|
||||
helper.setText(html2, true);
|
||||
} else if (type.equals("end")) {
|
||||
helper.setText(html3, true);
|
||||
}
|
||||
helper.setTo(users);
|
||||
|
||||
|
|
|
@ -1,16 +1,21 @@
|
|||
package io.metersphere.track.service;
|
||||
|
||||
import io.metersphere.base.domain.TestCaseComment;
|
||||
import io.metersphere.base.domain.TestCaseCommentExample;
|
||||
import io.metersphere.base.domain.User;
|
||||
import io.metersphere.base.domain.*;
|
||||
import io.metersphere.base.mapper.TestCaseCommentMapper;
|
||||
import io.metersphere.base.mapper.TestCaseMapper;
|
||||
import io.metersphere.base.mapper.TestCaseReviewMapper;
|
||||
import io.metersphere.base.mapper.UserMapper;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.notice.service.MailService;
|
||||
import io.metersphere.track.request.testreview.SaveCommentRequest;
|
||||
import io.metersphere.track.request.testreview.SaveTestCaseReviewRequest;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -21,7 +26,13 @@ public class TestCaseCommentService {
|
|||
@Resource
|
||||
TestCaseCommentMapper testCaseCommentMapper;
|
||||
@Resource
|
||||
private TestCaseReviewMapper testCaseReviewMapper;
|
||||
@Resource
|
||||
UserMapper userMapper;
|
||||
@Resource
|
||||
MailService mailService;
|
||||
@Resource
|
||||
TestCaseMapper testCaseMapper;
|
||||
|
||||
public void saveComment(SaveCommentRequest request) {
|
||||
TestCaseComment testCaseComment = new TestCaseComment();
|
||||
|
@ -32,6 +43,13 @@ public class TestCaseCommentService {
|
|||
testCaseComment.setUpdateTime(System.currentTimeMillis());
|
||||
testCaseComment.setDescription(request.getDescription());
|
||||
testCaseCommentMapper.insert(testCaseComment);
|
||||
TestCaseWithBLOBs testCaseWithBLOBs;
|
||||
testCaseWithBLOBs = testCaseMapper.selectByPrimaryKey(request.getCaseId());
|
||||
SaveTestCaseReviewRequest caseReviewRequest = new SaveTestCaseReviewRequest();
|
||||
List<String> userIds = new ArrayList<>();
|
||||
userIds.add(testCaseComment.getAuthor());
|
||||
mailService.sendHtml(userIds, "comment", caseReviewRequest, request, testCaseWithBLOBs);
|
||||
|
||||
}
|
||||
|
||||
public List<TestCaseComment> getComments(String caseId) {
|
||||
|
|
|
@ -17,10 +17,8 @@ import io.metersphere.controller.request.member.QueryMemberRequest;
|
|||
import io.metersphere.notice.service.MailService;
|
||||
import io.metersphere.service.UserService;
|
||||
import io.metersphere.track.dto.*;
|
||||
import io.metersphere.track.request.testreview.QueryTestReviewRequest;
|
||||
import io.metersphere.track.request.testreview.ReviewRelevanceRequest;
|
||||
import io.metersphere.track.request.testreview.QueryCaseReviewRequest;
|
||||
import io.metersphere.track.request.testreview.SaveTestCaseReviewRequest;
|
||||
import io.metersphere.track.request.testreview.*;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
|
@ -30,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -64,6 +63,7 @@ public class TestCaseReviewService {
|
|||
@Resource
|
||||
MailService mailService;
|
||||
|
||||
|
||||
public void saveTestCaseReview(SaveTestCaseReviewRequest reviewRequest) {
|
||||
checkCaseReviewExist(reviewRequest);
|
||||
|
||||
|
@ -91,7 +91,9 @@ public class TestCaseReviewService {
|
|||
reviewRequest.setCreator(SessionUtils.getUser().getId());
|
||||
reviewRequest.setStatus(TestCaseReviewStatus.Prepare.name());
|
||||
testCaseReviewMapper.insert(reviewRequest);
|
||||
mailService.sendHtml(userIds, "reviewer", reviewRequest);
|
||||
SaveCommentRequest request = new SaveCommentRequest();
|
||||
TestCaseWithBLOBs testCaseWithBLOBs = new TestCaseWithBLOBs();
|
||||
mailService.sendHtml(userIds, "reviewer", reviewRequest, request, testCaseWithBLOBs);
|
||||
|
||||
}
|
||||
|
||||
|
@ -148,7 +150,9 @@ public class TestCaseReviewService {
|
|||
testCaseReview.setUpdateTime(System.currentTimeMillis());
|
||||
checkCaseReviewExist(testCaseReview);
|
||||
testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview);
|
||||
mailService.sendHtml(testCaseReview.getUserIds(), "reviewer", testCaseReview);
|
||||
SaveCommentRequest request = new SaveCommentRequest();
|
||||
TestCaseWithBLOBs testCaseWithBLOBs = new TestCaseWithBLOBs();
|
||||
mailService.sendHtml(testCaseReview.getUserIds(), "reviewer", testCaseReview, request, testCaseWithBLOBs);
|
||||
}
|
||||
|
||||
private void editCaseReviewer(SaveTestCaseReviewRequest testCaseReview) {
|
||||
|
@ -321,6 +325,20 @@ public class TestCaseReviewService {
|
|||
}
|
||||
}
|
||||
testCaseReview.setStatus(TestPlanStatus.Completed.name());
|
||||
SaveCommentRequest request = new SaveCommentRequest();
|
||||
TestCaseWithBLOBs testCaseWithBLOBs = new TestCaseWithBLOBs();
|
||||
SaveTestCaseReviewRequest testCaseReviewRequest = new SaveTestCaseReviewRequest();
|
||||
TestCaseReview _testCaseReview = testCaseReviewMapper.selectByPrimaryKey(reviewId);
|
||||
List<String> userIds = new ArrayList<>();
|
||||
userIds.add(_testCaseReview.getCreator());
|
||||
try {
|
||||
BeanUtils.copyProperties(testCaseReviewRequest, _testCaseReview);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
mailService.sendHtml(userIds, "end", testCaseReviewRequest, request, testCaseWithBLOBs);
|
||||
testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,30 +1,35 @@
|
|||
<template>
|
||||
<el-card>
|
||||
<div class="report-title title">接口测试报告</div>
|
||||
<ms-report-title :title="$t('report.api_test_report')"/>
|
||||
<ms-metric-chart :content="content" :totalTime="totalTime"/>
|
||||
<div class="scenario-result" v-for="(scenario, index) in content.scenarios" :key="index" :scenario="scenario">
|
||||
<div>
|
||||
<el-card >
|
||||
<el-card>
|
||||
<template v-slot:header>
|
||||
{{$t('api_report.scenario_name')}}:{{scenario.name}}
|
||||
</template>
|
||||
<div class="ms-border" v-for="(request, index) in scenario.requestResults" :key="index" :request="request">
|
||||
<div class="ms-border clearfix" v-for="(request, index) in scenario.requestResults" :key="index" :request="request">
|
||||
|
||||
<div class="request-left">
|
||||
<api-report-reqest-header-item :title="request.name">
|
||||
<span class="url"> {{request.url}}</span>
|
||||
</api-report-reqest-header-item>
|
||||
<div class="request-top">
|
||||
<div>
|
||||
{{request.name}}
|
||||
</div>
|
||||
<div class="url">
|
||||
{{request.url}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-divider/>
|
||||
|
||||
<div class="request-right">
|
||||
|
||||
<div class="request-bottom">
|
||||
|
||||
<api-report-reqest-header-item :title="$t('api_test.request.method')">
|
||||
<span class="method"> {{request.method}}</span>
|
||||
</api-report-reqest-header-item>
|
||||
|
||||
<api-report-reqest-header-item :title="$t('api_report.response_time')">
|
||||
{{request.responseResult.responseTime}}
|
||||
{{request.responseResult.responseTime}} ms
|
||||
</api-report-reqest-header-item>
|
||||
|
||||
<api-report-reqest-header-item :title="$t('api_report.latency')">
|
||||
|
@ -36,11 +41,11 @@
|
|||
</api-report-reqest-header-item>
|
||||
|
||||
<api-report-reqest-header-item :title="$t('api_report.response_size')">
|
||||
{{request.responseResult.latency}} ms
|
||||
{{request.responseResult.responseSize}} bytes
|
||||
</api-report-reqest-header-item>
|
||||
|
||||
<api-report-reqest-header-item :title="$t('api_report.error')">
|
||||
{{request.responseResult.responseSize}} bytes
|
||||
{{request.error}}
|
||||
</api-report-reqest-header-item>
|
||||
|
||||
<api-report-reqest-header-item :title="$t('api_report.assertions')">
|
||||
|
@ -72,9 +77,10 @@
|
|||
import MsRequestResultTail from "./components/RequestResultTail";
|
||||
import ApiReportReqestHeaderItem from "./ApiReportReqestHeaderItem";
|
||||
import MsMetricChart from "./components/MetricChart";
|
||||
import MsReportTitle from "../../common/components/MsReportTitle";
|
||||
export default {
|
||||
name: "MsApiReportExport",
|
||||
components: {MsMetricChart, ApiReportReqestHeaderItem, MsRequestResultTail, MsScenarioResult},
|
||||
components: {MsReportTitle, MsMetricChart, ApiReportReqestHeaderItem, MsRequestResultTail, MsScenarioResult},
|
||||
props: {
|
||||
content: Object,
|
||||
totalTime: Number
|
||||
|
@ -99,27 +105,10 @@
|
|||
font-weight: 500;
|
||||
}
|
||||
|
||||
.request-right {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.request-left {
|
||||
float: left;
|
||||
.request-top,.request-bottom {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.ms-border {
|
||||
height: 60px;
|
||||
}
|
||||
|
||||
.report-title {
|
||||
font-size: 30px;
|
||||
font-weight: bold;
|
||||
height: 50px;
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.url {
|
||||
color: #409EFF;
|
||||
font-size: 14px;
|
||||
|
@ -133,4 +122,8 @@
|
|||
border-style: none;
|
||||
}
|
||||
|
||||
.request-top div {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<template>
|
||||
<div class="report-title title">{{title}}</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "MsReportTitle",
|
||||
props: {title: String}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
.report-title {
|
||||
font-size: 30px;
|
||||
font-weight: bold;
|
||||
height: 50px;
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
</style>
|
|
@ -0,0 +1,54 @@
|
|||
<template>
|
||||
<el-card class="report-export">
|
||||
<ms-report-title :title="$t('report.load_test_report')"/>
|
||||
<el-card id="testOverview">
|
||||
<template v-slot:header >
|
||||
<span class="title">{{$t('report.test_overview')}}</span>
|
||||
</template>
|
||||
<ms-report-test-overview :report="report" ref="testOverview"/>
|
||||
</el-card>
|
||||
<el-card id="requestStatistics" title="'requestStatistics'">
|
||||
<template v-slot:header >
|
||||
<span class="title">{{$t('report.test_request_statistics')}}</span>
|
||||
</template>
|
||||
<ms-report-request-statistics :report="report" ref="requestStatistics"/>
|
||||
</el-card>
|
||||
<el-card id="errorLog" title="'errorLog'">
|
||||
<template v-slot:header >
|
||||
<span class="title">{{$t('report.test_error_log')}}</span>
|
||||
</template>
|
||||
<ms-report-error-log :report="report" ref="errorLog"/>
|
||||
</el-card>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import MsReportErrorLog from './components/ErrorLog';
|
||||
import MsReportRequestStatistics from './components/RequestStatistics';
|
||||
import MsReportTestOverview from './components/TestOverview';
|
||||
|
||||
import {checkoutTestManagerOrTestUser} from "@/common/js/utils";
|
||||
import MsPerformanceReportExport from "./PerformanceReportExport";
|
||||
import MsReportTitle from "../../common/components/MsReportTitle";
|
||||
|
||||
|
||||
export default {
|
||||
name: "MsPerformanceReportExport",
|
||||
components: {
|
||||
MsReportTitle,
|
||||
MsReportErrorLog,
|
||||
MsReportRequestStatistics,
|
||||
MsReportTestOverview,
|
||||
},
|
||||
props: ['report']
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
.report-export .el-card {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
</style>
|
|
@ -22,8 +22,8 @@
|
|||
@click="rerun(testId)">
|
||||
{{ $t('report.test_execute_again') }}
|
||||
</el-button>
|
||||
<el-button :disabled="isReadOnly" type="info" plain size="mini" @click="exportReport(reportName)">
|
||||
{{$t('report.export')}}
|
||||
<el-button :disabled="isReadOnly" type="info" plain size="mini" @click="handleExport(reportName)">
|
||||
{{$t('test_track.plan_view.export_report')}}
|
||||
</el-button>
|
||||
|
||||
<!--<el-button :disabled="isReadOnly" type="warning" plain size="mini">-->
|
||||
|
@ -65,26 +65,7 @@
|
|||
</el-tabs>
|
||||
</div>
|
||||
|
||||
<div class="report-export" v-show="reportExportVisible">
|
||||
<el-card id="testOverview">
|
||||
<template v-slot:header >
|
||||
<span class="title">{{$t('report.test_overview')}}</span>
|
||||
</template>
|
||||
<ms-report-test-overview :report="report" ref="testOverview"/>
|
||||
</el-card>
|
||||
<el-card id="requestStatistics" title="'requestStatistics'">
|
||||
<template v-slot:header >
|
||||
<span class="title">{{$t('report.test_request_statistics')}}</span>
|
||||
</template>
|
||||
<ms-report-request-statistics :report="report" ref="requestStatistics"/>
|
||||
</el-card>
|
||||
<el-card id="errorLog" title="'errorLog'">
|
||||
<template v-slot:header >
|
||||
<span class="title">{{$t('report.test_error_log')}}</span>
|
||||
</template>
|
||||
<ms-report-error-log :report="report" ref="errorLog"/>
|
||||
</el-card>
|
||||
</div>
|
||||
<ms-performance-report-export id="performanceReportExport" v-show="reportExportVisible" :report="report"/>
|
||||
|
||||
</el-card>
|
||||
<el-dialog :title="$t('report.test_stop_now_confirm')" :visible.sync="dialogFormVisible" width="30%">
|
||||
|
@ -113,11 +94,13 @@ import MsMainContainer from "../../common/components/MsMainContainer";
|
|||
import {checkoutTestManagerOrTestUser} from "@/common/js/utils";
|
||||
import {exportPdf} from "../../../../common/js/utils";
|
||||
import html2canvas from 'html2canvas';
|
||||
import MsPerformanceReportExport from "./PerformanceReportExport";
|
||||
|
||||
|
||||
export default {
|
||||
name: "PerformanceReportView",
|
||||
components: {
|
||||
MsPerformanceReportExport,
|
||||
MsReportErrorLog,
|
||||
MsReportLogDetails,
|
||||
MsReportRequestStatistics,
|
||||
|
@ -147,7 +130,6 @@ export default {
|
|||
websocket: null,
|
||||
dialogFormVisible: false,
|
||||
reportExportVisible: false,
|
||||
isShow: true,
|
||||
testPlan: {testResourcePoolId: null}
|
||||
}
|
||||
},
|
||||
|
@ -273,41 +255,25 @@ export default {
|
|||
this.initReportTimeInfo();
|
||||
window.console.log("socket closed.");
|
||||
},
|
||||
exportReport(name) {
|
||||
this.result = {loading: true};
|
||||
let result = this.result;
|
||||
result.loading = true;
|
||||
handleExport(name) {
|
||||
this.result.loading = true;
|
||||
this.reportExportVisible = true;
|
||||
let promises = [];
|
||||
let canvasList = new Array(3);
|
||||
let reset = this.exportReportReset;
|
||||
|
||||
this.$nextTick(function () {
|
||||
setTimeout(() => {
|
||||
promises.push(this.getCanvasPromise('testOverview', 0, canvasList));
|
||||
promises.push(this.getCanvasPromise('requestStatistics', 1, canvasList));
|
||||
promises.push(this.getCanvasPromise('errorLog', 2, canvasList));
|
||||
|
||||
Promise.all(promises).then(function (info) {
|
||||
exportPdf(name, canvasList);
|
||||
result.loading = false;
|
||||
html2canvas(document.getElementById('performanceReportExport'), {
|
||||
scale: 2
|
||||
}).then(function(canvas) {
|
||||
exportPdf(name, [canvas]);
|
||||
reset();
|
||||
});
|
||||
}, 1000);
|
||||
})
|
||||
});
|
||||
},
|
||||
exportReportReset() {
|
||||
this.reportExportVisible = false;
|
||||
this.isShow = true;
|
||||
},
|
||||
getCanvasPromise(id, index, canvasList) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
html2canvas(document.getElementById(id), {
|
||||
scale: 2
|
||||
}).then(function(canvas) {
|
||||
canvasList[index] = canvas;
|
||||
resolve('success');
|
||||
});
|
||||
});
|
||||
this.result.loading = false;
|
||||
},
|
||||
},
|
||||
created() {
|
||||
|
|
|
@ -33,8 +33,11 @@
|
|||
|
||||
<div class="container" ref="resume" id="app">
|
||||
<el-main>
|
||||
<div v-for="(item, index) in previews" :key="item.id" id="reportViewpp">
|
||||
<template-component :isReportView="true" :metric="metric" :preview="item" :index="index" ref="templateComponent"/>
|
||||
<div id="reportViewpp" :class="{'report-export' : reportExportVisible}">
|
||||
<ms-report-title v-if="reportExportVisible" :title="$t('report.test_plan_report')"/>
|
||||
<div v-for="(item, index) in previews" :key="item.id">
|
||||
<template-component :isReportView="true" :metric="metric" :preview="item" :index="index" ref="templateComponent"/>
|
||||
</div>
|
||||
</div>
|
||||
</el-main>
|
||||
</div>
|
||||
|
@ -52,10 +55,13 @@
|
|||
import RichTextComponent from "./TemplateComponent/RichTextComponent";
|
||||
import TestCaseReportTemplateEdit from "./TestCaseReportTemplateEdit";
|
||||
import TemplateComponent from "./TemplateComponent/TemplateComponent";
|
||||
import html2canvas from "html2canvas";
|
||||
import MsReportTitle from "../../../../../common/components/MsReportTitle";
|
||||
|
||||
export default {
|
||||
name: "TestCaseReportView",
|
||||
components: {
|
||||
MsReportTitle,
|
||||
TemplateComponent,
|
||||
TestCaseReportTemplateEdit,
|
||||
RichTextComponent, TestResultComponent, TestResultChartComponent, BaseInfoComponent
|
||||
|
@ -70,6 +76,7 @@
|
|||
reportId: '',
|
||||
metric: {},
|
||||
planId: '',
|
||||
reportExportVisible: false,
|
||||
componentMap: new Map(
|
||||
[
|
||||
[1, {name: this.$t('test_track.plan_view.base_info'), id: 1, type: 'system'}],
|
||||
|
@ -198,24 +205,44 @@
|
|||
}
|
||||
});
|
||||
},
|
||||
/*导出报告*/
|
||||
handleExport(name) {
|
||||
this.result.loading = true;
|
||||
this.reportExportVisible = true;
|
||||
let reset = this.exportReportReset;
|
||||
|
||||
let result = this.result;
|
||||
result.loading = true;
|
||||
|
||||
let promises = [];
|
||||
let canvasList = new Array(this.previews.length);
|
||||
|
||||
for (let item of this.$refs.templateComponent) {
|
||||
promises.push(item.getCanvas(canvasList));
|
||||
}
|
||||
|
||||
Promise.all(promises).then(function (info) {
|
||||
exportPdf(name, canvasList);
|
||||
result.loading = false;
|
||||
this.$nextTick(function () {
|
||||
setTimeout(() => {
|
||||
html2canvas(document.getElementById('reportViewpp'), {
|
||||
scale: 2
|
||||
}).then(function(canvas) {
|
||||
exportPdf(name, [canvas]);
|
||||
reset();
|
||||
});
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
},
|
||||
exportReportReset() {
|
||||
this.reportExportVisible = false;
|
||||
this.result.loading = false;
|
||||
},
|
||||
// handleExport(name) {
|
||||
//
|
||||
// let result = this.result;
|
||||
// result.loading = true;
|
||||
//
|
||||
// let promises = [];
|
||||
// let canvasList = new Array(this.previews.length);
|
||||
//
|
||||
// for (let item of this.$refs.templateComponent) {
|
||||
// promises.push(item.getCanvas(canvasList));
|
||||
// }
|
||||
//
|
||||
// Promise.all(promises).then(function (info) {
|
||||
// exportPdf(name, canvasList);
|
||||
// result.loading = false;
|
||||
// });
|
||||
// },
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -250,4 +277,18 @@
|
|||
text-align: right;
|
||||
}
|
||||
|
||||
.report-export {
|
||||
padding: 20px 30px;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.report-export >>> .template-component {
|
||||
width: 100%;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.report-export .el-card {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
|
@ -292,6 +292,9 @@ export default {
|
|||
add: 'Add Role',
|
||||
},
|
||||
report: {
|
||||
api_test_report: 'Api Test Report',
|
||||
load_test_report: 'Load Test Report',
|
||||
test_plan_report: 'Test Plan Report',
|
||||
recent: 'Recent Report',
|
||||
search_by_name: 'Search by Name',
|
||||
test_name: 'Test',
|
||||
|
|
|
@ -292,6 +292,9 @@ export default {
|
|||
add: '添加角色',
|
||||
},
|
||||
report: {
|
||||
api_test_report: '接口测试报告',
|
||||
load_test_report: '性能测试报告',
|
||||
test_plan_report: '测试计划报告',
|
||||
recent: '最近的报告',
|
||||
search_by_name: '根据名称搜索',
|
||||
test_name: '所属测试',
|
||||
|
|
|
@ -292,6 +292,9 @@ export default {
|
|||
add: '添加角色',
|
||||
},
|
||||
report: {
|
||||
api_test_report: '接口測試報告',
|
||||
load_test_report: '性能測試報告',
|
||||
test_plan_report: '測試計劃報告',
|
||||
recent: '最近的報告',
|
||||
search_by_name: '根據名稱搜索',
|
||||
test_name: '所屬測試',
|
||||
|
|
Loading…
Reference in New Issue