很多时候我们需要直接在前台页面进行打印内容
<div>
<form id="form1" >
<table border="1" cellpadding="0";cellspacing="0" style="width:870px"" id="last">
<tr>
<th colspan ="12" style='font-size: 16px'>明细</th>
</tr>
<tr>
<td style='text-align: center;font-size: 12px;width:90px' id="qin_time"></td>
<td style='text-align: center;font-size: 12px;width:100px' id="qothers_name"></td>
<td style='text-align: center;font-size: 12px;width:50px' id="qothers_type"></td>
<td style='text-align: center;font-size: 12px;width:40px' id="qothers_count"></td>
<td style='text-align: center;font-size: 12px;width:40px' id="qothers_unit"></td>
<td style='text-align: center;font-size: 12px;width:40px' id="qothers_standard"></td>
<td style='text-align: center;font-size: 12px;width:40px' id="qothers_price"></td>
<td style='text-align: center;font-size: 12px;width:40px' id="qtotal_price"></td>
<td style='text-align: center;font-size: 12px;width:40px' id="qnototal_price"></td>
<td style='text-align: center;font-size: 12px;width:40px' id="qtax_rate"></td>
<td style='text-align: center;font-size: 12px;width:150px' id="qmanufacturer_name"></td>
<td style='text-align: center;font-size: 12px;width:90px' id="qstorage_name"></td>
<td style='text-align: center;font-size: 12px;width:60px' id="qpather"></td>
<td style='text-align: center;font-size: 12px;width:50px' id="qinput_person"></td>
</tr>
</table>
</form>
</div>
JS页面代码如下
var temp="";
var LODOP;
function CreateOneFormPage(){
LODOP=getLodop();
var strBodyStyle="<style>table,td { border: 1 solid #000000;border-collapse:collapse }</style>";
var strFormHtml=strBodyStyle+"<body>"+document.getElementById("form1").innerHTML+"</body>";
LODOP.ADD_PRINT_HTM(15,15,700,700,strFormHtml);
myrefresh();
};
function myrefresh(){
window.location.reload();
}
function prn1_preview() {
var current=new Date();
$("#qin_time").text("时间");
$("#qothers_name").text("物资名称");
$("#qothers_type").text("物资类别");
$("#qothers_count").text("数量");
$("#qothers_unit").text("单位");
$("#qothers_standard").text("规格型号");
$("#qothers_price").text("单价");
$("#qtotal_price").text("总价");
$("#qnototal_price").text("不含税价");
$("#qtax_rate").text("税额");
$("#qmanufacturer_name").text("供应商");
$("#qstorage_name").text("存放位置");
$("#qpather").text("送货人");
$("#qinput_person").text("录入人员");
var items = $("#other_rows").datagrid('getRows');
for(var i=0;i<items.length-1;i++){
temp+="<tr >";
temp+="<td style='text-align: center' >"+items[i].in_time+"</td>";
temp+="<td style='text-align: center'>"+items[i].others_name+"</td>";
temp+="<td style='text-align: center' >"+items[i].others_type+"</td>";
temp+="<td style='text-align: center'>"+items[i].others_count+"</td>";
temp+="<td style='text-align: center'>"+items[i].others_unit+"</td>";
temp+="<td style='text-align: center'>"+items[i].others_standard+"</td>";
temp+="<td style='text-align: center'>"+items[i].others_price+"</td>";
temp+="<td style='text-align: center'>"+items[i].total_price+"</td>";
temp+="<td style='text-align: center'>"+items[i].no_total_price+"</td>";
temp+="<td style='text-align: center'>"+items[i].tax_rate+"</td>";
temp+="<td style='text-align: center'>"+items[i].manufacturer_name+"</td>";
temp+="<td style='text-align: center'>"+items[i].storage_name+"</td>";
temp+="<td style='text-align: center'>"+items[i].pather+"</td>";
temp+="<td style='text-align: center'>"+items[i].input_person+"</td>";
temp+="</tr>";
}
$('#last').append(temp);
$.messager.confirm('Confirm','是否打印?',function(r){
if (r){
CreateOneFormPage();
LODOP.PREVIEW();
}
});
};
function print(){
prn1_preview();
}
这里面可能会用到插件,需要的可以联系我
<script type="text/javascript" src="<%=path%>/js/LodopFuncs.js"></script>