浏览代码

打印订单页面支持IE和非IE浏览器

xian 5 年之前
父节点
当前提交
0301a33d1e
共有 1 个文件被更改,包括 63 次插入29 次删除
  1. 63 29
      watero-rst-web/src/main/webapp/WEB-INF/views/cm/inspection/detect_list.ftl

+ 63 - 29
watero-rst-web/src/main/webapp/WEB-INF/views/cm/inspection/detect_list.ftl

@@ -480,7 +480,7 @@
 </div>
 <div style="padding-top: 10px;"></div>
 <#include "/base/page_util.ftl">
-<script type="text/javascript" src="https://s.iamberry.com/js/LodopFuncs.js"></script>
+<script type="text/javascript" src="https://s.iamberry.com/js/LodopFuncs_v_2_0.js"></script>
 <script type="text/javascript" src="${path}/common/lib/jquery.PrintArea/jquery.PrintArea.js"></script>
 <script type="text/javascript">
     var LODOP=getLodop();
@@ -513,7 +513,6 @@
 
 
     // 选择打印设备
-    /*var LODOP=getLodop();*/
     function printPageMaintenance(detectId) {
         //获取打印数据
         $.ajax({
@@ -602,36 +601,71 @@
                     /*$("#pageid").printArea();*/
 
                     // 选择打印设备
-                    LODOP.SELECT_PRINTER();
-                    LODOP.PRINT_INIT('打印维修单');
-                    LODOP.SET_PRINT_PAGESIZE(0, 0, 0,"");
-                    LODOP.ADD_PRINT_HTM("0mm","0mm","100%","100%", $("#pageid").html());
-                    var flag = LODOP.PRINT();
-                    if (flag) {
-                        layer.msg("打印成功", {icon: 6, time: 3000});
-                    }
-                    alert(detectInfo.detectIsPrint);
-                    //修改打印状态
-                    if(detectInfo.detectIsPrint === 1){
-                        $.ajax({
-                            cache: true,
-                            type: "POST",
-                            url: "${path}/admin/detect/update_print",
-                            data:{detectId:detectId},
-                            async: false,
-                            success: function(data){
-                                if (data.returnCode == 200) {
-                                    /*location.replace(location.href);*/
-                                    $("#print"+detectId).html("已打印");
-                                }
-                            },
-                            error: function(XmlHttpRequest, textStatus, errorThrown){
-
+                    var isIE = (navigator.userAgent.indexOf('MSIE')>=0) || (navigator.userAgent.indexOf('Trident')>=0);
+                    if (!isIE) {
+                        LODOP.PRINT_INIT('打印维修单');
+                        LODOP.SET_PRINT_PAGESIZE(0, 0, 0,"");
+                        LODOP.ADD_PRINT_HTM("0mm","0mm","100%","100%", $("#pageid").html());
+                        LODOP.SELECT_PRINTER(true);
+                        // 注意,选择打印机后,需要更改打印机事件,否则无法执行回调
+                        var spans = $("span");
+                        for (var i = 0; i < spans.length; i++) {
+                            if ($(spans[i]).text() === "打印份数:") {
+                                $(spans[i]).parent().next()[0].onclick = function () {
+                                    CLODOP.SelectBox.clickOK(false);
+                                    layer.msg("打印成功", {icon: 6, time: 3000});
+                                    //修改打印状态
+                                    if(detectInfo.detectIsPrint === 1){
+                                        $.ajax({
+                                            cache: true,
+                                            type: "POST",
+                                            url: "${path}/admin/detect/update_print",
+                                            data:{detectId:detectId},
+                                            async: false,
+                                            success: function(data){
+                                                if (data.returnCode == 200) {
+                                                    /*location.replace(location.href);*/
+                                                    $("#print"+detectId).html("已打印");
+                                                }
+                                            },
+                                            error: function(XmlHttpRequest, textStatus, errorThrown){
+
+                                            }
+                                        });
+                                    }
+                                };
                             }
-                        });
+                        }
+                    } else {
+                        LODOP.SELECT_PRINTER();
+                        LODOP.PRINT_INIT('打印维修单');
+                        LODOP.SET_PRINT_PAGESIZE(0, 0, 0,"");
+                        LODOP.ADD_PRINT_HTM("0mm","0mm","100%","100%", $("#pageid").html());
+                        var flag = LODOP.PRINT();
+                        if (flag) {
+                            layer.msg("打印成功", {icon: 6, time: 3000});
+                        }
+                        //修改打印状态
+                        if(detectInfo.detectIsPrint === 1){
+                            $.ajax({
+                                cache: true,
+                                type: "POST",
+                                url: "${path}/admin/detect/update_print",
+                                data:{detectId:detectId},
+                                async: false,
+                                success: function(data){
+                                    if (data.returnCode == 200) {
+                                        /*location.replace(location.href);*/
+                                        $("#print"+detectId).html("已打印");
+                                    }
+                                },
+                                error: function(XmlHttpRequest, textStatus, errorThrown){
+
+                                }
+                            });
+                        }
                     }
                 }
-
             },
             error: function(XmlHttpRequest, textStatus, errorThrown){
                 layer.msg('打印失败',{icon: 5,time:1000});