| | |
| | | <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all"> |
| | | <link rel="stylesheet" type="text/css" href="../../js/HiPrint/css/hiprint.css?t=' + Math.random() + '" /> |
| | | <link rel="stylesheet" type="text/css" href="../../js/HiPrint/css/print-lock.css" /> |
| | | <link rel="stylesheet" media="print" href="../../js/HiPrint/css/print-lock.css" /> |
| | | <!-- <link rel="stylesheet" type="text/css" href="../../js/HiPrint/css/bootstrap.min.css" > --> |
| | | <style> |
| | | .layui-form-label { |
| | |
| | | <body> |
| | | <div class="layui-card"> |
| | | <input type="hidden" id="printData" name="printData"> |
| | | <input type="hidden" id="printType" name="printType"> |
| | | <div class="row"> |
| | | |
| | | <!--左侧div--> |
| | |
| | | <script src="../../js/jquery-3.5.1.min.js"></script> |
| | | <script src="../../js/jquery.cookie.js"></script> |
| | | <script src="../../js/hiprint/content/bootstrap.min.js"></script> |
| | | <script src="../../js/HiPrint/hiprint.bundle.js?t=' + Math.random() + '"></script> |
| | | <script src="../../js/HiPrint/polyfill.min.js"></script> |
| | | <script src="../../js/HiPrint/plugins/jquery.minicolors.min.js"></script> |
| | | <script src="../../js/HiPrint/plugins/JsBarcode.all.min.js"></script> |
| | | <script src="../../js/HiPrint/plugins/qrcode.js"></script> |
| | | <script src="../../js/HiPrint/hiprint.bundle.js"></script> |
| | | <script src="../../js/HiPrint/plugins/jquery.hiwprint.js"></script> |
| | | <script src="../../js/HiPrint/plugins/socket.io.js"></script> |
| | | <!-- <script src="../../js/HiPrint/plugins/socket.io.js"></script> --> |
| | | <script src="../../js/HiPrint/plugins/config-etype-provider.js"></script> |
| | | <script src="../../js/HiPrint/plugins/jspdf/canvas2image.js"></script> |
| | | <script src="../../js/HiPrint/plugins/jspdf/canvg.min.js"></script> |
| | | <script src="../../js/HiPrint/plugins/jspdf/html2canvas.min.js"></script> |
| | | <script src="../../js/HiPrint/plugins/jspdf/jspdf.min.js"></script> |
| | | <script src="../../js/HiPrint/plugins/print-data-list.js"></script> |
| | | <script src="../../js/HiPrint/hiprint.config.js"></script> |
| | | <script src="../../layuiadmin/layui/layui.js"></script> |
| | | <script src="../../js/public.js"></script> |
| | | <script> |
| | | var configPrintJson; |
| | | |
| | | var datalist = []; |
| | | //初始化打印插件渲染 |
| | | $(".hiprintEpContainer").html(""); //清除div内容 |
| | | |
| | | hiprint.init({ |
| | | providers: [new configElementTypeProvider()] |
| | | }); |
| | | //设置左侧拖拽事件 |
| | | hiprint.PrintElementTypeManager.build('.hiprintEpContainer', 'testModule'); |
| | | |
| | | |
| | | var hiprintTemplate; |
| | | // var JsonData = JSON.parse('{"panels":[{"index":0,"height":50,"width":50,"paperHeader":0,"paperFooter":141.73228346456693,"printElements":[{"tid":"configModule.SkuName","options":{"left":9,"top":12,"height":9.75,"width":120}},{"tid":"configModule.SkuNo","options":{"left":9,"top":37.5,"height":78,"width":120,"textType":"qrcode"}}],"paperNumberLeft":178.5,"paperNumberTop":123}]}') |
| | | var JsonData = {}; |
| | | synData(IP + "/sys/GetDefaultPrintTemplate", {}, 'get', function (res) { |
| | | if (res.code == 0) { //成功 |
| | | JsonData = JSON.parse(res.data.PositionJson); |
| | | $("#customWidth").val(JsonData.panels[0].width); |
| | | $("#customHeight").val(JsonData.panels[0].height); |
| | | hiprintTemplate = new hiprint.PrintTemplate({ |
| | | template: JsonData,//模板JSON |
| | | settingContainer: '#PrintElementOptionSetting', |
| | | paginationContainer: '.hiprint-printPagination' |
| | | }); |
| | | setTimeout(function () { |
| | | var printType = $("#printType").val(); |
| | | datalist = getPrintDataList()(printType); |
| | | synData(IP + "/sys/GetDefaultPrintTemplate?Type=" + printType, {}, 'get', function (res) { |
| | | if (res.code == 0) { //成功 |
| | | hiprint.init({ |
| | | providers: [new configElementTypeProvider()] |
| | | }); |
| | | //设置左侧拖拽事件 |
| | | hiprint.PrintElementTypeManager.build('.hiprintEpContainer', 'testModule'); |
| | | JsonData = JSON.parse(res.data.PositionJson); |
| | | $("#customWidth").val(JsonData.panels[0].width); |
| | | $("#customHeight").val(JsonData.panels[0].height); |
| | | hiprintTemplate = new hiprint.PrintTemplate({ |
| | | template: JsonData,//模板JSON |
| | | settingContainer: '#PrintElementOptionSetting', |
| | | paginationContainer: '.hiprint-printPagination' |
| | | }); |
| | | |
| | | //打印设计 |
| | | hiprintTemplate.design('#hiprint-printTemplate'); |
| | | //打印设计 |
| | | hiprintTemplate.design('#hiprint-printTemplate'); |
| | | |
| | | //打印 |
| | | setTimeout(function () { |
| | | //打印 |
| | | //这里获取上级页面的printData数据打印 |
| | | // var printData = deepClone(parent.printData); |
| | | var printData = JSON.parse($("#printData").val()); |
| | | hiprintTemplate.print(printData,'打印'); |
| | | hiprintTemplate.print(printData, '打印'); |
| | | parent.layer.closeAll(); |
| | | }, 100); |
| | | } |
| | | else //不成功 |
| | | { |
| | | layer.msg(res.msg, { |
| | | icon: 2, |
| | | time: 2000 //2秒关闭(如果不配置,默认是3秒) |
| | | }, function () { parent.layer.closeAll(); }); |
| | | } |
| | | }); |
| | | } |
| | | else //不成功 |
| | | { |
| | | layer.msg(res.msg, { |
| | | icon: 2, |
| | | time: 2000 //2秒关闭(如果不配置,默认是3秒) |
| | | }, function () { parent.layer.closeAll(); }); |
| | | } |
| | | }); |
| | | }, 100); |
| | | |
| | | |
| | | |
| | | $('#directPrint').click(function () { |
| | | hiprintTemplate.print(printData); |
| | | }); |
| | | var datalist = []; |
| | | </script> |
| | | </body> |
| | | |