赞
踩
效果图:
之前有介绍过这个插件,当时只有一个二维码这次,多增加了一点,顺便上传,使用就不多说了,看之前的,附上地址:http://blog.csdn.net/qq_34117825/article/details/56015664,不多说上干货:
jsp:
- <!-- 二维码弹出框 -->
- <div class="modal fade" id="myModal_qrcode" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
- <div class="modal-dialog" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
- <span aria-hidden="true">×</span>
- </button>
- <h4 class="modal-title" id="myModalLabel">二维码</h4>
- </div>
- <div class="modal-body">
- <center>
- <div id="qrcode"></div>
- <form id="nameIp">
- <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="equ_name_qrcode" type="text" name="equ_name_qrcode" 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="equ_ip_qrcode" type="text" name="equ_ip_qrcode" readonly="readonly"/>
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </form>
- </center>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal">
- <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>关闭
- </button>
- <button type="button" id="btn_print" class="btn btn-primary" data-dismiss="modal">
- <span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>打印
- </button>
- </div>
- </div>
- </div>
- </div>

js:
- $("#btn_print").click(function(event) {
- /* Act on the event */
- $("#qrcode,#nameIp").printThis({
- debug: false,
- importCSS: true,
- importStyle: true,
- printContainer: true,
- // loadCSS: "/receiverShow/bootstrap/css/printThisStyleByQrcode.css",
- pageTitle: "二维码",
- removeInline: true,
- printDelay: 333,
- header: null,
- footer: null,
- formValues: true,
- });
- });
- $("#button_printAll").click(function(event) {
- /* Act on the event */
- $("#qrcode").html("");
- var obj=$("#grid-table").jqGrid("getRowData");
- var len = obj.length;
- jQuery(obj).each(function(i){
- $("#content").val("公司名称:"+this.companyName+","+"设备IP:"+this.deviceIP+","+"公司ID:"+this.companyId);
- // 创建二维码
- qrcode = new QRCode(document.getElementById("qrcode"), {
- width : 150,//设置宽高
- height : 150
- });
- qrcode.makeCode(document.getElementById("content").value);
- if (i < len - 1){
- $("#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>');
- $("#name"+this.id).val(this.deviceName);
- $("#Ip"+this.id).val(this.deviceIP);
- } else{
- $("#equ_name_qrcode").val(this.deviceName);
- $("#equ_ip_qrcode").val(this.deviceIP);
- }
- });
- $("#myModal_qrcode").modal();
- });

如果,打印的页面中input框没有数据,注意把formValues: true,还有input框,添加name属性,不然打印中也不会有值~
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。