目前所做的web系统开发当中,有着明确的需求需要打印,需要与设备相结合。
团队使用的是jquery中的jqprint插件
$("#print").click(function(){
$("#loadAllPurchaseCommodityDetails").jqprint({debug : true});
});
代码就这么一点点,贴上
loadAllPurchaseCommodityDetails
的一些代码
<!-- 以下是like 的模态框 -->
<div class="modal fade" id="cusModal-like" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="dialog">
<form class="form-horizontal" id="#form-cusLike">
<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>
</div>
<div class="modal-body">
<table class="table table-hover" id="loadAllPurchaseCommodityDetails">
<thead>
<tr>
<th data-field="sodDetailId" data-visible="false" data-sortable="true">
申购单明细ID
</th>
<th data-field="name">
商品名称
</th>
<th data-field="number">
商品数量
</th>
<th data-field="code">
商品条形码
</th>
<th data-field="soSupplier">
供应商姓名
</th>
<th data-field="remark">
商品备注
</th>
</tr>
</thead>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
<button type="button" class="btn btn-primary" id="print">打印</button>
</div>
</div>
</form>
</div>
</div>
还是挺ok的,在使用期间可能会遇到一些问题比如说点击打印按钮没反应,这时候打开开发者工具会看到一些jqprint is not a function 或是cannot read property ‘opera’ of
undefined 之类的问题,导入这俩js文件
<script src="js/plugins/jquery.jqprint-0.3.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.1.0.js"></script>
以上
有一些小问题,比如点击打印的时候,界面会出现一小块区域浮现打印的数据,而且取消不了,还有一个是需要跳转到新界面点击打印才行。
这块已经交给队伍里的前端工程师,希望能尽早修改源码达成想要的效果。
这个插件是开源