wxw
2024-12-14 41c5a191f9419bfa03e3ba0c18bb00d3172d6162
HTML/views/WareHouseSetting/Pallets.html
@@ -145,11 +145,11 @@
                     fixed: 'left'
                  }, {
                     field: 'PalletNo',
                     title: '托盘条码',
                     title: '桶号',
                     align: 'center',
                  }, {
                     field: 'Status',
                     title: '条码状态',
                     title: '桶状态',
                     align: 'center',
                     templet:function(d){
                        switch (d.Status) {
@@ -179,13 +179,15 @@
                     templet:function(d){
                        return formatDate(d.LastUse);
                     }
                  }, {
                     title: '操作',
                     fixed: 'right',
                     width: 220,
                     align: 'center',
                     toolbar: '#table-content-list'
                  }]
                  }
                  // , {
                  //    title: '操作',
                  //    fixed: 'right',
                  //    width: 220,
                  //    align: 'center',
                  //    toolbar: '#table-content-list'
                  // }
               ]
               ],
            });
            //监听搜索
@@ -220,15 +222,13 @@
                  }, function() {});
               }
            });
            
            var   active = {
               add: function() {
                  layer.open({
                     type: 2,
                     title: '打印托盘条码',
                     title: '添加桶号',
                     content: 'PalletsPrintFrom.html',
                     maxmin: true,
                     area: ['600px', '300px'],
@@ -242,31 +242,29 @@
                           var field = data.field; //获取提交的字段
                           console.log(field);
                           if (isTrue = true) {
                              isTrue = false;
                              var html = "";
                              var xun = 0;
                              document.getElementById('print').innerHTML="";
                              for(var i=0;i<field.GroupCount;i++){
                                 for(var j=0;j<field.SameCount;j++){
                                    html ="<div class=\"layui-form\" lay-filter=\"layuiadmin-app-form-list\" id=\"print\" style=\"width: 50%; text-align: center;padding-top: 10%;margin-left: 0%;\">\n"+
                                    "<div class=\"layui-form-item\">\n"+
                                    "<div class=\"layui-inline\">\n"+
                                    "<div class=\"\">\n"+
                                    "<img  id=\"imgBar\" width=\"245px\" height=\"120px\"/></div>\n"+
                                    "</div>\n"+
                                    "</div>\n"+
                                    "</div>\n"+
                                    "<div style=\"page-break-after: always;\"></div>\n"+
                                    "</div>" ;
                                    document.getElementById('print').innerHTML+=html;
                                    document.getElementById('imgBar').id="imgBar"+xun;
                                    xun+=1
                              isTrue = false;
                              var param = {
                                 PalletNo:field.StockCode,
                                 LocatNo:field.LocatNo
                              };
                              synData(IP + "/Sys/AddPallets", param, 'post', function(res) {
                                 console.log(res);
                                 if (res.code == 0) { //成功
                                    layer.msg("添加成功", {
                                       icon: 1,
                                       time: 2000 //2秒关闭(如果不配置,默认是3秒)
                                    }, function() {
                                       layer.close(index);
                                    });
                                 } else{
                                    layer.msg(res.msg, {
                                       icon: 2,
                                       time: 2000 //2秒关闭(如果不配置,默认是3秒)
                                    }, function() {});
                                 }
                              }
                              GetimgBar(field.StockCode,field.GroupCount,field.SameCount);
                              layer.close(index);
                              });
                           }   
                        });  
                        submit.trigger('click');
@@ -282,162 +280,30 @@
               var type = $(this).data('type');
               active[type] ? active[type].call(this) : '';
            });
            //获取添加条形码
            function GetimgBar(StockCode,GroupCount,SameCount){
               var param = {
                  PalletNo:StockCode,
                  GroupCount: parseInt(GroupCount),
                  SameCount:parseInt(SameCount),
               };
               console.log(param);
               synData(IP + "/Sys/GetImgBar", param, 'post', function(res) {
                  console.log(res);
                  if (res.code == 0) { //成功
                     for(var i=0;i<res.data.length;i++){
                        $("#"+"imgBar"+i).attr("src", res.data[i]);
                     }
                     AddPallets(StockCode,GroupCount);
                  } else { //不成功
                     layer.msg(res.msg, {
                        icon: 2,
                        time: 2000 //2秒关闭(如果不配置,默认是3秒)
                     }, function() {});
                  }
               });
            };
            //添加条形码
            function AddPallets(StockCode,GroupCount){
            function AddPallets(StockCode,LocatNo){
               //提交 Ajax 成功后,静态更新表格中的数据
               var param = {
                  GroupCount:parseInt(GroupCount),
                  PalletNo:StockCode,
                  LocatNo:LocatNo
               };
               synData(IP + "/Sys/AddPallets", param, 'post', function(res) {
                  console.log(res);
                  if (res.code == 0) { //成功
                     $("#print").print();
                  } else if(res.code == 1){
                     layer.msg(res.msg, {
                     layer.msg("添加成功", {
                        icon: 2,
                        time: 2000 //2秒关闭(如果不配置,默认是3秒)
                     }, function() {});
                  } else { //不成功
                     layer.msg(res.statusText, {
                  } else{
                     layer.msg(res.msg, {
                        icon: 2,
                        time: 2000 //2秒关闭(如果不配置,默认是3秒)
                     }, function() {});
                  }
               });
            };
            //获取补打条形码
            function GetimgBar1(StockCode,GroupCount,SameCount){
               var param = {
                  PalletNo:StockCode,
                  GroupCount:parseInt(GroupCount),
                  SameCount:parseInt(SameCount),
               };
               synData(IP + "/Sys/GetImgBarReprint", param, 'post', function(res) {
                  console.log(res);
                  if (res.code == 0) { //成功
                     var ok=false;
                     for(var i=0;i<res.data.length;i++){
                        $("#"+"imgBar"+i).attr("src", res.data[i]);
                        if(i==(res.data.length-1)){
                           ok=true;
                        }
                     }
                     if(ok){
                        $("#print").print();
                     }
                  } else { //不成功
                     layer.msg(res.msg, {
                        icon: 2,
                        time: 2000 //2秒关闭(如果不配置,默认是3秒)
                     }, function() {});
                  }
               })
            };
            table.on('tool(LAY-app-content-list)', function(obj) {
               var data = obj.data;
               if (obj.event === 'edit') {
                  layer.open({
                     type: 2,
                     title: '托盘时间线',
                     content: 'PalletsTimeLine.html?PalletNo=' +  data.PalletNo,
                     maxmin: true,
                     area: ['700px', '650px'],
                     btn: ['确定', '取消'],
                     yes: function(index, layero){
                        layer.close(index); //关闭弹层
                     }
                  });
               }
               if (obj.event === 'print') {
                  PalletNo = data.PalletNo;
                  layer.open({
                     type: 2,
                     title: '打印托盘条码',
                     content: 'PalletsPrintFrom.html?PalletNo='+PalletNo,
                     maxmin: true,
                     area: ['600px', '300px'],
                     btn: ['确定', '取消'],
                     yes: function(index, layero){
                        var iframeWindow = window['layui-layer-iframe'+ index]
                        ,submitID = 'layuiadmin-app-form-submit'
                        ,submit = layero.find('iframe').contents().find('#'+ submitID);
                        //监听提交
                        iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
                           var field = data.field; //获取提交的字段
                           console.log(field);
                           var html = "";
                           var xun = 0;
                           var isOk = false;
                           document.getElementById('print').innerHTML="";
                           for(var i=0;i<parseInt(field.GroupCount);i++){
                              for(var j=0;j<parseInt(field.SameCount);j++){
                                 html ="<div class=\"layui-form\" lay-filter=\"layuiadmin-app-form-list\" id=\"print\" style=\"width: 50%; text-align: center;padding-top: 10%;margin-left: 0%;\">\n"+
                                    "<div class=\"layui-form-item\">\n"+
                                    "<div class=\"layui-inline\">\n"+
                                    "<div class=\"\">\n"+
                                    "<img  id=\"imgBar\" width=\"245px\" height=\"120px\" /></div>\n"+
                                    "</div>\n"+
                                    "</div>\n"+
                                    "</div>\n"+
                                    "<div style=\"page-break-after: always;\"></div>\n"+
                                    "</div>" ;
                                    document.getElementById('print').innerHTML+=html;
                                    document.getElementById('imgBar').id="imgBar"+xun;
                                    xun+=1
                              }
                              if(i==(parseInt(field.GroupCount)-1)){
                                 isOk= true;
                              }
                           }
                           if(isOk){
                              GetimgBar1(field.StockCode,field.GroupCount,field.SameCount);
                           }
                        });
                       submit.trigger('click');
                     },
                     end:function(){
                        location.reload();
                        return false;
                     }
                  });
               }
            });
            };
            
         });
      </script>