基于MVC+EasyUI的web开发框架之使用云打印控件C(2)

我们设计好套打页面内容,如下所示。

设计好的内容,我们可以把它们转换为页面里面的JS代码如下所示。

<script src="https://www.jb51.net/Content/JQueryTools/LODOP/CheckActivX.js"></script> <script type="text/javascript"> var LODOP; //声明为全局变量 function Preview() {//打印预览 LODOP = getLodop(); LODOP.PRINT_INITA(-1, -1, 824, 1129, "运单套打"); CreateLicenseData(); LODOP.SET_PREVIEW_WINDOW(2, 0, 0, 800, 600, ""); LODOP.SET_PRINT_PAGESIZE(1, 0, 0, "A4"); LODOP.PREVIEW(); }; function Setup() {//打印维护 LODOP = getLodop(); LODOP.PRINT_INITA(-1, -1, 824, 1129, "运单套打"); CreateLicenseData(); LODOP.PRINT_SETUP(); }; function Design() {//打印设计 LODOP = getLodop(); LODOP.PRINT_INITA(-1, -1, 824, 1129, "运单套打"); CreateLicenseData(); LODOP.PRINT_DESIGN(); }; function CreateLicenseData() { if (printID != undefined && printID != '') { //使用同步方式,使得联动的控件正常显示 $.ajaxSettings.async = false; //首先用户发送一个异步请求去后台实现方法 $.getJSON("/BillDetail/FindByID?id=" + printID, function (info) { LODOP.ADD_PRINT_SETUP_BKIMG("<img src='https://www.jb51.net/Content/Template/空白套打模板.png'/>"); LODOP.SET_SHOW_MODE("BKIMG_IN_PREVIEW", true);//预览包含背景 LODOP.SET_SHOW_MODE("BKIMG_PRINT", true);//打印内容包含背景 LODOP.ADD_PRINT_BARCODE(78, 441, 262, 56, "128C", info.FenyunDanhao); LODOP.ADD_PRINT_BARCODE(684, 441, 262, 56, "128C", info.FenyunDanhao); LODOP.ADD_PRINT_TEXT(186, 287, 277, 39, info.Shou_Com); LODOP.SET_PRINT_STYLEA(0, "FontSize", 12); LODOP.ADD_PRINT_TEXT(236, 378, 186, 28, info.Shou_Name); LODOP.SET_PRINT_STYLEA(0, "FontSize", 12); LODOP.ADD_PRINT_TEXT(276, 283, 284, 67, info.Shou_Dizhi); LODOP.SET_PRINT_STYLEA(0, "FontSize", 12); LODOP.ADD_PRINT_TEXT(362, 306, 254, 30, info.Shou_Phone); LODOP.SET_PRINT_STYLEA(0, "FontSize", 12); LODOP.ADD_PRINT_TEXT(404, 319, 51, 30, info.Jianshu); LODOP.SET_PRINT_STYLEA(0, "FontSize", 12); LODOP.ADD_PRINT_TEXT(400, 476, 95, 31, info.Zhongliang); LODOP.SET_PRINT_STYLEA(0, "FontSize", 12); LODOP.ADD_PRINT_TEXT(187, 33, 227, 39, info.Fa_Gongsi); LODOP.SET_PRINT_STYLEA(0, "FontSize", 12); LODOP.ADD_PRINT_TEXT(277, 33, 230, 65, info.Fa_Dizhi); LODOP.SET_PRINT_STYLEA(0, "FontSize", 12); LODOP.ADD_PRINT_TEXT(364, 37, 227, 25, info.Fa_Phone); LODOP.SET_PRINT_STYLEA(0, "FontSize", 12); LODOP.ADD_PRINT_TEXT(410, 37, 226, 26, info.Pinming); LODOP.SET_PRINT_STYLEA(0, "FontSize", 12); LODOP.ADD_PRINT_TEXT(803, 34, 234, 39, info.Fa_Gongsi); LODOP.SET_PRINT_STYLEA(0, "FontSize", 12); LODOP.ADD_PRINT_TEXT(895, 32, 238, 66, info.Fa_Dizhi); LODOP.SET_PRINT_STYLEA(0, "FontSize", 12); LODOP.ADD_PRINT_TEXT(979, 33, 234, 25, info.Fa_Phone); LODOP.SET_PRINT_STYLEA(0, "FontSize", 12); LODOP.ADD_PRINT_TEXT(1024, 35, 228, 25, info.Pinming); LODOP.SET_PRINT_STYLEA(0, "FontSize", 12); LODOP.ADD_PRINT_TEXT(802, 285, 287, 39, info.Shou_Com); LODOP.SET_PRINT_STYLEA(0, "FontSize", 12); LODOP.ADD_PRINT_TEXT(849, 373, 198, 28, info.Shou_Name); LODOP.SET_PRINT_STYLEA(0, "FontSize", 12); LODOP.ADD_PRINT_TEXT(894, 285, 287, 67, info.Shou_Dizhi); LODOP.SET_PRINT_STYLEA(0, "FontSize", 12); LODOP.ADD_PRINT_TEXT(980, 287, 281, 26, info.Shou_Phone); LODOP.SET_PRINT_STYLEA(0, "FontSize", 12); LODOP.ADD_PRINT_TEXT(1021, 317, 59, 29, info.Jianshu); LODOP.SET_PRINT_STYLEA(0, "FontSize", 12); LODOP.ADD_PRINT_TEXT(1017, 477, 95, 30, info.Zhongliang); LODOP.SET_PRINT_STYLEA(0, "FontSize", 12); }); } } //打印预览 var printID; function PrintDetail() { var row = $("#gridDetail").datagrid("getSelected"); if (row) { var index = $('#gridDetail').datagrid('getRowIndex', row); printID = row.ID; Preview(); } else { $.messager.alert("提示", "请选择一个记录"); } } //批量打印 function BatchPrint() { //得到用户选择的数据的ID var rows = $("#gridDetail").datagrid("getSelections"); if (rows.length >= 1) { //然后确认发送异步请求的信息到后台删除数据 $.messager.confirm("批量打印确认", "您确认批量打印选定的记录吗?", function (action) { if (action) { for (var i = 0; i < rows.length; i++) { LODOP = getLodop(); LODOP.PRINT_INIT(""); LODOP.SET_PRINT_PAGESIZE(1, 0, 0, "A4"); printID = rows[i].ID; CreateLicenseData(); LODOP.PRINT(); } } }); } else { $.messager.alert("提示", "请选择你要批量打印的数据"); } } //打印维护 function PrintSetup() { var row = $("#gridDetail").datagrid("getSelected"); if (row) { var index = $('#gridDetail').datagrid('getRowIndex', row); printID = row.ID; Setup(); } } </script>

其中这个打印界面中,还用到了二维码的打印处理操作,这样很方便直接使用条码枪直接读取,如下代码:

LODOP.ADD_PRINT_BARCODE(78, 441, 262, 56, "128C", info.FenyunDanhao); LODOP.ADD_PRINT_BARCODE(684, 441, 262, 56, "128C", info.FenyunDanhao);

然后在主页面里面设定打印的操作功能按钮进行处理,下面是我们基于EasyUI的Web框架界面效果。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wzfdpp.html