• 打印设定区域


       在很多客户请求中,有些字据要进行打印,比如一些发票或一些具体的详情信息需要打印。具体直接上代码:

    页面代码:

     <div class="modal fade" id="myModal" tabindex="-1" role="dialog"
             aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog" style="background-color:#99cadb; ">
                <div class="modal-header" style="background-color: #99cadb;" >
                  <button class="btn btn-sm btn-primary" ng-click="doPrintdetail()">  打印数据</button>
                    <button type="button" class="close"
                            data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                </div>
                <!--startprint-->
                <div class="modal-dialog">
                <div class="modal-content">
    
                    <h2 class="modal-title" id="myModalLabel">
                        详情信息
                    </h2>
                    <div class="modal-body">
                        <table>
                            <tr><td></td><td>商户ID</td><td></td>
                     <td >{{currentCoupons.merchantRoleId}}</td></tr> <tr><td></td><td">优惠券类型</td><td></td>
    <td id="coupontypeTime" >免费{{currentCoupons.freeTime}}小时</td> <td id="coupontypeMoney">免费{{currentCoupons.money}}元</td> <td id="coupontypeallfree">全额免费</td> <td id="coupontypealltime">最大免费时长</td> </tr> </table> </div> </div> </div> <!--endprint--> </div> </div> </div>
    <!--startprint--> <!--endprint--> 一定要填写的,这是标志文件打印的起始

    js代码:
     $scope.doPrintdetail=function() {
            bdhtml=window.document.body.innerHTML;
            sprnstr="<!--startprint-->";
            eprnstr="<!--endprint-->";
            prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
            prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
            OpenWindow = window.open("");
            //OpenWindow.document.write("<link rel="stylesheet" type="text/css" href="/parkmanage-new/css/printdetail.css">");
            OpenWindow.document.body.innerHTML=prnhtml;
            OpenWindow.print();
        };
  • 相关阅读:
    [转][Navicat for MySQL系列]Navicat如何使用(二)
    [转]Syntax error on token "Invalid Character", delete this token 的解决
    [转] valuestack,stackContext,ActionContext.之间的关系
    [转]jquery后代和子元素的区别
    python中模块、包、库的区别和使用
    python函数对象
    list深拷贝和浅拷贝
    json中load和loads区别
    变量作用域
    正则里的.*和.*?区别
  • 原文地址:https://www.cnblogs.com/liziyou/p/6498981.html
Copyright © 2020-2023  润新知