| | |
| | | var pageCurr; |
| | | var printMatCodeNos = []; |
| | | layui.use(['table','laydate', 'form','upload'], function(){ |
| | | var table = layui.table; |
| | | var $ = layui.jquery; |
| | |
| | | break; |
| | | // 批量打印 |
| | | case "btnPrintBatch": |
| | | layer.open({ |
| | | type: 1, |
| | | title: '批量打印', |
| | | area: ['500px'], |
| | | shadeClose: true, |
| | | content: $('#printDataDiv'), |
| | | success: function(layero, index){ |
| | | |
| | | }, |
| | | end: function () { |
| | | } |
| | | }); |
| | | printMatCodeNos = []; |
| | | var data = checkStatus.data; |
| | | if (data.length === 0){ |
| | | layer.msg('请选择打印数据'); |
| | | } else { |
| | | layer.open({ |
| | | type: 1, |
| | | title: '批量打印', |
| | | area: ['500px'], |
| | | shadeClose: true, |
| | | content: $('#printDataDiv'), |
| | | success: function(layero, index){ |
| | | for (var i = 0; i<data.length;i++) { |
| | | printMatCodeNos.push(data[i].matNo); |
| | | } |
| | | }, |
| | | end: function () { |
| | | } |
| | | }); |
| | | } |
| | | break; |
| | | } |
| | | }); |
| | |
| | | break; |
| | | // 打印 |
| | | case "btnPrint": |
| | | console.log(data); |
| | | printMatCodeNos = []; |
| | | layer.open({ |
| | | type: 1, |
| | | title: '打印', |
| | |
| | | content: $('#printDataDiv'), |
| | | success: function(layero, index){ |
| | | layer.iframeAuto(index); |
| | | printMatCodeNos.push(data.matNo); |
| | | }, |
| | | end: function () { |
| | | } |
| | |
| | | } |
| | | }); |
| | | |
| | | 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 { |
| | |
| | | } |
| | | } |
| | | }) |
| | | console.log(data.field); |
| | | // $('#template-preview-1').print(); |
| | | |
| | | }) |
| | | |
| | | // 数据保存动作 |