From 918cf69e763d30a1315fa1c83a964dae4dd88f12 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <xltys1995>
Date: 星期六, 03 四月 2021 15:11:08 +0800
Subject: [PATCH] #

---
 src/main/webapp/static/js/mat/mat.js |  106 +++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 95 insertions(+), 11 deletions(-)

diff --git a/src/main/webapp/static/js/mat/mat.js b/src/main/webapp/static/js/mat/mat.js
index bb4b3f0..2233719 100644
--- a/src/main/webapp/static/js/mat/mat.js
+++ b/src/main/webapp/static/js/mat/mat.js
@@ -1,4 +1,5 @@
 var pageCurr;
+var printMatCodeNos = [];
 layui.use(['table','laydate', 'form'], function(){
     var table = layui.table;
     var $ = layui.jquery;
@@ -23,21 +24,21 @@
 //             ,{field: 'id', align: 'center',title: 'ID'}
 //             ,{field: 'uuid', align: 'center',title: '缂栧彿'}
 //             ,{field: 'nodeId$', align: 'center',title: '鎵�灞炲尯鍩�',event: 'nodeId', style: 'cursor:pointer'}
-//             ,{field: 'tagId$', align: 'center',title: '鎵�灞炲綊绫�',event: 'tagId', style: 'cursor:pointer'}
+            ,{field: 'tagId$', align: 'center',title: '褰掔被', templet: '#tagTpl'}
             ,{field: 'matnr', align: 'center',title: '鍟嗗搧缂栧彿'}
-            ,{field: 'maktx', align: 'center',title: '鍟嗗搧鍚嶇О'}
+            ,{field: 'maktx', align: 'center',title: '鍟嗗搧鍚嶇О', minWidth: 300}
             // ,{field: 'name', align: 'center',title: '鍚嶇О'}
             ,{field: 'specs', align: 'center',title: '瑙勬牸'}
-            ,{field: 'model', align: 'center',title: '鍨嬪彿'}
-            ,{field: 'batch', align: 'center',title: '鎵瑰彿'}
+            ,{field: 'model', align: 'center',title: '鍨嬪彿', hide: true}
+            ,{field: 'batch', align: 'center',title: '鎵瑰彿', hide: true}
             ,{field: 'unit', align: 'center',title: '鍗曚綅'}
-            ,{field: 'barcode', align: 'center',title: '鏉$爜'}
-            ,{field: 'docId', align: 'center',title: '鍗曟嵁绫诲瀷'}
-            ,{field: 'docNum', align: 'center',title: '鍗曟嵁缂栧彿'}
-            ,{field: 'custName', align: 'center',title: '瀹㈡埛鍚嶇О'}
-            ,{field: 'itemNum', align: 'center',title: '鍝侀」鏁�'}
-            ,{field: 'count', align: 'center',title: '搴撳瓨浣欓噺'}
-            ,{field: 'weight', align: 'center',title: '閲嶉噺'}
+            ,{field: 'barcode', align: 'center',title: '鏉$爜', hide: true}
+            // ,{field: 'docId', align: 'center',title: '鍗曟嵁绫诲瀷'}
+            // ,{field: 'docNum', align: 'center',title: '鍗曟嵁缂栧彿'}
+            // ,{field: 'custName', align: 'center',title: '瀹㈡埛鍚嶇О'}
+            ,{field: 'itemNum', align: 'center',title: '鍝侀」鏁�', hide: true}
+            ,{field: 'count', align: 'center',title: '搴撳瓨浣欓噺', hide: true}
+            ,{field: 'weight', align: 'center',title: '閲嶉噺', hide: true}
             // ,{field: 'status', align: 'center',title: '鐘舵��'}
             // ,{field: 'createBy$', align: 'center',title: '娣诲姞浜哄憳'}
             // ,{field: 'createTime$', align: 'center',title: '娣诲姞鏃堕棿'}
@@ -184,6 +185,29 @@
                     });
                 });
                 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;
         }
     });
 
@@ -191,6 +215,23 @@
     table.on('tool(mat)', function(obj){
         var data = obj.data;
         switch (obj.event) {
+            // 鎵撳嵃
+            case "btnPrint":
+                printMatCodeNos = [];
+                layer.open({
+                    type: 1,
+                    title: data.matnr + ' [鏁伴噺锛�1]',
+                    area: ['500px'],
+                    shadeClose: true,
+                    content: $('#printDataDiv'),
+                    success: function(layero, index){
+                        layer.iframeAuto(index);
+                        printMatCodeNos.push(data.matnr);
+                    },
+                    end: function () {
+                    }
+                });
+                break;
             // 璇︽儏
             case 'detail':
                 layer.open({
@@ -232,6 +273,49 @@
         }
     });
 
+    // 妯℃澘閫夋嫨
+    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;
+        $.ajax({
+            url: baseUrl+"/mat/print/auth",
+            headers: {'token': localStorage.getItem('token')},
+            data: {param: printMatCodeNos},
+            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);
+                    let 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(save)', function () {
         if (banMsg != null){

--
Gitblit v1.9.1