src/main/webapp/static/js/matCode/matCode.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/webapp/views/matCode/matCode.html | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/webapp/static/js/matCode/matCode.js
@@ -1,4 +1,5 @@ var pageCurr; var printMatCodeNos = []; layui.use(['table','laydate', 'form','upload'], function(){ var table = layui.table; var $ = layui.jquery; @@ -196,6 +197,11 @@ break; // 批量打印 case "btnPrintBatch": printMatCodeNos = []; var data = checkStatus.data; if (data.length === 0){ layer.msg('请选择打印数据'); } else { layer.open({ type: 1, title: '批量打印', @@ -203,11 +209,14 @@ shadeClose: true, content: $('#printDataDiv'), success: function(layero, index){ for (var i = 0; i<data.length;i++) { printMatCodeNos.push(data[i].matNo); } }, end: function () { } }); } break; } }); @@ -299,7 +308,7 @@ break; // 打印 case "btnPrint": console.log(data); printMatCodeNos = []; layer.open({ type: 1, title: '打印', @@ -308,6 +317,7 @@ content: $('#printDataDiv'), success: function(layero, index){ layer.iframeAuto(index); printMatCodeNos.push(data.matNo); }, end: function () { } @@ -316,48 +326,23 @@ } }); function startPrint(template, data) { let param = []; param.push("1902980-11/12"); console.log(param) $.ajax({ url: baseUrl+"/macCode/print/auth", headers: {'token': localStorage.getItem('token')}, data: {param: param}, method: 'POST', async: false, success: function (res) { if (res.code === 200){ console.log(res.data); } else if (res.code === 403){ top.location.href = baseUrl; }else { layer.msg(res.msg) } } }) console.log(data.field); // $('#template-preview-1').print(); } // 开始打印 form.on('submit(doPrint)', function (data) { let param = []; param.push("1902980-11/12"); console.log(param) var templateNo = data.field.selectTemplate; $.ajax({ url: baseUrl+"/macCode/print/auth", headers: {'token': localStorage.getItem('token')}, data: {param: param}, data: {param: printMatCodeNos}, method: 'POST', async: false, success: function (res) { if (res.code === 200){ console.log(res.data); var tpl = $("#templatePreview"+templateNo).html(); var template = Handlebars.compile(tpl); var html = template(res); $("#box").html(html); $("#box").print(); // $('#template-preview-'+templateNo).print(); } else if (res.code === 403){ top.location.href = baseUrl; }else { @@ -365,8 +350,7 @@ } } }) console.log(data.field); // $('#template-preview-1').print(); }) // 数据保存动作 src/main/webapp/views/matCode/matCode.html
@@ -132,9 +132,9 @@ <hr> <!--单选框--> <div class="layui-form-item" style="display: inline-block; margin-bottom: 10px"> <input type="radio" name="sex" value="男" title="模板一" checked=""> <input type="radio" name="sex" value="女" title="模板二"> <input type="radio" name="sex" value="禁" title="模板三"> <input type="radio" name="selectTemplate" value="1" title="模板一" checked=""> <input type="radio" name="selectTemplate" value="2" title="模板二"> <input type="radio" name="selectTemplate" value="3" title="模板三"> </div> <fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;text-align: left;"> <legend>打印预览</legend> @@ -204,9 +204,33 @@ </div> </div> <div id="box" style="display: block"> <!-- 模板引擎 --> <!-- 模板1 --> <script type="text/template" id="templatePreview1"> {{#each data}} <table class="contain" height="217" width="317" style="overflow: hidden;font-size: xx-small"> <tr> <td colspan="1" align="right" scope="col">条码</td> <td class="barcode"colspan="3" align="left" scope="col"> <img class="qrcode" src="/macCode/barcode/auth?param={{this.barcode}}" width="80%"> </td> </tr> <tr> <td align="right" width="25%">物料编码</td> <td align="right" width="25%">{{this.matNo}}</td> <td align="right" width="25%">物料名称</td> <td align="right" width="25%">{{this.matName}}</td> </tr> <tr> <td align="right" width="25%">物料单位</td> <td align="right" width="25%">{{this.str1}}</td> <td align="right" width="25%">物料规格</td> <td align="right" width="25%">{{this.str2}}</td> </tr> </table> {{/each}} </script> <!-- 模板2 --> <script type="text/template" id="templatePreview2">