Quellcode durchsuchen

机器打印列表功能

liujiankang vor 7 Jahren
Ursprung
Commit
0b333edf40

+ 5 - 2
watero-rst-web/src/main/java/com/iamberry/rst/controllers/pts/MachineController.java

@@ -246,9 +246,12 @@ public class MachineController {
                 num = String.valueOf(number);
                 break;
         }
-
+        String months = String.valueOf(month);
+        if(month < 10){
+            months = "0"+months;
+        }
         //拼接
-        String barcode = productModel+productFeatures+softwareVersion+String.valueOf(year).substring(2,4)+month+num;
+        String barcode = productModel+productFeatures+softwareVersion+String.valueOf(year).substring(2,4)+months+num;
         return barcode;
     }
 }

+ 29 - 29
watero-rst-web/src/main/webapp/WEB-INF/views/pts/machine/machine_List.ftl

@@ -152,49 +152,49 @@
                     /*$("#barcodeId").html(machineBarcode);
                     $("#qrcodeImg").attr('src',machineQrcode);*/
                     if(produceType == 1){//净水机模板
-                        $("#printlist").append('<div style="width: 227px;height: 142px;position: relative;margin-left: 20px;">' +
-                                '<span style="position: absolute;left: 10px;top:20px;font-size: 14px;">WaterO可移动智能净水机</span>' +
-                                '<span style="position: absolute;left: 10px;top: 44px;font-size: 12px;">型号:WA-1X</span>' +
-                                '<span style="position: absolute;left: 10px;top: 60px;font-size: 12px;">S/N</span>' +
-                                '<div style="position: absolute;top: 80px;height: 23px;" id="bcTarget2" class="barcodeImg">'+barcodes+'</div>' +
-                                '<span style="position: absolute;left: 10px;top: 108px;font-size: 12px;width: 116px;text-align: center;" id="barcodeId">'+machineBarcode+'</span>' +
-                                '<img style="position: absolute;right: 10px;top:24px;width: 78px;height: 78px;" id="qrcodeImg" src="'+machineQrcode+'" /> ' +
-                                '<span style="position: absolute;right: 26px;top: 108px;font-size: 12px;">no.:4295</span> ' +
+                        $("#printlist").append('<div style="width: 268px;height: 152px;position: relative;">' +
+                                '<span style="position: absolute;top:0px;font-size: 14px;">WaterO可移动智能净水机</span>' +
+                                '<span style="position: absolute;top: 24px;font-size: 12px;">型号:WA-1X</span>' +
+                                '<span style="position: absolute;top: 40px;font-size: 12px;">S/N</span>' +
+                                '<div style="position: absolute;left: -10px;top: 75px;height: 30px;" id="bcTarget2" class="barcodeImg">'+barcodes+'</div>' +
+                                '<span style="position: absolute;top: 102px;font-size: 12px;width: 116px;text-align: center;" id="barcodeId">'+machineBarcode+'</span>' +
+                                '<img style="position: absolute;right: 2px;top:18px;width: 86px;height: 86px;" id="qrcodeImg" src="'+machineQrcode+'" /> ' +
+                                '<span style="position: absolute;right: 26px;top: 102px;font-size: 12px;">NO.4295</span> ' +
                                 '</div>');
                     }
                     if(produceType == '' || produceType == null){
-                        $("#printlist").append('<div style="width: 227px;height: 142px;position: relative;margin-left: 20px;">' +
-                                '<span style="position: absolute;left: 10px;top:20px;font-size: 14px;">WaterO可移动智能净水机</span>' +
-                                '<span style="position: absolute;left: 10px;top: 44px;font-size: 12px;">型号:WA-1X</span>' +
-                                '<span style="position: absolute;left: 10px;top: 60px;font-size: 12px;">S/N</span>' +
-                                '<div style="position: absolute;top: 80px;height: 23px;" id="bcTarget2" class="barcodeImg">'+barcodes+'</div>' +
-                                '<span style="position: absolute;left: 10px;top: 108px;font-size: 12px;width: 116px;text-align: center;" id="barcodeId">'+machineBarcode+'</span>' +
-                                '<img style="position: absolute;right: 10px;top:24px;width: 78px;height: 78px;" id="qrcodeImg" src="'+machineQrcode+'" /> ' +
-                                '<span style="position: absolute;right: 26px;top: 108px;font-size: 12px;">no:4295</span> ' +
+                        $("#printlist").append('<div style="width: 268px;height: 152px;position: relative;">' +
+                                '<span style="position: absolute;top:0px;font-size: 14px;">WaterO可移动智能净水机</span>' +
+                                '<span style="position: absolute;top: 24px;font-size: 12px;">型号:WA-1X</span>' +
+                                '<span style="position: absolute;top: 40px;font-size: 12px;">S/N</span>' +
+                                '<div style="position: absolute;left: -10px;top: 75px;height: 30px;" id="bcTarget2" class="barcodeImg">'+barcodes+'</div>' +
+                                '<span style="position: absolute;top: 102px;font-size: 12px;width: 116px;text-align: center;" id="barcodeId">'+machineBarcode+'</span>' +
+                                '<img style="position: absolute;right: 2px;top:18px;width: 86px;height: 86px;" id="qrcodeImg" src="'+machineQrcode+'" /> ' +
+                                '<span style="position: absolute;right: 26px;top: 102px;font-size: 12px;">NO.4295</span> ' +
                                 '</div>');
                     }
                     if(produceType == 2){//冲奶机模板
-                        $("#printlist").append('<div style="width: 227px;height: 142px;position: relative;margin-left: 20px;">' +
-                                '<span style="position: absolute;left: 10px;top:20px;font-size: 14px;">爱贝源冲奶机</span>' +
-                                '<span style="position: absolute;left: 10px;top: 44px;font-size: 12px;">型号:WA-1X</span>' +
-                                '<span style="position: absolute;left: 10px;top: 60px;font-size: 12px;">S/N</span>' +
-                                '<div style="position: absolute;top: 80px;height: 23px;" id="bcTarget2" class="barcodeImg">'+barcodes+'</div>' +
-                                '<span style="position: absolute;left: 10px;top: 108px;font-size: 12px;width: 116px;text-align: center;" id="barcodeId">'+machineBarcode+'</span>' +
-                                '<img style="position: absolute;right: 10px;top:24px;width: 78px;height: 78px;" id="qrcodeImg" src="'+machineQrcode+'" /> ' +
-                                '<span style="position: absolute;right: 26px;top: 108px;font-size: 12px;">no:4295</span> ' +
+                        $("#printlist").append('<div style="width: 268px;height: 152px;position: relative;">' +
+                                '<span style="position: absolute;top:0px;font-size: 14px;">爱贝源冲奶机</span>' +
+                                '<span style="position: absolute;top: 24px;font-size: 12px;">型号:WA-1X</span>' +
+                                '<span style="position: absolute;top: 40px;font-size: 12px;">S/N</span>' +
+                                '<div style="position: absolute;left: -10px;top: 75px;height: 30px;" id="bcTarget2" class="barcodeImg">'+barcodes+'</div>' +
+                                '<span style="position: absolute;top: 102px;font-size: 12px;width: 116px;text-align: center;" id="barcodeId">'+machineBarcode+'</span>' +
+                                '<img style="position: absolute;right: 2px;top:18px;width: 86px;height: 86px;" id="qrcodeImg" src="'+machineQrcode+'" /> ' +
+                                '<span style="position: absolute;right: 26px;top: 102px;font-size: 12px;">NO.4295</span> ' +
                                 '</div>');
                     }
 
                 }
                 $("#printlist").printArea();
                 $("#printlist").html("");
-                updatePrint(machineId);
+                updatePrint(machineBarcode);
             }
 
             ref = setInterval(function(){
-                latestMachine();
+                latestMachines();
             },2000);
-            function  latestMachine() {
+            function  latestMachines() {
                 $.ajax({
                     cache: true,
                     type: "POST",
@@ -273,12 +273,12 @@
                 return   year+"-"+month+"-"+date;
             }
 
-            function updatePrint(machineId){
+            function updatePrint(machineBarcode){
                 $.ajax({
                     "type" : "post",
                     "url" : "${path}/admin/machine/_update_print",
                     "dataType" : "json",
-                    "data" :{machineId : machineId},
+                    "data" :{machineBarcode : machineBarcode},
                     "success" : function(data) {
 
                     },

+ 74 - 72
watero-rst-web/src/main/webapp/WEB-INF/views/pts/machine/machine_print_List.ftl

@@ -44,7 +44,7 @@
 				</thead>
 				<tbody id="listid">
 					<#list machineList as list>
-						<tr>
+						<tr >
                             <td width="2">
                                 <input name='checkbox' type='checkbox' value='${list.machineBarcode }${list.machineQrcode }${list.machineProduceType }' >
                             </td>
@@ -70,11 +70,15 @@
         <script type="text/javascript" src="${path}/common/static/h-ui.admin/js/H-ui.js"></script>
 
 		<script type="text/javascript">
-            $("#all").click(function(){
-                $("input[name='checkbox']").attr("checked","true");
-            })
-
+            $("#all").on('click',function(){
+                console.log($(this).prop('checked'));
+                if($(this).prop('checked')){
+                    $("input[name='checkbox']").prop("checked","true");
+                }else{
+                    $("input[name='checkbox']").removeAttr("checked");
+                }
 
+            });
                 if(${machineIsPrint} == 1){
                     $("#notPrint").attr("class", "current");
                     $("#machineIsPrint").val(1);
@@ -107,41 +111,51 @@
             function  printList() {
                 var machineBarcode = null;
                 var machineQrcode = null;
-                var machineProduceType = null
+                var machineProduceType = null;
+                var prints = "";
+                var settingNumber = $("#settingNumber").val();
                     $("input[name='checkbox']:checkbox:checked").each(function(){
+                        prints += $(this).val();
                         machineBarcode = $(this).val().substring(0,13);
                         machineQrcode = $(this).val().substring(13,($(this).val().length)-1);
                         machineProduceType = $(this).val().substring(($(this).val().length)-1,$(this).val().length);
-                        code128(machineBarcode);
-                        var barcodes = $("#bcTarget").html();
-                        /*$("#barcodeId").html(machineBarcode);
-                        $("#qrcodeImg").attr('src',machineQrcode);*/
-                        if(machineProduceType == 1){//净水机模板
-                            $("#printlist").append('<div style="width: 227px;height: 142px;position: relative;margin-left: 20px;">' +
-                                    '<span style="position: absolute;left: 10px;top:20px;font-size: 14px;">WaterO可移动智能净水机</span>' +
-                                    '<span style="position: absolute;left: 10px;top: 44px;font-size: 12px;">型号:WA-1X</span>' +
-                                    '<span style="position: absolute;left: 10px;top: 60px;font-size: 12px;">S/N</span>' +
-                                    '<div style="position: absolute;top: 80px;height: 23px;" id="bcTarget2" class="barcodeImg">'+barcodes+'</div>' +
-                                    '<span style="position: absolute;left: 10px;top: 108px;font-size: 12px;width: 116px;text-align: center;" id="barcodeId">'+machineBarcode+'</span>' +
-                                    '<img style="position: absolute;right: 10px;top:24px;width: 78px;height: 78px;" id="qrcodeImg" src="'+machineQrcode+'" /> ' +
-                                    '<span style="position: absolute;right: 26px;top: 108px;font-size: 12px;">no.:4295</span> ' +
-                                    '</div>');
+                        for (var i=0;i<settingNumber;i++){
+                            code128(machineBarcode);
+                            var barcodes = $("#bcTarget").html();
+                            /*$("#barcodeId").html(machineBarcode);
+                            $("#qrcodeImg").attr('src',machineQrcode);*/
+                            if(machineProduceType == 1){//净水机模板
+                                $("#printlist").append('<div style="width: 268px;height: 152px;position: relative;">' +
+                                        '<span style="position: absolute;top:0px;font-size: 14px;">WaterO可移动智能净水机</span>' +
+                                        '<span style="position: absolute;top: 24px;font-size: 12px;">型号:WA-1X</span>' +
+                                        '<span style="position: absolute;top: 40px;font-size: 12px;">S/N</span>' +
+                                        '<div style="position: absolute;left: -10px;top: 75px;height: 30px;" id="bcTarget2" class="barcodeImg">'+barcodes+'</div>' +
+                                        '<span style="position: absolute;top: 102px;font-size: 12px;width: 116px;text-align: center;" id="barcodeId">'+machineBarcode+'</span>' +
+                                        '<img style="position: absolute;right: 2px;top:18px;width: 86px;height: 86px;" id="qrcodeImg" src="'+machineQrcode+'" /> ' +
+                                        '<span style="position: absolute;right: 26px;top: 102px;font-size: 12px;">NO.4295</span> ' +
+                                        '</div>');
+                            }
+                            if(machineProduceType == 2){//冲奶机模板
+                                $("#printlist").append('<div style="width: 268px;height: 152px;position: relative;">' +
+                                        '<span style="position: absolute;top:0px;font-size: 14px;">爱贝源冲奶机</span>' +
+                                        '<span style="position: absolute;top: 24px;font-size: 12px;">型号:WA-1X</span>' +
+                                        '<span style="position: absolute;top: 40px;font-size: 12px;">S/N</span>' +
+                                        '<div style="position: absolute;left: -10px;top: 75px;height: 30px;" id="bcTarget2" class="barcodeImg">'+barcodes+'</div>' +
+                                        '<span style="position: absolute;top: 102px;font-size: 12px;width: 116px;text-align: center;" id="barcodeId">'+machineBarcode+'</span>' +
+                                        '<img style="position: absolute;right: 2px;top:18px;width: 86px;height: 86px;" id="qrcodeImg" src="'+machineQrcode+'" /> ' +
+                                        '<span style="position: absolute;right: 26px;top: 102px;font-size: 12px;">NO.4295</span> ' +
+                                        '</div>');
+                            }
+                            updatePrint(machineBarcode);
                         }
-                        if(machineProduceType == 2){//冲奶机模板
-                            $("#printlist").append('<div style="width: 227px;height: 142px;position: relative;margin-left: 20px;">' +
-                                    '<span style="position: absolute;left: 10px;top:20px;font-size: 14px;">爱贝源冲奶机</span>' +
-                                    '<span style="position: absolute;left: 10px;top: 44px;font-size: 12px;">型号:WA-1X</span>' +
-                                    '<span style="position: absolute;left: 10px;top: 60px;font-size: 12px;">S/N</span>' +
-                                    '<div style="position: absolute;top: 80px;height: 23px;" id="bcTarget2" class="barcodeImg">'+barcodes+'</div>' +
-                                    '<span style="position: absolute;left: 10px;top: 108px;font-size: 12px;width: 116px;text-align: center;" id="barcodeId">'+machineBarcode+'</span>' +
-                                    '<img style="position: absolute;right: 10px;top:24px;width: 78px;height: 78px;" id="qrcodeImg" src="'+machineQrcode+'" /> ' +
-                                    '<span style="position: absolute;right: 26px;top: 108px;font-size: 12px;">no:4295</span> ' +
-                                    '</div>');
-                        }
-                        updatePrint(machineBarcode);
                     })
-                $("#printlist").printArea();
-                $("#printlist").html("");
+                if(prints != ""){
+                    $("#printlist").printArea();
+                    $("#printlist").html("");
+                }else{
+                    alert("未选中需要打印的条形码");
+                }
+                prints = "";
             /*$.ajax({
                     cache: true,
                     type: "POST",
@@ -207,50 +221,38 @@
                 latestMachine();
             },2000);
             function  latestMachine() {
-                $.ajax({
-                    cache: true,
-                    type: "POST",
-                    url: "${path}/admin/machine/_LatestMachine_list",
-                    data:{machineId : $("#machineId").val()},// 你的formid
-                    success: function(data){
-                        if(data != null){
-                            $.each(data,function(i,value) {
-                                if(i+1 == data.length){
-                                    $("#machineId").val(value.machineId);
-                                }
-                                $("#listid").prepend('<td class="text-c" width="10">'+value.machineBarcode+'</td>' +
-                                        '<td class="td-manage text-c"> <a onclick="machineLogs('+value.machineId+');" title="生产流程" href="javascript:;"  class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe667;</i></a> </td>');
-                            });
-                        }
+                var machineIsPrint = $("#machineIsPrint").val();
+                if(machineIsPrint == 2){
+                    $.ajax({
+                        cache: true,
+                        type: "POST",
+                        url: "${path}/admin/machine/_LatestMachine_list",
+                        data:{machineId : $("#machineId").val()},// 你的formid
+                        success: function(data){
+                            if(data != null){
+                                $.each(data,function(i,value) {
+                                    if(i+1 == data.length){
+                                        $("#machineId").val(value.machineId);
+                                    }
+                                    $("#listid").prepend('<tr><td width="2"> ' +
+                                            '<input name="checkbox" type="checkbox" value="'+value.machineBarcode+value.machineQrcode+value.machineProduceType+'" > </td>' +
+                                            '<td class="text-c" width="10">'+value.machineBarcode+'</td>' +
+                                            '<td class="td-manage text-c"> <a onclick="machineLogs('+value.machineId+');" title="生产流程" href="javascript:;"  class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe667;</i></a> </td></tr>');
 
-                    },
-                    error: function(){
-                        console.log("查询最新机器失败!");
-                    }
-                });
-            }
 
+                                });
+                            }
 
-            function   formatDate(now)   {
-                var time = new Date(now);
-                var   year=time.getFullYear();
-                var   month=time.getMonth()+1;
-                var   date=time.getDate();
-                var   hour=time.getHours();
-                var   minute=time.getMinutes();
-                var   second=time.getSeconds();
-                if(month < 10){
-                    month = "0"+month;
-                }
-                if(date < 10){
-                    date = "0"+date;
-                }
-                if(minute < 10){
-                    minute = "0"+minute;
+                        },
+                        error: function(){
+                            console.log("查询最新机器失败!");
+                        }
+                    });
                 }
-                return   year+"-"+month+"-"+date;
+
             }
 
+
                 function updatePrint(machineBarcode){
                     $.ajax({
                         "type" : "post",