From 45dd167e12e11af8dc7929ff1475623c80fc3578 Mon Sep 17 00:00:00 2001
From: whycq <913841844@qq.com>
Date: 星期三, 30 十月 2024 13:59:33 +0800
Subject: [PATCH] #

---
 src/main/webapp/static/js/trayCode/trayCode.js |  105 +++++++++++++++++++++++++++++++---------------------
 1 files changed, 63 insertions(+), 42 deletions(-)

diff --git a/src/main/webapp/static/js/trayCode/trayCode.js b/src/main/webapp/static/js/trayCode/trayCode.js
index 5d5d836..bc70c7a 100644
--- a/src/main/webapp/static/js/trayCode/trayCode.js
+++ b/src/main/webapp/static/js/trayCode/trayCode.js
@@ -112,9 +112,10 @@
                     content: $('#print-windows'),
                     success: function(layero, index){
                         layer.iframeAuto(index)
+                        http.post(baseUrl+"/trayCode/latest", null, function (res) {
+                            $('#startNo').val(res.data);
+                        })
                     },
-                    end: function () {
-                    }
                 });
                 break;
             case 'exportData':
@@ -295,51 +296,71 @@
         ,range: true
     });
 
+    // 寮�濮嬫墦鍗�
     form.on('submit(print)', function (data) {
-        // $.ajax({
-        //     url: baseUrl+"/trayCode/print/preview",
-        //     headers: {'token': localStorage.getItem('token')},
-        //     data: {
-        //         startNo: $('#startNo'),
-        //         count: $('#count'),
-        //         type: $("input[name='type']:checked").val()
-        //     },
-        //     method: 'POST',
-        //     async: false,
-        //     success: function (res) {
-        //         if (res.code === 200){
-        //             for (let i=0;i<res.data.length;i++){
-        //                 res.data[i]["barcodeUrl"]=baseUrl+"/macCode/code/auth?type=1&param="+res.data[i].item;
-        //             }
-        //             var tpl = $('#trayCodeTemplate').html();
-        //             var template = Handlebars.compile(tpl);
-        //             var html = template(res);
-        //             let box = $("#printBox");
-        //             // box.html(html);
-        //             // box.show();
-        //             // box.print();
-        //             // box.hide();
-        //             // parent.layer.close(parent.layer.getFrameIndex(window.name));
-        //         } else if (res.code === 403){
-        //             top.location.href = baseUrl+"/";
-        //         }else {
-        //             layer.msg(res.msg)
-        //         }
-        //     }
-        // })
+        $.ajax({
+            url: baseUrl+"/trayCode/print/preview",
+            headers: {'token': localStorage.getItem('token')},
+            data: data.field,
+            method: 'POST',
+            async: false,
+            success: function (res) {
+                if (res.code === 200){
+                    for (let i=0;i<res.data.length;i++){
+                        if (data.field.type === '1') {
+                            res.data[i]["barcodeUrl"]=baseUrl+"/file/barcode/qrcode/auth?" +
+                                "type="+data.field.type+"&param="+res.data[i].item+"&width="+200+"&height="+90;
+                        } else {
+                            res.data[i]["barcodeUrl"]=baseUrl+"/file/barcode/qrcode/auth?" +
+                                "type="+data.field.type+"&param="+res.data[i].item+"&width="+400+"&height="+180;
+                        }
+                    }
+                    var tpl = $('#trayCodeTemplate').html();
+                    var template = Handlebars.compile(tpl);
+                    var html = template(res);
+                    let box = $("#printBox");
+                    box.html(html);
+                    box.show();
+                    box.print({
+                        mediaPrint:true,
+                        deferred: $.Deferred().done(function () {
+                            layer.confirm('[閲嶈] 鎵撳嵃鏄惁鎴愬姛锛�',  {btn: ['Yes', 'No']}, function(){
+                                $.ajax({
+                                    url: baseUrl+"/trayCode/print/auth",
+                                    headers: {'token': localStorage.getItem('token')},
+                                    data: data.field,
+                                    method: 'POST',
+                                    success: function (res) {
+                                        if (res.code === 200){
+                                            layer.closeAll();
+                                            $(".layui-laypage-btn")[0].click();
+                                            layer.msg("鎿嶄綔鎴愬姛")
+                                        } else if (res.code === 403){
+                                            top.location.href = baseUrl+"/";
+                                        } else {
+                                            layer.msg(res.msg)
+                                        }
+                                    }
+                                })
+                            });
+                        })
+                    });
+                    box.hide();
+                    layer.closeAll();
+                } else if (res.code === 403){
+                    top.location.href = baseUrl+"/";
+                }else {
+                    layer.msg(res.msg)
+                }
+            }
+        })
     });
 
-
+    $('#cancel').click(function () {
+        layer.closeAll();
+    })
 });
 
-
-$('#print').click(function () {
-
-});
-
-$('#cancel').click(function () {
-    // layer.close(layer.getFrameIndex(window.name));
-})
 
 // 鍏抽棴鍔ㄤ綔
 $(document).on('click','#data-detail-close', function () {

--
Gitblit v1.9.1