Files
SIPAIIS_WMS_JSSW/WebRoot/jsp/equipment/equipmentCardNewListForoutQRCode.jsp
2026-01-16 14:13:44 +08:00

173 lines
6.8 KiB
Plaintext
Raw Permalink 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.

<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ page import="com.sipai.entity.base.ServerObject"%>
<%@ taglib uri="http://www.springsecurity.org/jsp" prefix="security"%>
<!DOCTYPE html>
<!-- <html lang="zh-CN"> -->
<!-- BEGIN HEAD -->
<head>
<title><%= ServerObject.atttable.get("TOPTITLE")%></title>
<!-- 引用页头及CSS页-->
<jsp:include page="/jsp/inc.jsp"></jsp:include>
<!-- 下载PDF-->
<script type="text/javascript" src="<%=request.getContextPath()%>/node_modules/pdf/html2canvas.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/node_modules/pdf/jsPDF-1.3.2/dist/jspdf.debug.js"></script>
<script type="text/javascript">
var nowpage=1;
var checkedIds='&checkedIds=${param.eqids}';
$(function() {
getlist();
});
var totalpages="";
function getlist(){
var page="&page="+nowpage;
var rows="&rows=100";
$.post(ext.contextPath + '/equipment/getList.do',checkedIds+page+rows, function(datas) {
totalpages=Math.ceil(datas.total/24);
var data=datas.rows;
if(data!=''){
var html="";
for(var i=0;i<data.length;i++){
var eqId=data[i].id;
var eqNo=data[i].equipmentcardid;
var eqName=data[i].equipmentname;
html+="<div style='float:left;width:50%;margin-bottom:115px;'>";
html+="<div style='float:left;width:100%;text-align: center;font-weight: bold;'>"+eqName+"</div>";
html+="<div style='float:left;width:100%;text-align: center;font-weight: bold;'>"+eqNo+"</div>";
html+="<div id='"+eqId+"' style='float:left;width:100%;text-align: center;'></div>";
html+="</div>";
}
$('#print').html(html);
for(var i=0;i<data.length;i++){
var eqId=data[i].id;
$("#"+eqId+"").qrcode({
render : "canvas",
width : 150, //设置宽度
height : 150, //设置高度
typeNumber : -1, //计算模式
background : "#ffffff",//背景颜色
foreground : "#000000", //前景颜色
text: eqId
});
}
$('#pageSt').text(nowpage+"/"+totalpages);
}else{
nowpage=0;
totalpages=0;
$('#pageSt').text(nowpage+"/"+totalpages);
}
},'json')
}
function lastpage(){
if(totalpages==0){
alert("当前无数据");
return;
}
if(nowpage==1){
nowpage=totalpages;
}else{
nowpage--;
}
getlist();
}
function nextpage(){
if(totalpages==0){
alert("当前无数据");
return;
}
if(nowpage==totalpages){
nowpage=1;
}else{
nowpage++;
}
getlist();
}
function printPDF(){
if(confirm("您确认下载该PDF文件吗?")){
var pdfName="台账二维码"+nowpage;
var target = $('#print');
// var pdf = new jsPDF('p','pt','a4');
// // 设置打印比例 越大打印越小
// pdf.internal.scaleFactor = 1;
// var options = {
// pagesplit: true, //设置是否自动分页
// "background": '#FFFFFF' //如果导出的pdf为黑色背景需要将导出的html模块内容背景 设置成白色。
// };
// var printHtml = $('#print'); // 页面某一个div里面的内容通过id获取div内容
// pdf.addHTML(printHtml,15, 15, options,function() {
// pdf.save(pdfName+'.pdf');
// });
if(pdfName==''||pdfName==undefined) pdfName= getNowFormatDate();
html2canvas(target, {
onrendered:function(canvas) {
var contentWidth = canvas.width;
var contentHeight = canvas.height;
//一页pdf显示html页面生成的canvas高度;
var pageHeight = contentWidth / 595.28 * 841.89;
//未生成pdf的html页面高度
var leftHeight = contentHeight;
//页面偏移
var position = 0;
//a4纸的尺寸[595.28,841.89]html页面生成的canvas在pdf中图片的宽高
var imgWidth = 595.28;
var imgHeight = 591.28/contentWidth * contentHeight;
var pageData = canvas.toDataURL('image/jpeg', 1.0);
var pdf = new jsPDF('', 'pt', 'a4');
//有两个高度需要区分一个是html页面的实际高度和生成pdf的页面高度(841.89)
//当内容未超过pdf一页显示的范围无需分页
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 > 10) {
pdf.addPage();
}
}
}
pdf.save(pdfName+".pdf");
}
})
}
}
</script>
</head>
<body >
<div class="wrapper">
<!-- Main content -->
<section class="content container-fluid">
<!-- 界面提醒div强制id为alertDiv -->
<div id="alertDiv"></div>
<div style="float:left;width: 100%;height: 50px;">
<div style="float:left;width:120px;height: 50px;padding-left:10px;padding-top:5px;">
<button type="button" class="btn btn-default btn-sm" onclick="printPDF();"><i
class="fa fa-file-pdf-o"></i> 下载PDF
</button>
</div>
<div style="float:right;width:130px;height: 50px;padding-right:10px;padding-top:5px;">
<div style="float:left;width:35px;height: 50px;text-align: left;"><button type="button" class="btn btn-default btn-sm pull-left" onclick="lastpage();"><</button></div>
<div style="float:left;width:50px;height: 50px;text-align: center;"><span id="pageSt" style="line-height: 30px;"></span></div>
<div style="float:left;width:35px;height: 50px;text-align: right;"><button type="button" class="btn btn-default btn-sm pull-right" onclick="nextpage();">></button></div>
</div>
</div>
<div id="print" name="print" style="float:left;width: 100%;background-color:#FFFFFF;"></div>
</section>
<!-- /.content -->
</div>
</body>