瀏覽代碼

Merge branch 'master' of http://git.iamberry.com/hexiugang/iamberry-common-parent

# Conflicts:
#	watero-rst-web/src/main/java/com/iamberry/rst/controllers/pts/AdminMachineController.java
#	watero-rst-web/src/main/webapp/WEB-INF/views/pts/machine/addRenovationMachine.ftl
liujiankang 7 年之前
父節點
當前提交
c28c6a4785

+ 37 - 20
watero-rst-web/src/main/java/com/iamberry/rst/controllers/pts/AdminMachineController.java

@@ -718,29 +718,29 @@ public class AdminMachineController {
         String num = null;
         for (int i = 0; i < number; i++) {
             machineNumber++;
-            switch (String.valueOf(machineNumber).length()) {
-                case 0:
-                    num = "00001";
-                    break;
-                case 1:
-                    num = "0000" + String.valueOf(machineNumber);
-                    break;
-                case 2:
-                    num = "000" + String.valueOf(machineNumber);
-                    break;
-                case 3:
-                    num = "00" + String.valueOf(machineNumber);
-                    break;
-                case 4:
-                    num = "00" + String.valueOf(machineNumber);
-                    break;
-                case 5:
-                    num = String.valueOf(machineNumber);
-                    break;
-            }
             String qrCodeUrl = null;
             //判断机器是水机or牙刷
             if(productType == 3){
+                switch (String.valueOf(machineNumber).length()) {
+                    case 0:
+                        num = "00001";
+                        break;
+                    case 1:
+                        num = "0000" + String.valueOf(machineNumber);
+                        break;
+                    case 2:
+                        num = "000" + String.valueOf(machineNumber);
+                        break;
+                    case 3:
+                        num = "00" + String.valueOf(machineNumber);
+                        break;
+                    case 4:
+                        num = "00" + String.valueOf(machineNumber);
+                        break;
+                    case 5:
+                        num = String.valueOf(machineNumber);
+                        break;
+                }
                 //获取项目地址
                 WebApplicationContext webApplicationContext = ContextLoader.getCurrentWebApplicationContext();
                 ServletContext servletContext = webApplicationContext.getServletContext();
@@ -758,6 +758,23 @@ public class AdminMachineController {
                         qrCodeUrl = tempContextUrl +ResultInfo.QRCODE_TOOTH_IMAGE+ "/"+berQrcode+num+".png";
                     }
             }else{
+                switch (String.valueOf(machineNumber).length()) {
+                    case 0:
+                        num = "0001";
+                        break;
+                    case 1:
+                        num = "000" + String.valueOf(machineNumber);
+                        break;
+                    case 2:
+                        num = "00" + String.valueOf(machineNumber);
+                        break;
+                    case 3:
+                        num = "0" + String.valueOf(machineNumber);
+                        break;
+                    case 4:
+                        num = String.valueOf(machineNumber);
+                        break;
+                }
                   /*获取公众号信息*/
                 WechatMp wechatMp = produceService.getWechatMpById(produce.getWechatMpId());
                 String json = String.format(NameUtils.QR_LIMIT_STR_SCENE, ResultInfo.barCodePrefix + berQrcode + num);

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

@@ -348,7 +348,7 @@ public class MachineController {
 
 
     /**
-     * 根据barcode查询机器信息
+     * 根据barcode查询机器信息(电动牙刷项目也调用此功能)
      * @param request
      * @return
      */
@@ -365,6 +365,10 @@ public class MachineController {
             rsj.addResponseKeyValue("isBeing",1);
             rsj.addResponseKeyValue("productType",ptsMachine.getMachineProduceType() == 1?"净水机":"冲奶机");
             rsj.addResponseKeyValue("producedTime",ptsMachine.getMachineProducedTime() == null?null:ptsMachine.getMachineProducedTime().getTime());
+            rsj.addResponseKeyValue("productId",ptsMachine.getMachineProduceId());//产品id
+            /*rsj.addResponseKeyValue("producePattern",ptsMachine.getProducePattern());//产品型号前俩位
+            rsj.addResponseKeyValue("produceModel",ptsMachine.getProduceModel());//产品型号后俩位
+            rsj.addResponseKeyValue("produceName",ptsMachine.getProduceName());//产品名*/
         }else{
             rsj.addResponseKeyValue("isBeing",2);
         }

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

@@ -1,424 +1,424 @@
 <!DOCTYPE html>
 <html>
-	<head>
-		<meta charset="UTF-8">
-		<title></title>
-        <#include "/base/list_base.ftl">
-		<style>
-            *{padding: 0;margin: 0;}
-			.my-input{border: 1px solid rgba(0,0,0,.1);padding: 1px 5px;height: 32px;margin-right: 10px;}
-			.my-input::-webkit-input-placeholder,.my-select{color: #dcdcdc;}
-			.my-select{border: 1px solid rgba(0,0,0,.1);padding:6px 50px 6px 15px;height: 34px;margin: 0 10px; -webkit-appearance:none;appearance:none;background: url(${path}/common/images/pts/select-1.png) right center no-repeat;background-size:auto 100%;}
-			.my-btn-search{border: 1px solid #32a3d8;padding: 1px 25px;height: 32px;background-color: #32a3d8;color: #fff;}
-            .barcodeImg{margin:10px 0px}
-			.isprint{width: 200px;height:50px;}
-            .background{background-color: #0a6999}
-		</style>
-	</head>
-	<body>
-    <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
-        <span class="c-gray en">&gt;</span> PST管理
-        <span class="c-gray en">&gt;</span> 机器打印列表
-        <a class="btn radius r" style="line-height:1.6em;margin-top:3px;background: #32a3d8;color: #fff;border:1px solid #32a3d8;" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
-    </nav>
-		<div class="text-c" style="margin-top: 20px;">
-			<form action="${path}/admin/machine/_machine_print_list" method="post">
-
-				<#--<div id="havePrint" class="isprint background" onclick="selectIsPrint(1);"><span>未打印</span></div>
-                <div id="notPrint" class="isprint" onclick="selectIsPrint(2);"><span>已打印</span></div>-->
-                    <div id="HuiTab-demo1" class="HuiTab">
-                        <div class="tabBar cl">
-                            <span id="notPrint" onclick="selectIsPrint(1);" class="allOrder">未打印</span>
-                            <span id="havePrint" onclick="selectIsPrint(2);" class="returnOrderEtc">已打印</span>
-                        </div>
-                    </div>
-                <input class="my-input" type="hidden" id="machineIsPrint" name="machineIsPrint" />
-                <input  class="my-input" type="text" value="每个二维码打印数量:" readonly="readonly" style="border: 0;margin-top: 8px;margin-right: 0"/>
-                <input class="my-input" type="text" id="settingNumber" name="printNumber" value="3" placeholder="打印数量" style="margin-top: 10px;"/>
-                <button type="button" class="my-btn-search" onclick="printList();" style="cursor:pointer; margin-right: 50px;margin-top: 10px;">打印</button>
-                <button id="updatePrintId" type="button" class="my-btn-search" onclick="batchUpdatePring();" style="cursor:pointer; margin-right: 50px;margin-top: 10px;">修改为已打印</button>
-			</form>
-		</div>
-		<div class="mt-2" style="margin: 20px; " >
-            <div style="width: 55%;margin: 0 auto; ">
-                <table class="table table-border table-bordered table-bg table-hover table-sort" >
-                    <thead>
-                    <tr class="text-c">
-                        <th width="1"><input name='checkbox' type='checkbox' value='' id="all" ></th>
-                        <th width="40">设备尾号</th>
-                        <th width="40">产品条码</th>
-                        <th width="70">产品名/型号</th>
-                        <th width="10">生产时间</th>
-                        <th width="20">操作</th>
-                    </tr>
-                    </thead>
-                    <tbody id="listid">
+<head>
+    <meta charset="UTF-8">
+    <title></title>
+<#include "/base/list_base.ftl">
+    <style>
+        *{padding: 0;margin: 0;}
+        .my-input{border: 1px solid rgba(0,0,0,.1);padding: 1px 5px;height: 32px;margin-right: 10px;}
+        .my-input::-webkit-input-placeholder,.my-select{color: #dcdcdc;}
+        .my-select{border: 1px solid rgba(0,0,0,.1);padding:6px 50px 6px 15px;height: 34px;margin: 0 10px; -webkit-appearance:none;appearance:none;background: url(${path}/common/images/pts/select-1.png) right center no-repeat;background-size:auto 100%;}
+        .my-btn-search{border: 1px solid #32a3d8;padding: 1px 25px;height: 32px;background-color: #32a3d8;color: #fff;}
+        .barcodeImg{margin:10px 0px}
+        .isprint{width: 200px;height:50px;}
+        .background{background-color: #0a6999}
+    </style>
+</head>
+<body>
+<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
+    <span class="c-gray en">&gt;</span> PST管理
+    <span class="c-gray en">&gt;</span> 机器打印列表
+    <a class="btn radius r" style="line-height:1.6em;margin-top:3px;background: #32a3d8;color: #fff;border:1px solid #32a3d8;" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
+</nav>
+<div class="text-c" style="margin-top: 20px;">
+    <form action="${path}/admin/machine/_machine_print_list" method="post">
+
+    <#--<div id="havePrint" class="isprint background" onclick="selectIsPrint(1);"><span>未打印</span></div>
+    <div id="notPrint" class="isprint" onclick="selectIsPrint(2);"><span>已打印</span></div>-->
+        <div id="HuiTab-demo1" class="HuiTab">
+            <div class="tabBar cl">
+                <span id="notPrint" onclick="selectIsPrint(1);" class="allOrder">未打印</span>
+                <span id="havePrint" onclick="selectIsPrint(2);" class="returnOrderEtc">已打印</span>
+            </div>
+        </div>
+        <input class="my-input" type="hidden" id="machineIsPrint" name="machineIsPrint" />
+        <input  class="my-input" type="text" value="每个二维码打印数量:" readonly="readonly" style="border: 0;margin-top: 8px;margin-right: 0"/>
+        <input class="my-input" type="text" id="settingNumber" name="printNumber" value="3" placeholder="打印数量" style="margin-top: 10px;"/>
+        <button type="button" class="my-btn-search" onclick="printList();" style="cursor:pointer; margin-right: 50px;margin-top: 10px;">打印</button>
+        <button id="updatePrintId" type="button" class="my-btn-search" onclick="batchUpdatePring();" style="cursor:pointer; margin-right: 50px;margin-top: 10px;">修改为已打印</button>
+    </form>
+</div>
+<div class="mt-2" style="margin: 20px; " >
+    <div style="width: 55%;margin: 0 auto; ">
+        <table class="table table-border table-bordered table-bg table-hover table-sort" >
+            <thead>
+            <tr class="text-c">
+                <th width="1"><input name='checkbox' type='checkbox' value='' id="all" ></th>
+                <th width="40">设备尾号</th>
+                <th width="40">产品条码</th>
+                <th width="70">产品名/型号</th>
+                <th width="10">生产时间</th>
+                <th width="20">操作</th>
+            </tr>
+            </thead>
+            <tbody id="listid">
+            <#if machineIsPrint == '1'>
+                <#assign machineList = machineList />
+            <#else >
+                <#assign machineList = page.dataList />
+            </#if>
+            <#if machineList?? &&  (machineList?size > 0) >
+                <#list machineList as list>
+                <tr class="text-c" id="${list.machineBarcode }">
+                    <td width="2">
+                        <input name='checkbox' type='checkbox' value='${list.machineBarcode }' machineId='${list.machineId }'>
+                        <input type="hidden" value="${list.machineId + 1000000 }" id="${list.machineBarcode + 'Id'}">
+                        <input type="hidden" value="${list.machineQrcode}" id="machineQrcode${list.machineId }">
+                        <input type="hidden" value="${list.machineProduceType}" id="machineProduceType${list.machineId }">
+                    </td>
+                    <td class="text-c" style="font-size: 24px" width="10">${list.machineBarcode?substring(list.machineBarcode?length-4) }</td>
+                    <td class="text-c" width="10">${list.machineBarcode }</td>
+                    <td class="text-c" width="6">
+                    ${list.produceName }/${list.producePattern }-${list.produceModel }
+                    </td>
+                    <td>${(list.machineCreateTime?string("yyyy-MM-dd HH:mm:ss"))!''}</td>
+                    <!-- 遍历操作 -->
+                    <td class="td-manage text-c">
                         <#if machineIsPrint == '1'>
-                            <#assign machineList = machineList />
-                        <#else >
-                            <#assign machineList = page.dataList />
-                        </#if>
-                        <#if machineList?? &&  (machineList?size > 0) >
-                        <#list machineList as list>
-                            <tr class="text-c" id="${list.machineBarcode }">
-                                <td width="2">
-                                    <input name='checkbox' type='checkbox' value='${list.machineBarcode }' machineId='${list.machineId }'>
-                                    <input type="hidden" value="${list.machineId + 1000000 }" id="${list.machineBarcode + 'Id'}">
-                                    <input type="hidden" value="${list.machineQrcode}" id="machineQrcode${list.machineId }">
-                                    <input type="hidden" value="${list.machineProduceType}" id="machineProduceType${list.machineId }">
-                                </td>
-                                <td class="text-c" style="font-size: 24px" width="10">${list.machineBarcode?substring(list.machineBarcode?length-4) }</td>
-                                <td class="text-c" width="10">${list.machineBarcode }</td>
-                                <td class="text-c" width="6">
-                                ${list.produceName }/${list.producePattern }-${list.produceModel }
-                                </td>
-                                <td>${(list.machineCreateTime?string("yyyy-MM-dd HH:mm:ss"))!''}</td>
-                                <!-- 遍历操作 -->
-                                <td class="td-manage text-c">
-                                    <#if machineIsPrint == '1'>
-                                        <a onclick="updatePrint('${list.machineBarcode}',true);" title="修改为已打印" href="javascript:;"  class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6a7;</i></a>
-                                    </#if>
-                                    <a onclick="barCodePrint('${list.machineBarcode }','${list.machineId }');" title="打印" href="javascript:;"  class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe652;</i></a>
-                                </td>
-                            </tr>
-                        </#list>
-                        <#else>
-                        <tr id="noMachineTr"><td colspan="6" class="td-manage text-c" >暂时没有机器,请添加!</td></tr>
+                            <a onclick="updatePrint('${list.machineBarcode}',true);" title="修改为已打印" href="javascript:;"  class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6a7;</i></a>
                         </#if>
-                    </tbody>
-                </table>
-
-                <#if machineIsPrint == '2'>
-                    <tfoot>
-                        <div style="margin-top: 20px"><#include "/base/page_util.ftl"></div>
-                    </tfoot>
-                </#if>
-            </div>
-
-			<input type="hidden" value="${machineId!''}" name="machineId" id="machineId">
-            <input type="hidden" value="" name="codeId" id="codeId">
-            <div style="position: absolute;top: 80px;height: 23px;display:none;" id="bcTarget" class="barcodeImg"></div>
-			<div  style="display:none;" >
-				<div id="printlist">
-                </div>
-			</div>
-		</div>
-        <script type="text/javascript" src="${path}/common/lib/jquery.PrintArea/jquery.PrintArea.js"></script>
-        <script type="text/javascript" src="${path}/common/lib/jquery/1.9.1/jquery-barcode.js"></script>
-
-		<script type="text/javascript">
-            $("#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);
-                }
-                if(${machineIsPrint} == '2'){
-                    $("#havePrint").attr("class", "current");
-                    $("#machineIsPrint").val(2);
-                    $("#updatePrintId").hide();//隐藏修改打印按钮
-                }
-
-            function selectIsPrint(printState) {
-                if(printState == 1){
-                    $("#notPrint").attr("class", "current");
-                    $("#havePrint").removeClass("current");
-                }else if(printState == 2){
-                    $("#havePrint").attr("class", "current");
-                    $("#notPrint").removeClass("current");
-                }
-
-                $("#machineIsPrint").val(printState);
-                window.location.href=root_path + '/admin/machine/_machine_print_list?machineIsPrint='+printState;
-            }
-                //生成128条形码
-                function code128(barcode){
-                    $("#codeId").val(barcode);
-                    $("#bcTarget").empty().barcode($("#codeId").val(), "code128",{
-                        barWidth:1, barHeight:23,showHRI:false
-                    });
-
-                }
-            function  printList() {
-                var machineBarcode = null;
-                var machineQrcode = null;
-                var machineProduceType = null;
-                var prints = "";
-                var numbers = 0;
-                var settingNumber = $("#settingNumber").val();
-
-                $("input[name='checkbox']:checkbox:checked").each(function () {
-                    prints += $(this).val();
-                    numbers = numbers+parseInt(settingNumber);
-                    var machineId = $(this).attr("machineId");
-
-                    machineBarcode = $(this).val();
-                    machineQrcode = $("#machineQrcode"+machineId).val();
-
-                    machineProduceType = $("#machineProduceType"+machineId).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);*/
-
-
-                    var produce = getProduce(machineId);
-                    var producePattern =  produce.producePattern;    //获取产品型号前两位
-                    var produceModel =  produce.produceModel;        //获取产品型号后两位
-                    var produceName = produce.produceName;            //获取产品名称
-
-                    var machineNo = "NO." + $("#"+machineBarcode+"Id").val();
-                    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: 242px;height: 120px;position: relative;">' +
-                                    '<span style="position: absolute;left: 10px;font-size: 14px;">'+produceName+'</span>' +
-                                    '<span style="position: absolute;top: 25px;left: 10px;font-size: 12px;">型号:'+producePattern+'-'+produceModel+'</span>' +
-                                    '<span style="position: absolute;top: 40px;left: 10px;font-size: 12px;">S/N</span>' +
-                                    '<div style="position: absolute;left: 5px;top: 64px;height: 30px;" id="bcTarget2" class="barcodeImg">'+barcodes+'</div>' +
-                                    '<span style="position: absolute;top: 85px;left: 10px;font-size: 12px;width: 116px;text-align: center;" id="barcodeId">'+machineBarcode+'</span>' +
-                                    '<img style="position: absolute;right: 5px;top:18px;width: 76px;height: 76px;" id="qrcodeImg" src="'+machineQrcode+'" /> ' +
-                                    '<span style="position: absolute;right: 9px;top: 85px;font-size: 12px;">'+ machineNo +'</span>' +
-                                    '</div>');
-                        /*}*/
-                        /*if (machineProduceType == 2) {//冲奶机模板
-                            $("#printlist").append('<div style="width: 242px;height: 120px;position: relative;">' +
-                                    '<span style="position: absolute;left: 10px;font-size: 14px;">'+produceName+'</span>' +
-                                    '<span style="position: absolute;top: 25px;left: 10px;font-size: 12px;">型号:'+producePattern+'-'+produceModel+'</span>' +
-                                    '<span style="position: absolute;top: 40px;left: 10px;font-size: 12px;">S/N</span>' +
-                                    '<div style="position: absolute;left: 5px;top: 64px;height: 30px;" id="bcTarget2" class="barcodeImg">'+barcodes+'</div>' +
-                                    '<span style="position: absolute;top: 85px;left: 10px;font-size: 12px;width: 116px;text-align: center;" id="barcodeId">'+machineBarcode+'</span>' +
-                                    '<img style="position: absolute;right: 5px;top:18px;width: 76px;height: 76px;" id="qrcodeImg" src="'+machineQrcode+'" /> ' +
-                                    '<span style="position: absolute;right: 9px;top: 85px;font-size: 12px;">'+ machineNo +'</span>' +
-                                    '</div>');
-                        }*/
-                        if(${machineIsPrint} == '1')
-                        {
-                            updatePrint(machineBarcode,false);
-                            $("#" + machineBarcode).remove();
-                        }
-                    }
-                });
-                numbers = numbers - parseInt(settingNumber);
-
-                /*计算总打印数量*/
-                var num = $("#settingNumber").val();
-                var selectNum = $("#listid").find("input[name='checkbox']:checked").length;
-                var machinePrintNumber = parseInt(num)*parseInt(selectNum);
-
-                if(machinePrintNumber > 24){
-                    layer.msg('一次最多支持打印24张条形码', {icon: 2, time: 2000});
-                }else if (prints != ""){
-                    $("#printlist").printArea();
-                    $("#printlist").html("");
-                    layer.closeAll();
-                } else {
-                    layer.msg('未选中需要打印的条形码', {icon: 2, time: 2000});
-                }
-
-                $("#printlist").html("");  //未打印成功,需要清除数据
-
-                /*if (prints != "") {
-                    $("#printlist").printArea();
-                    $("#printlist").html("");
-                    layer.closeAll();
-                } else {
-                    layer.msg('未选中需要打印的条形码', {icon: 2, time: 2000});
+                        <a onclick="barCodePrint('${list.machineBarcode }','${list.machineId }');" title="打印" href="javascript:;"  class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe652;</i></a>
+                    </td>
+                </tr>
+                </#list>
+            <#else>
+            <tr id="noMachineTr"><td colspan="6" class="td-manage text-c" >暂时没有机器,请添加!</td></tr>
+            </#if>
+            </tbody>
+        </table>
+
+    <#if machineIsPrint == '2'>
+        <tfoot>
+        <div style="margin-top: 20px"><#include "/base/page_util.ftl"></div>
+        </tfoot>
+    </#if>
+    </div>
+
+    <input type="hidden" value="${machineId!''}" name="machineId" id="machineId">
+    <input type="hidden" value="" name="codeId" id="codeId">
+    <div style="position: absolute;top: 80px;height: 23px;display:none;" id="bcTarget" class="barcodeImg"></div>
+    <div  style="display:none;" >
+        <div id="printlist">
+        </div>
+    </div>
+</div>
+<script type="text/javascript" src="${path}/common/lib/jquery.PrintArea/jquery.PrintArea.js"></script>
+<script type="text/javascript" src="${path}/common/lib/jquery/1.9.1/jquery-barcode.js"></script>
+
+<script type="text/javascript">
+    $("#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);
+    }
+    if(${machineIsPrint} == '2'){
+        $("#havePrint").attr("class", "current");
+        $("#machineIsPrint").val(2);
+        $("#updatePrintId").hide();//隐藏修改打印按钮
+    }
+
+    function selectIsPrint(printState) {
+        if(printState == 1){
+            $("#notPrint").attr("class", "current");
+            $("#havePrint").removeClass("current");
+        }else if(printState == 2){
+            $("#havePrint").attr("class", "current");
+            $("#notPrint").removeClass("current");
+        }
+
+        $("#machineIsPrint").val(printState);
+        window.location.href=root_path + '/admin/machine/_machine_print_list?machineIsPrint='+printState;
+    }
+    //生成128条形码
+    function code128(barcode){
+        $("#codeId").val(barcode);
+        $("#bcTarget").empty().barcode($("#codeId").val(), "code128",{
+            barWidth:1, barHeight:23,showHRI:false
+        });
+
+    }
+    function  printList() {
+        var machineBarcode = null;
+        var machineQrcode = null;
+        var machineProduceType = null;
+        var prints = "";
+        var numbers = 0;
+        var settingNumber = $("#settingNumber").val();
+
+        $("input[name='checkbox']:checkbox:checked").each(function () {
+            prints += $(this).val();
+            numbers = numbers+parseInt(settingNumber);
+            var machineId = $(this).attr("machineId");
+
+            machineBarcode = $(this).val();
+            machineQrcode = $("#machineQrcode"+machineId).val();
+
+            machineProduceType = $("#machineProduceType"+machineId).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);*/
+
+
+            var produce = getProduce(machineId);
+            var producePattern =  produce.producePattern;    //获取产品型号前两位
+            var produceModel =  produce.produceModel;        //获取产品型号后两位
+            var produceName = produce.produceName;            //获取产品名称
+
+            var machineNo = "NO." + $("#"+machineBarcode+"Id").val();
+            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: 242px;height: 120px;position: relative;">' +
+                        '<span style="position: absolute;left: 10px;font-size: 14px;">'+produceName+'</span>' +
+                        '<span style="position: absolute;top: 25px;left: 10px;font-size: 12px;">型号:'+producePattern+'-'+produceModel+'</span>' +
+                        '<span style="position: absolute;top: 40px;left: 10px;font-size: 12px;">S/N</span>' +
+                        '<div style="position: absolute;left: 5px;top: 64px;height: 30px;" id="bcTarget2" class="barcodeImg">'+barcodes+'</div>' +
+                        '<span style="position: absolute;top: 85px;left: 10px;font-size: 12px;width: 116px;text-align: center;" id="barcodeId">'+machineBarcode+'</span>' +
+                        '<img style="position: absolute;right: 5px;top:18px;width: 76px;height: 76px;" id="qrcodeImg" src="'+machineQrcode+'" /> ' +
+                        '<span style="position: absolute;right: 9px;top: 85px;font-size: 12px;">'+ machineNo +'</span>' +
+                        '</div>');
+                /*}*/
+                /*if (machineProduceType == 2) {//冲奶机模板
+                    $("#printlist").append('<div style="width: 242px;height: 120px;position: relative;">' +
+                            '<span style="position: absolute;left: 10px;font-size: 14px;">'+produceName+'</span>' +
+                            '<span style="position: absolute;top: 25px;left: 10px;font-size: 12px;">型号:'+producePattern+'-'+produceModel+'</span>' +
+                            '<span style="position: absolute;top: 40px;left: 10px;font-size: 12px;">S/N</span>' +
+                            '<div style="position: absolute;left: 5px;top: 64px;height: 30px;" id="bcTarget2" class="barcodeImg">'+barcodes+'</div>' +
+                            '<span style="position: absolute;top: 85px;left: 10px;font-size: 12px;width: 116px;text-align: center;" id="barcodeId">'+machineBarcode+'</span>' +
+                            '<img style="position: absolute;right: 5px;top:18px;width: 76px;height: 76px;" id="qrcodeImg" src="'+machineQrcode+'" /> ' +
+                            '<span style="position: absolute;right: 9px;top: 85px;font-size: 12px;">'+ machineNo +'</span>' +
+                            '</div>');
                 }*/
-
-                prints = "";
-            }
-            //动态刷新是否有最新的机器
-            ref = setInterval(function(){
-                latestMachine();
-            },2000);
-            function  latestMachine() {
-                var machineIsPrint = $("#machineIsPrint").val();
-                if(machineIsPrint == 1){
-                    $.ajax({
-                        cache: true,
-                        type: "POST",
-                        url: "${path}/admin/machine/_LatestMachine_list",
-                        data:{machineId : $("#machineId").val()},// 你的formid
-                        success: function(data){
-                            if(data != null){
-                                $("#noMachineTr").remove();
-                                $.each(data,function(i,value) {
-                                    if(i+1 == data.length){
-                                        $("#machineId").val(value.machineId);
-                                    }
-                                    var machineName = value.produceName+"/"+value.producePattern+"-"+value.produceModel;
-                                    /*var machineType = "";
-                                    if(value.machineProduceType == 1){
-                                        machineType = "净水机";
-                                    }
-                                    if(value.machineProduceType == 2){
-                                        machineType = "冲奶机";
-                                    }*/
-                                    var private = value.machineBarcode.substr(value.machineBarcode.length-4);
-                                    var machineCreateTime = formatDate(value.machineCreateTime,"yyyy-MM-dd HH:mm:ss");
-                                    $("#listid").prepend('<tr class="text-c"><td width="2"> ' +
-                                            '<input name="checkbox" type="checkbox" value="'+value.machineBarcode+'"  machineId="'+value.machineId+'"> ' +
-                                            '<input type="hidden" value="'+value.machineId + 1000000 +'" id="'+value.machineBarcode + 'Id'+'"></td>' +
-                                            '<input type="hidden" value="'+value.machineQrcode+'" id="'+'machineQrcode'+value.machineId+'">' +
-                                            '<input type="hidden" value="'+value.machineProduceType+'" id="'+'machineProduceType'+value.machineId+'">' +
-                                            '<td class="text-c" style="font-size: 24px" width="10">'+private+'</td>' +
-                                            '<td class="text-c" width="10">'+value.machineBarcode+'</td>' +
-                                            '<td class="text-c" width="10">'+machineName+'</td>' +
-                                            '<td>'+machineCreateTime+'</td>' +
-                                            '<td class="td-manage text-c"> <a onclick="updatePrint('+value.machineBarcode+',true);" title="修改为已打印" href="javascript:;"  class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6a7;</i></a>' +
-                                            '<a onclick="barCodePrint('+'\''+value.machineBarcode+'\''+','+'\''+value.machineId+'\''+',);" title="打印" href="javascript:;"  class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe652;</i></a> </td></tr>');
-
-
-                                });
-                            }
-
-                        },
-                        error: function(){
-                            console.log("查询最新机器失败!");
-                        }
-                    });
+                if(${machineIsPrint} == '1')
+                {
+                    updatePrint(machineBarcode,false);
+                    $("#" + machineBarcode).remove();
                 }
-
             }
-
-
-                function updatePrint(machineBarcode,type){
-                    $.ajax({
-                        "type" : "post",
-                        "url" : "${path}/admin/machine/_update_print",
-                        "dataType" : "json",
-                        "data" :{machineBarcode : machineBarcode},
-                        "success" : function(data) {
-                            $("#"+machineBarcode).remove();
-                            if(type){
-                                layer.msg('修改成功', {icon: 1, time: 2000});
+        });
+        numbers = numbers - parseInt(settingNumber);
+
+        /*计算总打印数量*/
+        var num = $("#settingNumber").val();
+        var selectNum = $("#listid").find("input[name='checkbox']:checked").length;
+        var machinePrintNumber = parseInt(num)*parseInt(selectNum);
+
+        if(machinePrintNumber > 24){
+            layer.msg('一次最多支持打印24张条形码', {icon: 2, time: 2000});
+        }else if (prints != ""){
+            $("#printlist").printArea();
+            $("#printlist").html("");
+            layer.closeAll();
+        } else {
+            layer.msg('未选中需要打印的条形码', {icon: 2, time: 2000});
+        }
+
+        $("#printlist").html("");  //未打印成功,需要清除数据
+
+        /*if (prints != "") {
+            $("#printlist").printArea();
+            $("#printlist").html("");
+            layer.closeAll();
+        } else {
+            layer.msg('未选中需要打印的条形码', {icon: 2, time: 2000});
+        }*/
+
+        prints = "";
+    }
+    //动态刷新是否有最新的机器
+    ref = setInterval(function(){
+        latestMachine();
+    },2000);
+    function  latestMachine() {
+        var machineIsPrint = $("#machineIsPrint").val();
+        if(machineIsPrint == 1){
+            $.ajax({
+                cache: true,
+                type: "POST",
+                url: "${path}/admin/machine/_LatestMachine_list",
+                data:{machineId : $("#machineId").val()},// 你的formid
+                success: function(data){
+                    if(data != null){
+                        $("#noMachineTr").remove();
+                        $.each(data,function(i,value) {
+                            if(i+1 == data.length){
+                                $("#machineId").val(value.machineId);
                             }
-                        },
-                        "error":function(data){
-                            layer.msg('操作失败', {icon: 2, time: 2000});
-                        }
-                    });
-                }
+                            var machineName = value.produceName+"/"+value.producePattern+"-"+value.produceModel;
+                            /*var machineType = "";
+                            if(value.machineProduceType == 1){
+                                machineType = "净水机";
+                            }
+                            if(value.machineProduceType == 2){
+                                machineType = "冲奶机";
+                            }*/
+                            var private = value.machineBarcode.substr(value.machineBarcode.length-4);
+                            var machineCreateTime = formatDate(value.machineCreateTime,"yyyy-MM-dd HH:mm:ss");
+                            $("#listid").prepend('<tr class="text-c"><td width="2"> ' +
+                                    '<input name="checkbox" type="checkbox" value="'+value.machineBarcode+'"  machineId="'+value.machineId+'"> ' +
+                                    '<input type="hidden" value="'+value.machineId + 1000000 +'" id="'+value.machineBarcode + 'Id'+'"></td>' +
+                                    '<input type="hidden" value="'+value.machineQrcode+'" id="'+'machineQrcode'+value.machineId+'">' +
+                                    '<input type="hidden" value="'+value.machineProduceType+'" id="'+'machineProduceType'+value.machineId+'">' +
+                                    '<td class="text-c" style="font-size: 24px" width="10">'+private+'</td>' +
+                                    '<td class="text-c" width="10">'+value.machineBarcode+'</td>' +
+                                    '<td class="text-c" width="10">'+machineName+'</td>' +
+                                    '<td>'+machineCreateTime+'</td>' +
+                                    '<td class="td-manage text-c"> <a onclick="updatePrint('+value.machineBarcode+',true);" title="修改为已打印" href="javascript:;"  class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6a7;</i></a>' +
+                                    '<a onclick="barCodePrint('+'\''+value.machineBarcode+'\''+','+'\''+value.machineId+'\''+',);" title="打印" href="javascript:;"  class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe652;</i></a> </td></tr>');
+
+
+                        });
+                    }
 
-                function machineLogs(machineId) {
-                    window.location.href=root_path + '/admin/machine/_machine_logs_list?machineId='+machineId;
+                },
+                error: function(){
+                    console.log("查询最新机器失败!");
                 }
+            });
+        }
 
-            function batchUpdatePring(){
-                var a = new Array();
-                $("input[name='checkbox']:checkbox:checked").each(function(i) {
-                    a[i] = $(this).val().substring(0, 13);
-                })
-                $.ajax({
-                    "type" : "post",
-                    "url" : "${path}/admin/machine/_batchUpdate_print",
-                    "dataType" : "json",
-                    "data" :{machineBarcodes : ""+a},
-                    /*"data" :{machineBarcodes : JSON.stringify(a)},*/
-                    "success" : function(data) {
-                        layer.msg('修改成功!', {icon: 1,time:2000});
-                        location.replace(location.href);
-                    },
-                    "error":function(data){
-                        /*alert("操作失败,请联系管理员!");*/
-                        layer.msg('操作失败!', {icon: 2,time:2000});
-                    }
-                });
-            }
+    }
 
-            //单个打印条形码
-             function barCodePrint(barCode,machineId){
-                 var  machineBarcode = barCode;
-                 var machineQrcode = $("#machineQrcode"+machineId).val();
-                 var machineProduceType = $("#machineProduceType"+machineId).val();
-                 var machineNo = "NO." + $("#"+machineBarcode+"Id").val();
-                var settingNumber = $("#settingNumber").val();
-
-                 var produce = getProduce(machineId);
-                 var producePattern =  produce.producePattern;    //获取产品型号前两位
-                 var produceModel =  produce.produceModel;        //获取产品型号后两位
-                 var produceName = produce.produceName;            //获取产品名称
-
-                for (var i=0;i<settingNumber;i++){
-                    code128(machineBarcode);
-                    var barcodes = $("#bcTarget").html();
-
-                    /*if(machineProduceType == 1){//净水机模板*/
-                        $("#printlist").append('<div style="width: 242px;height: 120px;position: relative;">' +
-                                '<span style="position: absolute;left: 10px;font-size: 14px;">'+produceName+'</span>' +
-                                '<span style="position: absolute;top: 25px;left: 10px;font-size: 12px;">型号:'+producePattern+'-'+produceModel+'</span>' +
-                                '<span style="position: absolute;top: 40px;left: 10px;font-size: 12px;">S/N</span>' +
-                                '<div style="position: absolute;left: 5px;top: 64px;height: 30px;" id="bcTarget2" class="barcodeImg">'+barcodes+'</div>' +
-                                '<span style="position: absolute;top: 85px;left: 10px;font-size: 12px;width: 116px;text-align: center;" id="barcodeId">'+machineBarcode+'</span>' +
-                                '<img style="position: absolute;right: 5px;top:18px;width: 76px;height: 76px;" id="qrcodeImg" src="'+machineQrcode+'" /> ' +
-                                '<span style="position: absolute;right: 9px;top: 85px;font-size: 12px;">'+ machineNo +'</span>' +
-                                '</div>');
-                    /*}*/
-                    /*if(machineProduceType == 2){//冲奶机模板
-                        $("#printlist").append('<div style="width: 242px;height: 120px;position: relative;">' +
-                                '<span style="position: absolute;left: 10px;font-size: 14px;">'+produceName+'</span>' +
-                                '<span style="position: absolute;top: 25px;left: 10px;font-size: 12px;">型号:'+producePattern+'-'+produceModel+'</span>' +
-                                '<span style="position: absolute;top: 40px;left: 10px;font-size: 12px;">S/N</span>' +
-                                '<div style="position: absolute;left: 5px;top: 64px;height: 30px;" id="bcTarget2" class="barcodeImg">'+barcodes+'</div>' +
-                                '<span style="position: absolute;top: 85px;left: 10px;font-size: 12px;width: 116px;text-align: center;" id="barcodeId">'+machineBarcode+'</span>' +
-                                '<img style="position: absolute;right: 5px;top:18px;width: 76px;height: 76px;" id="qrcodeImg" src="'+machineQrcode+'" /> ' +
-                                '<span style="position: absolute;right: 9px;top: 85px;font-size: 12px;">'+ machineNo +'</span>' +
-                                '</div>');
-                    }*/
 
+    function updatePrint(machineBarcode,type){
+        $.ajax({
+            "type" : "post",
+            "url" : "${path}/admin/machine/_update_print",
+            "dataType" : "json",
+            "data" :{machineBarcode : machineBarcode},
+            "success" : function(data) {
+                $("#"+machineBarcode).remove();
+                if(type){
+                    layer.msg('修改成功', {icon: 1, time: 2000});
                 }
-                 if(settingNumber > 24){
-                     layer.msg('一次最多支持打印24张条形码', {icon: 2, time: 2000});
-                 }else{
-                     $("#printlist").printArea();
-                     $("#printlist").html("");
-                     if(${machineIsPrint} == '1')
-                     {
-                         updatePrint(machineBarcode, false);
-                         $("#" + machineBarcode).remove();
-                     }
-                 }
-
+            },
+            "error":function(data){
+                layer.msg('操作失败', {icon: 2, time: 2000});
             }
-
-            /*获取产品信息*/
-            function getProduce(machineId){
-                var produce = new Object();
-                produce.producePattern = "";
-                produce.produceModel = "";
-                produce.produceFeature = "";
-                produce.produceName = "";
-                $.ajax({
-                    type: "POST",
-                    url: "${path}/admin/machine/_getProduce_print",
-                    async: false,
-                    data:{machineId : machineId},
-                    success: function(data){
-                        if(data != null){
-                            produce.producePattern = data.producePattern;
-                            produce.produceModel = data.produceModel;
-                            produce.produceFeature = data.produceFeature;
-                            produce.produceName = data.produceName;
-                        }
-                    },
-                    error: function(){
-                        console.log("查询产品型号信息失败!");
-                    }
-                });
-                return produce;
+        });
+    }
+
+    function machineLogs(machineId) {
+        window.location.href=root_path + '/admin/machine/_machine_logs_list?machineId='+machineId;
+    }
+
+    function batchUpdatePring(){
+        var a = new Array();
+        $("input[name='checkbox']:checkbox:checked").each(function(i) {
+            a[i] = $(this).val().substring(0, 13);
+        })
+        $.ajax({
+            "type" : "post",
+            "url" : "${path}/admin/machine/_batchUpdate_print",
+            "dataType" : "json",
+            "data" :{machineBarcodes : ""+a},
+            /*"data" :{machineBarcodes : JSON.stringify(a)},*/
+            "success" : function(data) {
+                layer.msg('修改成功!', {icon: 1,time:2000});
+                location.replace(location.href);
+            },
+            "error":function(data){
+                /*alert("操作失败,请联系管理员!");*/
+                layer.msg('操作失败!', {icon: 2,time:2000});
+            }
+        });
+    }
+
+    //单个打印条形码
+    function barCodePrint(barCode,machineId){
+        var  machineBarcode = barCode;
+        var machineQrcode = $("#machineQrcode"+machineId).val();
+        var machineProduceType = $("#machineProduceType"+machineId).val();
+        var machineNo = "NO." + $("#"+machineBarcode+"Id").val();
+        var settingNumber = $("#settingNumber").val();
+
+        var produce = getProduce(machineId);
+        var producePattern =  produce.producePattern;    //获取产品型号前两位
+        var produceModel =  produce.produceModel;        //获取产品型号后两位
+        var produceName = produce.produceName;            //获取产品名称
+
+        for (var i=0;i<settingNumber;i++){
+            code128(machineBarcode);
+            var barcodes = $("#bcTarget").html();
+
+            /*if(machineProduceType == 1){//净水机模板*/
+            $("#printlist").append('<div style="width: 242px;height: 120px;position: relative;">' +
+                    '<span style="position: absolute;left: 10px;font-size: 14px;">'+produceName+'</span>' +
+                    '<span style="position: absolute;top: 25px;left: 10px;font-size: 12px;">型号:'+producePattern+'-'+produceModel+'</span>' +
+                    '<span style="position: absolute;top: 40px;left: 10px;font-size: 12px;">S/N</span>' +
+                    '<div style="position: absolute;left: 5px;top: 64px;height: 30px;" id="bcTarget2" class="barcodeImg">'+barcodes+'</div>' +
+                    '<span style="position: absolute;top: 85px;left: 10px;font-size: 12px;width: 116px;text-align: center;" id="barcodeId">'+machineBarcode+'</span>' +
+                    '<img style="position: absolute;right: 5px;top:18px;width: 76px;height: 76px;" id="qrcodeImg" src="'+machineQrcode+'" /> ' +
+                    '<span style="position: absolute;right: 9px;top: 85px;font-size: 12px;">'+ machineNo +'</span>' +
+                    '</div>');
+            /*}*/
+            /*if(machineProduceType == 2){//冲奶机模板
+                $("#printlist").append('<div style="width: 242px;height: 120px;position: relative;">' +
+                        '<span style="position: absolute;left: 10px;font-size: 14px;">'+produceName+'</span>' +
+                        '<span style="position: absolute;top: 25px;left: 10px;font-size: 12px;">型号:'+producePattern+'-'+produceModel+'</span>' +
+                        '<span style="position: absolute;top: 40px;left: 10px;font-size: 12px;">S/N</span>' +
+                        '<div style="position: absolute;left: 5px;top: 64px;height: 30px;" id="bcTarget2" class="barcodeImg">'+barcodes+'</div>' +
+                        '<span style="position: absolute;top: 85px;left: 10px;font-size: 12px;width: 116px;text-align: center;" id="barcodeId">'+machineBarcode+'</span>' +
+                        '<img style="position: absolute;right: 5px;top:18px;width: 76px;height: 76px;" id="qrcodeImg" src="'+machineQrcode+'" /> ' +
+                        '<span style="position: absolute;right: 9px;top: 85px;font-size: 12px;">'+ machineNo +'</span>' +
+                        '</div>');
+            }*/
+
+        }
+        if(settingNumber > 24){
+            layer.msg('一次最多支持打印24张条形码', {icon: 2, time: 2000});
+        }else{
+            $("#printlist").printArea();
+            $("#printlist").html("");
+            if(${machineIsPrint} == '1')
+            {
+                updatePrint(machineBarcode, false);
+                $("#" + machineBarcode).remove();
+            }
+        }
+
+    }
+
+    /*获取产品信息*/
+    function getProduce(machineId){
+        var produce = new Object();
+        produce.producePattern = "";
+        produce.produceModel = "";
+        produce.produceFeature = "";
+        produce.produceName = "";
+        $.ajax({
+            type: "POST",
+            url: "${path}/admin/machine/_getProduce_print",
+            async: false,
+            data:{machineId : machineId},
+            success: function(data){
+                if(data != null){
+                    produce.producePattern = data.producePattern;
+                    produce.produceModel = data.produceModel;
+                    produce.produceFeature = data.produceFeature;
+                    produce.produceName = data.produceName;
+                }
+            },
+            error: function(){
+                console.log("查询产品型号信息失败!");
             }
-        </script>
+        });
+        return produce;
+    }
+</script>
 
 
-	</body>
+</body>
 </html>