health_parent/health_service/target/classes/static/toPDF.html
2024-07-03 20:01:25 +08:00

144 lines
6.3 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>武安市第一人民医院检验报告单</title>
<link rel="stylesheet" href="./toPDF.css">
<script src="./jquery.min.js"></script>
<script src="./html2canvas.js"></script>
<script src="./jspdf.js"></script>
</head>
<body>
<script>
function getParams(){
var _txt = ``
var para = {}
var href = location.search.replace("?","&").substr(1);
var tempArr = href.split("&");
tempArr.forEach(function (item){
var tempArr2 = item.split("=");
para[tempArr2[0]] = tempArr2[1]
})
$.ajax({
url:`https://www.wadyyy.com:9117/report/getListReportDetail?openid=${para.openid}&reportId=${para.reportId}`,
type:"GET",
success:function (res){
var data = res.data;
data.patSex = data.patSex == 1 ? "男" : "女";
_txt = `<div id="hesuanReportPage">
<div class="title">武安市第一人民医院检验报告单</div>
<div class="content">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td>姓名:${data.patName}</td>
<td>性别:${data.patSex}</td>
<td>年龄:${data.patAge}</td>
<td>样本类型:${data.specimenName}</td>
</tr>
<tr>
<td>科室:${data.applyDeptName}</td>
<td>住院号:</td>
<td></td>
<td>样本状态:${data.reportStatus}</td>
</tr>
</table>
<table class="jcx" width="100%" cellpadding="0" cellspacing="0">
<thead>
<th>检验项目</th>
<th>结果</th>
<th>参考区间</th>
<th>检验方法</th>
<th>检测限</th>
</thead>
<tbody>
<tr>
<td>${data.reportName}</td>
<td>${data.itemInfo.itemValue}</td>
<td>${data.itemInfo.itemRef}</td>
<td>${data.itemInfo.itemCnName}</td>
<td>500 copies/ml</td>
</tr>
</tbody>
</table>
<span class="zhang">
<img src="./image/zhang.jpg">
</span>
</div>
<div class="bottom">
<table width="100%" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>送检医生:</td>
<td>检验者:${data.applyDrName}</td>
<td>审核者:${data.reportDrName}</td>
</tr>
<tr>
<td>采集时间:${data.collectTime}</td>
<td>接送时间:${data.receiveTime}</td>
<td>报告时间:${data.reportTime}</td>
</tr>
</tbody>
</table>
<div class="tips">
1、本检测结果可能受到采样时间、采样部位及方法学局限性等因素影响结果需结合临床进行分析。 <br>
2、此报告仅对本次送检标本负责。 <br>
3、地址河北省邯郸市武安市矿建路与西环路交叉口西行500米 电话5857235
</div>
</div>
<div class="download">
<div class="button">下载PDF</div>
</div>
</div>`
$("body").append($(_txt))
}
})
}
function downLoadPdf(content){
var contentWidth = content.width();
var contentHeight = content.height();
var canvas = document.createElement("canvas")
canvas.width = contentWidth
canvas.height = contentHeight
var context = canvas.getContext("2d");
html2canvas(content,{
allowTaint:true,
scale:2 // 提升画面质量,但是会增加文件大小
}).then(function(canvas){
var pdfWidth = canvas.width;
var pdfHeight = canvas.height;
var pageHeight = pdfWidth / 592.28 * 841.89;
var leftHeight = pdfHeight;
var position = 0;
var imgWidth = 595.28;
var imgHeight = 595.28 / pdfWidth * pdfHeight;
var pageData = canvas.toDataURL("img/jpeg",1.0);
var pdf = new jsPDF('', 'pt', 'a4');
// 判断打印dom高度是否需要分页如果需要进行分页处理
if(leftHeight < pageHeight){
pdf.addImage(pageData,"JPEG",0,0,imgWidth,imgHeight)
}else{
while(leftHeight > 0){
pdf.addImage(pageData,"JPEG",0,position,imgWidth,imgHeight)
leftHeight -= pageHeight
position -= 841.89
if(leftHeight > 0){
pdf.addPage()
}
}
}
pdf.save("检验报告单.pdf")
})
}
getParams();
$(".button").on("click",function (){
downLoadPdf($('#hesuanReportPage'))
})
</script>
</body>
</html>