您的位置:首页 > 运维架构

关于lodop打印控件的使用

2018-03-24 14:47 134 查看
 <script type="text/javascript" language="javascript" src="${request.contextPath}/static/lodop/LodopFuncs.js"></script>
<object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width="0" height="0"> 
  <embed id="LODOP_EM" type="application/x-print-lodop" width="0" height="0"></embed>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<div class="loading-list" id="printdiv">
    <p style="text-align: center;font-size:20px;">XXX物流公司装车清单<p>
    <p> <span>司机:李洪峰   18215645555</span>    <span>时间:2018-02-16</span></p>
    <p><span>车辆:鄂B 15555</span>  <span>线路:江夏-玖通达</span>  <span>专线公司:3家</span></p>

<table border="1px" width="100%" id="infotable" cellspacing="0px" style="border-collapse:collapse">
<tr>
<th width="10%">专线名称</th>
<th width="14%">订单编号</th>
<th width="8%">货物名称</th>
<th width="10%">线路</th>
<th width="8%">件数</th>
<th width="10%">申明价值</th>
<!-- <th width="10%">投保诉求</th> -->
<th width="10%">发货人</th>
<!-- <th width="10%">电话</th>
<th width="10%">签收栏</th> -->
</tr>
</table>

</div>
   <input type="button" onclick="prtTest()" value="打印预览 ">
</body>
<script language="javascript" type="text/javascript">

var a;
    var LODOP; //声明为全局变量 
    function prtTests() {
        PrintMytable();
        LODOP.PREVIEW();
    };
    function prtTest() 
    {
        PrintMytable();
        LODOP.PRINTA();
    };

    function PrintMytable() {
        LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
        LODOP.PRINT_INIT("银燕公司宽带收费明细");
        LODOP.SET_PRINT_PAGESIZE(2,'210mm', '297mm', "A4");
        LODOP.SET_PRINT_MODE('PRINT_PAGE_PERCENT',"Width:90%;Height:80%");//设置打印内容的自动缩放
        LODOP.SET_PRINT_MODE('AUTO_CLOSE_PREWINDOW',1);//设置设置完打印后 是否关闭预览窗口;
        LODOP.ADD_PRINT_HTM(60,40,"100%","100%", document.getElementById("printdiv").innerHTML);
    };    
   
</script> 
<script>
$(document).ready(function () {

// $("#infotable").append(htmls);
$.ajax({
type: "POST",
         url: "${request.contextPath}/pdcallcenter/indexinfo",
         dataType: "json",
         success: function (data) {
        var sa=data.compangid;
        var infos=data.infos;
        var htmls="";
        //for(var name in infos)是在js里面 循环遍历MAP数据的方法name就是箱单与一个key 
        for(var name in infos){
         
        var temp=infos[name];//是获取到Key对应的value
        for(var i=0;i<sa.length;i++){
        var names=sa[i].specialname;
        if(names==name){
        for(var j=0;j<=temp.length;j++){
        if(j==temp.length){
        htmls+="<tr><td>合计共"+j+"运单</td><td></td><td></td><td></td><td></td><td></td></tr>"
        }else{
        var specialname=temp[j].specialname;
            var ordernumber=temp[j].ordernumber;
            var goodsname=temp[j].goodsname;
            var line=temp[j].line;
            var goodsnumber=temp[j].goodsnumber;
            var shengvalue=temp[j].shengvalue;
            var fhr=temp[j].fhr;
            if(j==0){
            htmls += "<tr><td rowspan='"+rows+"'>"+specialname+"</td> <td>"+ordernumber+"</td><td>"+goodsname+"</td><td>"+line+"</td><td>"+goodsnumber+"</td><td>"+shengvalue+"</td> <td>"+fhr+"</td></tr>"
            }else{
            htmls += "<tr> <td>"+ordernumber+"</td><td>"+goodsname+"</td><td>"+line+"</td><td>"+goodsnumber+"</td><td>"+shengvalue+"</td> <td>"+fhr+"</td></tr>"
               }
            }
        }
        } 
            }
}
        $("#infotable").append(htmls);//拼接html;
       
         },
         error: function () {
         }
  })

});
</script>

</htm
4000
l>

需要下载lodop打印控件然后安装并放在资源文件夹里面 方便页面的调用
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  打印