From 133e9fccff97927467a2edbfec8ae1f382722fae Mon Sep 17 00:00:00 2001
From: zyx <zyx123456>
Date: 星期六, 27 一月 2024 16:31:38 +0800
Subject: [PATCH] # 打印物料码 文本自动换行

---
 src/main/webapp/static/js/pla/plaDetl.js |   88 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 88 insertions(+), 0 deletions(-)

diff --git a/src/main/webapp/static/js/pla/plaDetl.js b/src/main/webapp/static/js/pla/plaDetl.js
index ba2eb66..615d4c4 100644
--- a/src/main/webapp/static/js/pla/plaDetl.js
+++ b/src/main/webapp/static/js/pla/plaDetl.js
@@ -7,6 +7,7 @@
 var checkStatus = [];
 var dataCheck = [];
 var admin;
+var printData = [];
 function getCol() {
     var cols = [
         {field: 'id', title: 'id', align: 'center',hide:true}
@@ -106,6 +107,7 @@
         limits: [16, 30, 50, 100, 200, 500],
         even: true,
         toolbar: '#toolbar',
+        size: "lg",
         cellMinWidth: 50,
         cols: [getCol()],
         request: {
@@ -125,6 +127,7 @@
             statusCode: 200
         },
         done: function(res, curr, count) {
+            //$(".lavui-table-grid-down").hide();
             if (res.code === 403) {
                 top.location.href = baseUrl+"/";
             }
@@ -227,6 +230,7 @@
     // 鐩戝惉澶村伐鍏锋爮浜嬩欢
     table.on('toolbar(plaDetl)', function (obj) {
         var checkStatus = table.checkStatus(obj.config.id)
+        printData = checkStatus;
         switch(obj.event) {
             case 'updateData':
                 var data = checkStatus.data;
@@ -365,9 +369,93 @@
                     });
                 }
                 break;
+            // 鎵归噺鎵撳嵃
+            case "btnPrintBatch":
+                printMatCodeNos = [];
+                var data = checkStatus.data;
+                if (data.length === 0){
+                    layer.msg('璇烽�夋嫨鎵撳嵃鏁版嵁');
+                } else {
+                    layer.open({
+                        type: 1,
+                        title: '鎵归噺鎵撳嵃 [鏁伴噺'+ data.length +']',
+                        area: ['500px'],
+                        shadeClose: true,
+                        content: $('#printDataDiv'),
+                        success: function(layero, index){
+                            for (var i = 0; i<data.length;i++) {
+                                printMatCodeNos.push(data[i].matnr);
+                            }
+                        },
+                        end: function () {
+                        }
+                    });
+                }
+                break;
         }
     })
 
+    // 妯℃澘閫夋嫨
+    form.on('radio(selectTemplateRadio)', function (data) {
+        $('.template-preview').hide();
+        $('#template-preview-'+data.value).show();
+    });
+
+    // 寮�濮嬫墦鍗�
+    form.on('submit(doPrint)', function (data) {
+        var templateNo = data.field.selectTemplate;
+        var templateDom = $("#templatePreview"+templateNo);
+        var className = templateDom.attr("class");
+        layer.closeAll();
+        for (let i=0;i<printData.data.length;i++){
+            if (className === 'template-barcode') {
+                printData.data[i]["barcodeUrl"]=baseUrl+"/mac/code/auth?type=1&param="+(printData.data[i].batch+";"+printData.data[i].packageNo)
+            } else {
+                printData.data[i]["barcodeUrl"]=baseUrl+"/mac/code/auth?type=2&param="+(printData.data[i].batch+";"+printData.data[i].packageNo)
+            }
+        }
+        var tpl = templateDom.html();
+        var template = Handlebars.compile(tpl);
+        var html = template(printData);
+        var box = $("#box");
+        box.html(html);box.show();
+        box.print({mediaPrint:true});
+        box.hide();
+        // $.ajax({
+        //     url: baseUrl+"/pla/print/auth",
+        //     headers: {'token': localStorage.getItem('token')},
+        //     data: JSON.stringify(printData.data),
+        //     contentType:'application/json;charset=UTF-8',
+        //     method: 'POST',
+        //     async: false,
+        //     success: function (res) {
+        //         if (res.code === 200){
+        //             layer.closeAll();
+        //             for (let i=0;i<res.data.length;i++){
+        //                 var templateDom = $("#templatePreview"+templateNo);
+        //                 var className = templateDom.attr("class");
+        //                 if (className === 'template-barcode') {
+        //                     res.data[i]["barcodeUrl"]=baseUrl+"/mac/code/auth?type=1&param="+res.data[i].matnr;
+        //                 } else {
+        //                     res.data[i]["barcodeUrl"]=baseUrl+"/mac/code/auth?type=2&param="+res.data[i].matnr;
+        //                 }
+        //             }
+        //             var tpl = templateDom.html();
+        //             var template = Handlebars.compile(tpl);
+        //             var html = template(res);
+        //             var box = $("#box");
+        //             box.html(html);box.show();
+        //             box.print({mediaPrint:true});
+        //             box.hide();
+        //         } else if (res.code === 403){
+        //             top.location.href = baseUrl+"/";
+        //         }else {
+        //             layer.msg(res.msg)
+        //         }
+        //     }
+        // })
+    });
+
     // 鎼滅储鏍忔悳绱簨浠�
     form.on('submit(search)', function (data) {
         pageCurr = 1;

--
Gitblit v1.9.1