From 142aed38403568e99d7f115f57442fa0abec1cc8 Mon Sep 17 00:00:00 2001
From: zyx <zyx123456>
Date: 星期一, 04 十二月 2023 16:53:44 +0800
Subject: [PATCH] 平库库位加打印模板功能

---
 src/main/webapp/static/js/node/node.js |   56 ++++++++++++++++++
 src/main/webapp/views/node/node.html   |   96 ++++++++++++++++++++++++++++++++
 2 files changed, 150 insertions(+), 2 deletions(-)

diff --git a/src/main/webapp/static/js/node/node.js b/src/main/webapp/static/js/node/node.js
index ac5aaf8..de3d782 100644
--- a/src/main/webapp/static/js/node/node.js
+++ b/src/main/webapp/static/js/node/node.js
@@ -2,6 +2,7 @@
 var admin;
 var areas;
 var matXmSelect;
+var printContent = [];
 layui.config({
     base: baseUrl + "/static/layui/lay/modules/"
 }).extend({
@@ -77,18 +78,32 @@
             });
             doDel({ids: ids});
         } else if (obj.event === 'printBatch') {
+            printContent = [];
             if (checkRows.length === 0) {
                 layer.msg('璇烽�夋嫨瑕佹墦鍗扮殑鏁版嵁', {icon: 2});
                 return;
             }
-            var printContent = checkRows.map(function (d) {
+            printContent = checkRows.map(function (d) {
                 if (!d.LAY_INDETERMINATE && d.type === 3) {
                     return d.name;
                 } else {
                     return null;
                 }
             });
-            printBatch(printContent, 1);
+            layer.open({
+                type: 1,
+                title: '鎵归噺鎵撳嵃 [鏁伴噺'+ printContent.length +']',
+                area: ['500px'],
+                shadeClose: true,
+                content: $('#printDataDiv'),
+                success: function(layero, index){
+                },
+                end: function () {
+                }
+            });
+
+
+            //printBatch(printContent, 1);
         }else if (obj.event === 'nodeInit'){
             nodeInit();
         }
@@ -101,6 +116,12 @@
         } else if (obj.event === 'del') { // 鍒犻櫎
             doDel(obj);
         }
+    });
+
+    // 妯℃澘閫夋嫨
+    form.on('radio(selectTemplateRadio)', function (data) {
+        $('.template-preview').hide();
+        $('#template-preview-'+data.value).show();
     });
 
     /* 鏄剧ず琛ㄥ崟寮圭獥 */
@@ -201,6 +222,7 @@
 
     // 鎵归噺鎵撳嵃
     function printBatch(printMsgList, type) {
+
         var data = [];
         for (var i = 0; i<printMsgList.length; i ++) {
             if (printMsgList[i] != null && printMsgList[i] !== '') {
@@ -226,6 +248,36 @@
         box.hide();
     }
 
+    // 寮�濮嬫墦鍗�
+    form.on('submit(doPrint)', function (data) {
+        var templateNo = data.field.selectTemplate;
+        var data = [];
+        var type = 1;
+        for (var i = 0; i<printContent.length; i ++) {
+            if (printContent[i] != null && printContent[i] !== '') {
+                var barcodeUrl;
+                if (type === 1) {
+                    barcodeUrl = baseUrl+"/mac/code/auth?type="+type+"&param="+printContent[i]+"&width="+200+"&height="+70;
+                } else {
+                    barcodeUrl = baseUrl+"/mac/code/auth?type="+type+"&param="+printContent[i]+"&width="+400+"&height="+180;
+                }
+                data.push({
+                    item: printContent[i],
+                    barcodeUrl: barcodeUrl
+                })
+            }
+        }
+        var templateDom = $("#templatePreview"+templateNo);
+        var tpl = templateDom.html();
+        var template = Handlebars.compile(tpl);
+        var html = template({data: data});
+        var box = $("#box");
+        box.html(html);
+        box.show();
+        box.print({mediaPrint:true});
+        box.hide();
+    });
+
 
     function nodeInit(){
         layer.prompt({title: '璇疯緭鍏ュ彛浠わ紝骞堕噸缃簱浣�', formType: 1,   shadeClose: true}, function(pass, idx){
diff --git a/src/main/webapp/views/node/node.html b/src/main/webapp/views/node/node.html
index b049dd7..427cd4f 100644
--- a/src/main/webapp/views/node/node.html
+++ b/src/main/webapp/views/node/node.html
@@ -16,6 +16,17 @@
         .ew-tree-table-box {
             height: 100%;
         }
+        /* ------------------------- 鎵撳嵃琛ㄦ牸 -----------------------  */
+        .template-preview {
+            height: 200px;
+            display: inline-block;
+        }
+        .contain td {
+            border: 1px solid #000;
+            /*font-family: 榛戜綋;*/
+            /*font-weight: bold;*/
+            /*color: #000000;*/
+        }
     </style>
 </head>
 <body>
@@ -197,7 +208,92 @@
     </div>
 </div>
 
+<!-- 鎵撳嵃鎿嶄綔寮圭獥 -->
+<div id="printDataDiv" style="display: none;padding: 20px">
+    <div class="layui-form" style="text-align: center">
+        <hr>
+        <!--鍗曢�夋-->
+        <div class="layui-form-item" style="display: inline-block; margin-bottom: 10px">
+            <input type="radio" name="selectTemplate" value="1" title="妯℃澘涓�"  lay-filter="selectTemplateRadio" checked="checked">
+            <input type="radio" name="selectTemplate" value="2" title="妯℃澘浜�" lay-filter="selectTemplateRadio">
+        </div>
+        <fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;text-align: left;">
+            <legend>鎵撳嵃棰勮</legend>
+            <div id="template-container" style="margin: 20px;text-align: center">
 
+                <!-- 棰勮鍥� 1 -->
+                <div id="template-preview-1" class="template-preview" style="display: inline-block">
+                    <table class="contain" width="280" style="overflow: hidden;font-size: xx-small;table-layout: fixed;">
+                        <tr style="height: 74px; border: none">
+                            <td class="barcode" colspan="12" align="center" scope="col" style=" border: none">
+                                <img class="template-code template-barcode" src="" width="90%;">
+                                <div style="letter-spacing: 2px;margin-top: 1px; text-align: center;">
+                                    <span>xxxxxx</span>
+                                </div>
+                            </td>
+                        </tr>
+                    </table>
+                </div>
+
+                <!-- 棰勮鍥� 2 -->
+                <div id="template-preview-2" class="template-preview" style="display: none">
+                    <table class="contain" width="280" style="overflow: hidden;table-layout: fixed; border: none; font-size: xx-large">
+                        <tr style="height: 74px">
+                            <td class="barcode" colspan="9" align="center" scope="col" style="border: none">
+                                <img class="template-code template-barcode" src="" width="90%;"> 鈫�
+                                <div style="letter-spacing: 2px;margin-top: 1px; text-align: center; font-size: xx-small">
+                                    <span>xxxxxx</span>
+                                </div>
+                            </td>
+                        </tr>
+                    </table>
+                </div>
+            </div>
+        </fieldset>
+
+        <button class="layui-btn" id="doPrint" lay-submit lay-filter="doPrint" style="margin-top: 20px">纭畾</button>
+    </div>
+</div>
+
+<div id="box" style="display: block"></div>
+
+<!-- 鍒濆鍖栨墦鍗版ā鏉跨殑鏉″舰鐮� -->
+<script type="text/javascript">
+    $('.template-barcode').attr("src", baseUrl+"/mac/code/auth?type=1&param=123");
+    $('.template-qrcode').attr("src", baseUrl+"/mac/code/auth?type=2&param=123");
+</script>
+
+<!-- 妯℃澘寮曟搸 -->
+<!-- 妯℃澘1 -->
+<script type="text/template" id="templatePreview1" class="template-barcode">
+    {{#each data}}
+    <table class="contain" width="400px" style="overflow: hidden;font-size: xx-small;table-layout: fixed;">
+        <tr style="height: 150px; border: none">
+            <td class="barcode" colspan="12" align="center" scope="col" style=" border: none">
+                <img class="template-code template-barcode" src="{{this.barcodeUrl}}" width="90%;">
+                <div style="letter-spacing: 2px;margin-top: 1px; text-align: center;">
+                    <span>{{this.item}}</span>
+                </div>
+            </td>
+        </tr>
+    </table>
+    {{/each}}
+</script>
+<!-- 妯℃澘2 -->
+<script type="text/template" id="templatePreview2" class="template-barcode">
+    {{#each data}}
+    <table class="contain" width="400px" style="overflow: hidden;table-layout: fixed; border: none; font-size: xx-large">
+        <tr style="height: 150px">
+            <td class="barcode" colspan="9" align="center" scope="col" style="border: none">
+                <img class="template-code template-barcode" src="{{this.barcodeUrl}}" width="90%;"> 鈫�
+                <div style="letter-spacing: 2px;margin-top: 1px; text-align: center; font-size: xx-small">
+                    <span>{{this.item}}</span>
+                </div>
+            </td>
+        </tr>
+    </table>
+    {{/each}}
+</script>
 </body>
 </html>
 

--
Gitblit v1.9.1