当前位置:   article > 正文

Bootstrap prinThis插件 打印多张二维码并动态添加数据

bootstrap print

效果图:

之前有介绍过这个插件,当时只有一个二维码这次,多增加了一点,顺便上传,使用就不多说了,看之前的,附上地址:http://blog.csdn.net/qq_34117825/article/details/56015664,不多说上干货:

jsp:

  1. <!-- 二维码弹出框 -->
  2. <div class="modal fade" id="myModal_qrcode" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  3. <div class="modal-dialog" role="document">
  4. <div class="modal-content">
  5. <div class="modal-header">
  6. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  7. <span aria-hidden="true">×</span>
  8. </button>
  9. <h4 class="modal-title" id="myModalLabel">二维码</h4>
  10. </div>
  11. <div class="modal-body">
  12. <center>
  13. <div id="qrcode"></div>
  14. <form id="nameIp">
  15. <table>
  16. <tbody>
  17. <tr>
  18. <td>
  19. <label class="col-sm-4 control-label" for="equ_name_qrcode"><h7>设备名称:</h7></label>
  20. <div class="col-sm-8">
  21. <input class="form-control" id="equ_name_qrcode" type="text" name="equ_name_qrcode" readonly="readonly"/>
  22. </div>
  23. </td>
  24. <td>
  25. <label class="col-sm-4 control-label" for="equ_ip_qrcode"><h7>设备IP:</h7></label>
  26. <div class="col-sm-8">
  27. <input class="form-control" id="equ_ip_qrcode" type="text" name="equ_ip_qrcode" readonly="readonly"/>
  28. </div>
  29. </td>
  30. </tr>
  31. </tbody>
  32. </table>
  33. </form>
  34. </center>
  35. </div>
  36. <div class="modal-footer">
  37. <button type="button" class="btn btn-default" data-dismiss="modal">
  38. <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>关闭
  39. </button>
  40. <button type="button" id="btn_print" class="btn btn-primary" data-dismiss="modal">
  41. <span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>打印
  42. </button>
  43. </div>
  44. </div>
  45. </div>
  46. </div>
js:

  1. $("#btn_print").click(function(event) {
  2. /* Act on the event */
  3. $("#qrcode,#nameIp").printThis({
  4. debug: false,
  5. importCSS: true,
  6. importStyle: true,
  7. printContainer: true,
  8. // loadCSS: "/receiverShow/bootstrap/css/printThisStyleByQrcode.css",
  9. pageTitle: "二维码",
  10. removeInline: true,
  11. printDelay: 333,
  12. header: null,
  13. footer: null,
  14. formValues: true,
  15. });
  16. });
  17. $("#button_printAll").click(function(event) {
  18. /* Act on the event */
  19. $("#qrcode").html("");
  20. var obj=$("#grid-table").jqGrid("getRowData");
  21. var len = obj.length;
  22. jQuery(obj).each(function(i){
  23. $("#content").val("公司名称:"+this.companyName+","+"设备IP:"+this.deviceIP+","+"公司ID:"+this.companyId);
  24. // 创建二维码
  25. qrcode = new QRCode(document.getElementById("qrcode"), {
  26. width : 150,//设置宽高
  27. height : 150
  28. });
  29. qrcode.makeCode(document.getElementById("content").value);
  30. if (i < len - 1){
  31. $("#qrcode").append('<form id="addNameIp"><table><tbody><tr><td><label class="col-sm-4 control-label" for="equ_name_qrcode"><h7>设备名称:</h7></label><div class="col-sm-8"><input class="form-control" id="name'+this.id+'" type="text" name="name'+this.id+'" readonly="readonly"/></div></td><td><label class="col-sm-4 control-label" for="equ_ip_qrcode"><h7>设备IP:</h7></label><div class="col-sm-8"><input class="form-control" id="Ip'+this.id+'" type="text" name="Ip'+this.id+'" readonly="readonly"/></div></td></tr></tbody></table></form>');
  32. $("#name"+this.id).val(this.deviceName);
  33. $("#Ip"+this.id).val(this.deviceIP);
  34. } else{
  35. $("#equ_name_qrcode").val(this.deviceName);
  36. $("#equ_ip_qrcode").val(this.deviceIP);
  37. }
  38. });
  39. $("#myModal_qrcode").modal();
  40. });
如果,打印的页面中input框没有数据,注意把formValues: true,还有input框,添加name属性,不然打印中也不会有值~


声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号