zhaowc
2025-04-07 19e95f4acc328bbf62a0427fe658d00268019e66
HTML/views/ASNSetting/LabelBox.html
@@ -75,32 +75,33 @@
                  </div>
               </div>
               <div class="layui-inline" style="margin-right: 0;">
                  <label class="layui-form-label" style="width: 60px;">批次号</label>
                  <label class="layui-form-label" style="width: 60px;">进厂编号</label>
                  <div class="layui-input-inline" style="margin-right: 0;">
                     <div class="layui-input-inline" style="margin-right: 0;">
                        <input type="text" id="LotNo" name="LotNo" placeholder="批次号" autocomplete="off"
                        <input type="text" id="LotNo" name="LotNo" placeholder="进厂编号" autocomplete="off"
                           class="layui-input">
                     </div>
                  </div>
               </div>
               <div class="layui-inline" style="margin-right: 0;">
                  <label class="layui-form-label" style="width: 60px;">供货批次</label>
                  <label class="layui-form-label" style="width: 60px;">原厂批号</label>
                  <div class="layui-input-inline" style="margin-right: 0;">
                     <div class="layui-input-inline" style="margin-right: 0;">
                        <input type="text" id="SupplierLot" name="SupplierLot" placeholder="供货批次"
                        <input type="text" id="SupplierLot" name="SupplierLot" placeholder="原厂批号"
                           autocomplete="off" class="layui-input">
                     </div>
                  </div>
               </div>
               <div class="layui-inline" style="margin-right: 0;">
                  <label class="layui-form-label">是否使用</label>
                  <label class="layui-form-label">标签状态</label>
                  <div class="layui-input-inline" style="margin-right: 0;">
                     <div class="layui-input-inline" style="margin-right: 0;">
                        <select name="Status" id="Status" lay-filter="Status" lay-search>
                           <option value=""></option>
                           <option value="0">否</option>
                           <option value="1">是</option>
                           <option value="0">未组托</option>
                           <option value="1">已组托</option>
                           <option value="2">已入库</option>
                        </select>
                     </div>
@@ -120,13 +121,45 @@
                     lay-filter="LAY-app-contlist-search">
                     <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>搜索
                  </button>
                  <button class="layui-btn layui-btn-sm layuiadmin-btn-list layui-btn-normal buDaLabelClass" style="margin-left: 5px;" lay-event="BuDaLabel" id="BuDaLabel">
                     <i class="layui-icon layui-icon-print layuiadmin-button-btn"></i>补打标签
                  </button>
                  <button class="layui-btn layui-btn-sm layuiadmin-btn-list layui-btn-danger delLabelClass" style="margin-left: 5px;" lay-event="delLabel" id="delLabel">
                     <i class="layui-icon layui-icon-delete layuiadmin-button-btn"></i>删除标签
                  </button>
               </div>
               <!-- 删除标签页面弹窗 -->
               <div class="layui-inline" id="divDelLotNo" style="display: none; padding-top: 10px;">
                  <div class="layui-inline">
                     <label class="layui-form-label">入库单据</label>
                     <div class="layui-input-inline" style="width: 220px;">
                        <input type="text" id="AsnNoSelect" name="AsnNoSelect" placeholder="入库单据" autocomplete="off" class="layui-input">
                     </div>
                  </div>
                  <div class="layui-inline DivLoadingArea" style="margin-top: 10px;">
                     <label class="layui-form-label">进厂编号</label>
                     <div class="layui-input-inline" style="width: 220px;">
                        <select name="LotNoSelect" id="LotNoSelect" lay-search>
                           <option value=""></option>
                        </select>
                     </div>
                  </div>
               </div>
               <!-- 编辑标签页面弹窗 -->
               <div class="layui-inline" id="divEditQty" style="display: none; padding-top: 10px;">
                  <div class="layui-inline">
                     <label class="layui-form-label">数量</label>
                     <div class="layui-input-inline" style="width: 220px;">
                        <input type="text" id="LabelQty" name="LabelQty" placeholder="数量" autocomplete="off" class="layui-input">
                     </div>
                  </div>
               </div>
            </div>
         </div>
         <div class="layui-card-body">
            <!-- <button type="button" class="layui-btn layui-btn-sm" id="daoru1">
               导入
            </button> -->
         <div class="layui-card-body">
            <div class="position-relative">
               <table id="Box-list" lay-filter="Box-list"></table>
@@ -227,9 +260,9 @@
            <script type="text/html" id="toolbarDemoList">
               {{# function GetBtn2(d){
                     var html = '';
                     if(d.Origin == "WMS生成" || d.Status == "0"){
                        html = `<a class="layui-btn layui-btn-danger layui-btn-xs delClass" lay-event="del">
                           <i class="layui-icon layui-icon-delete"></i>删除</a>`;
                     if(d.Origin == "WMS生成" && d.Status == "0"){
                        html = `<a class="layui-btn layui-btn-normal layui-btn-xs editClass" lay-event="edit">
                           <i class="layui-icon layui-icon-delete"></i>编辑</a>`;
                        
                     }
                     return html;
@@ -277,72 +310,147 @@
         // 页面加载绑定Table
         bindTable();
         //生成
         $('#BuDaLabel').on('click', function () {
                layer.open({
               type: 2,
               title: '打印',
               content: 'LabelBoxBuDa.html',
               maxmin: true,
               area: ['430px', '390px'],
               // btn: ['取消']
            });
            });
         $("#AsnNoSelect").on('input', function () {
         // 添加导入按钮单机事件
         table.on('toolbar(Box-list)', function (obj) {
            switch (obj.event) {
               case 'add':   // 添加箱支关系
                  // layer.open({
                  //     type: 2,
                  //     title: '自定义列',
                  //     content: '../SystemSettings/HeaderSetting.html',
                  //     maxmin: false,
                  //     resize: false,
                  //     area: ['970px', '650px']
                  // });
                  layer.open({
                     type: 2,
                     title: '打印',
                     content: 'LabelPrint.html?',
                     maxmin: true,
                     area: ['600px', '670px'],
                     btn: ['取消']
                  });
                  break;
               default: break;
            if ($("#AsnNoSelect").val() == "" || $("#AsnNoSelect").val().length < 16) {
               return
            }
         });
            if ($("#AsnNoSelect").val().length >= 16) {
               $("#AsnNoSelect").val($("#AsnNoSelect").val().substr(-16))
            }
            GetLotNoByAsnNo()
         })
         function GetLotNoByAsnNo() {
            $("#LotNoSelect").empty()
                $("#LotNoSelect").append('<option value =>' + '</option>');
            form.render('select');
            var param = {
               asnNo: $("#AsnNoSelect").val(),
            };
            sendData(IP + "/BllAsn/GetLotNoListByAsn", param, 'get', function(res) {
               if (res.code == 0) { //成功
                  for (var i = 0; i < res.data.length; i++) {
                     $("#LotNoSelect").append('<option value =' + res.data[i] + '>' + res.data[i] + '</option>');
                  }
                  form.render('select');
               } else { //不成功
                  layer.msg(res.msg, {
                     icon: 2,
                     time: 3000 //2秒关闭(如果不配置,默认是3秒)
                  }, function() {
                  });
               }
            });
         }
         // 删除箱支信息
            //删除标签
         $('#delLabel').on('click', function () {
            layer.open({
               type: 1,
               title: '删除标签',
               content: $('#divDelLotNo'),
               maxmin: false,
               area: ['350px','340px'],
               btn: ['确定', '取消'],
               yes: function(index, layero) {
                  var param = {
                     AsnNo: $('#AsnNoSelect').val(),
                     LotNo: $('#LotNoSelect').val(),
                  };
                  sendData(IP + "/BllAsn/DelLabelByAsnNo", param, 'post', function(res) {
                     if (res.code == 0) { //成功
                        bindTable();
                        layer.msg(res.msg, {
                           icon: 1,
                           time: 1500 //1秒关闭(如果不配置,默认是3秒)
                        }, function() {
                           $('#AsnNoSelect').val("");
                           $("#LotNoSelect").empty()
                           $("#LotNoSelect").append('<option value =>' + '</option>');
                           form.render('select');
                        });
                     } else { //不成功
                        layer.msg(res.msg, {
                           icon: 2,
                           time: 3000 //2秒关闭(如果不配置,默认是3秒)
                        }, function() {
                           bindTable();
                           $('#AsnNoSelect').val("");
                           $("#LotNoSelect").empty()
                           $("#LotNoSelect").append('<option value =>' + '</option>');
                           form.render('select');
                        });
                     }
                     layer.close(index);
                  });
               }
            });
            });
         //明细表操作栏事件
         table.on('tool(Box-list)', function (obj) {
            var data = obj.data;
            switch (obj.event) {
               case "del":
                  layer.confirm('确定删除箱支明细吗?', function (index) {
                     // 代码区域
                     var param = {
                        Id: data.Id,
                        Status: "0",
                     };
                     console.log(param);
                     sendData(IP + "/BllAsn/DelBllBoxInfo", param, 'post', function (res) {
                        if (res.code == 0) { //成功
                           layer.msg(res.msg, {
                              icon: 1,
                              time: 2000 //2秒关闭(如果不配置,默认是3秒)
                           }, function () {
            var id = data.Id;
            switch(obj.event)
            {
               case "edit" :
                  layer.open({
                     type: 1,
                     title: '编辑标签',
                     content: $('#divEditQty'),
                     maxmin: false,
                     area: ['350px','180px'],
                     btn: ['确定', '取消'],
                     yes: function(index, layero) {
                        var param = {
                           Id: id,
                           Qty: $('#LabelQty').val(),
                        };
                        sendData(IP + "/BllAsn/EditLabelQty", param, 'post', function(res) {
                           if (res.code == 0) { //成功
                              bindTable();
                              doing = true
                           });
                        } else { //不成功
                           layer.msg(res.msg, {
                              icon: 2,
                              time: 2000 //2秒关闭(如果不配置,默认是3秒)
                           }, function () { doing = true });
                        }
                     });
                              layer.msg(res.msg, {
                                 icon: 1,
                                 time: 1500 //1秒关闭(如果不配置,默认是3秒)
                              }, function() {
                                 $('#LabelQty').val("");
                              });
                           } else { //不成功
                              layer.msg(res.msg, {
                                 icon: 2,
                                 time: 3000 //2秒关闭(如果不配置,默认是3秒)
                              }, function() {
                                 bindTable();
                                 $('#LabelQty').val("");
                              });
                           }
                           layer.close(index);
                        });
                     }
                  });
                  break;
               default: break;
               default:break;
            }
         });
         //#region 事件方法
         // 查询录入的箱支关系
         //#region 自定义表头
         var TotalColsArr = [[
            { field: 'ASNNo', title: '入库单号', align: 'center',fixed: 'left', width: 180, "disabled": true },
@@ -352,10 +460,11 @@
            { field: 'SkuNo', title: '物料编码', align: 'center', fixed: 'left', width: 140, "disabled": true },
            { field: 'SkuName', title: '物料名称', align: 'center', width: 240, },
            { field: 'Qty', title: '数量', align: 'center', width: 100, },
            { field: 'UnitName', title: '单位', align: 'center', width: 100, },
            { field: 'FullQty', title: '整箱数量', align: 'center', width: 100, },
            { field: 'LotNo', title: '批次号', align: 'center', width: 155, },
            { field: 'LotNo', title: '进厂编号', align: 'center', width: 155, },
            { field: 'LotText', title: '批次描述', align: 'center', width: 165 },
            { field: 'SupplierLot', title: '供货批次', align: 'center', width: 155 },
            { field: 'SupplierLot', title: '原厂批号', align: 'center', width: 155 },
            { field: 'Status', title: '状态', align: 'center', templet: '#templetStatus', width: 90 },
             
            { field: 'Standard', title: '规格/型号', align: 'center', width: 165 },
@@ -372,7 +481,7 @@
            { field: 'CreateUserName', title: '创建人', align: 'center', width: 100 },
            { field: 'CreateTime', title: '创建时间', align: 'center', width: 160, templet: '#templetCreateTime' },
            //{ field: 'caozuo', title: '操作', fixed: 'right', width: 100, align: 'center', toolbar: '#toolbarDemoList', "disabled": true }
            { field: 'caozuo', title: '操作', fixed: 'right', width: 100, align: 'center', toolbar: '#toolbarDemoList', "disabled": true }
         ]];
         //url编码
         var TotalColsSysArr = encodeURIComponent(encodeURIComponent(JSON.stringify(TotalColsArr)))//将表头数据进行url编码
@@ -420,44 +529,13 @@
                  limits: pageLimits,
                  cellMinWidth: 60, //全局定义常规单元格的最小宽度,layui 2.2.1 新增
                  done: function (res) {
                     console.log(res);
                     setRight();
                     //自定义列宽
                     SetTableColW('Box-list', 'BllAsn/GetLabelBoxList', TotalColsSysArr);
                  },
                  cols: colsJson
               });
               //绑定导入
               upload.render({
                  elem: '#daoru' //绑定元素
                  , url: '' //上传接口
                  , auto: false  //是否选完文件后自动上传。如果设定 false,那么需要设置 bindAction 参数来指向一个其它按钮提交上传
                  , exts: 'slx|excel|xlsx'  //允许上传的文件后缀
                  , accept: 'file' //指定允许上传时校验的文件类型
                  //, bindAction: '#daoru' //指向一个按钮触发上传
                  , choose: function (obj) {// 选择文件回调
                     console.log(obj);
                     var files = obj.pushFile(); //将每次选择的文件追加到文件队列
                     var fileArr = Object.values(files);// 注意这里的数据需要是数组,所以需要转换一下
                     console.log(fileArr)
                     // 用完就清理掉,避免多次选中相同文件时出现问题
                     for (var index in files) {
                        console.log(index);
                        if (files.hasOwnProperty(index)) {
                           delete files[index];
                        }
                     }
                     console.log("abs");
                     uploadExcel(fileArr); // 如果只需要最新选择的文件,可以这样写: uploadExcel([files.pop()])
                  }
                  , done: function (res) {
                     console.log(res);
                     //上传完毕回调
                  }
                  , error: function (res) {
                     console.log(res);
                     //请求异常回调
                  }
               });
            });
            //#endregion
@@ -466,26 +544,26 @@
         // 权限设置
         function setRight() {
            $(function () {
               $(".addClass").hide();
               $(".DaoRuClass").hide();
               $(".delClass").hide();
               $(".buDaLabelClass").hide();
               $(".delLabelClass").hide();
               $(".editClass").hide();
            });
            sendData(IP + "/Basis/GetRoleRightList", {}, 'get', function (res) {
               if (res.code == 0) { //成功 
                  for (var k = 0; k < res.data.length; k++) {
                     if (res.data[k].MenuName == "添加箱支录入") {
                     if (res.data[k].MenuName == "补打标签") {
                        $(function () {
                           $(".addClass").show();
                           $(".buDaLabelClass").show();
                        });
                     }
                     if (res.data[k].MenuName == "导入箱支录入") {
                     }
                     if (res.data[k].MenuName == "删除标签") {
                        $(function () {
                           $(".DaoRuClass").show();
                           $(".delLabelClass").show();
                        });
                     }
                     if (res.data[k].MenuName == "删除箱支录入") {
                     }
                     if (res.data[k].MenuName == "编辑标签") {
                        $(function () {
                           $(".delClass").show();
                           $(".editClass").show();
                        });
                     }
                  }
@@ -498,155 +576,7 @@
            });
         }
         // 获取箱支信息
         function getBoxInforVlues() {
            var msg = "";
            if ($("#BoxNo").val() == "") {
               layer.msg("请输入箱码!", {
                  icon: 2,
                  time: 2000 //2秒关闭(如果不配置,默认是3秒)
               });
               return msg;
            }
            if ($("#BoxNo3").val() == "") {
               layer.msg("请输入支码!", {
                  icon: 2,
                  time: 2000 //2秒关闭(如果不配置,默认是3秒)
               });
               return msg;
            }
            if ($("#SkuNo").val() == "") {
               layer.msg("请输入物料编码!", {
                  icon: 2,
                  time: 2000 //2秒关闭(如果不配置,默认是3秒)
               });
               return msg;
            }
            if ($("#LotNo").val() == "") {
               layer.msg("请输入批次号!", {
                  icon: 2,
                  time: 2000 //2秒关闭(如果不配置,默认是3秒)
               });
               return msg;
            }
            if ($("#Qty").val() == "") {
               layer.msg("请输入实际数量!", {
                  icon: 2,
                  time: 2000 //2秒关闭(如果不配置,默认是3秒)
               });
               return msg;
            }
            var param = {
               BoxNo: $("#BoxNo").val(),
               BoxNo3: $("#BoxNo3").val(),
               SkuNo: $("#SkuNo").val(),
               LotNo: $("#LotNo").val(),
               LotText: $("#LotText").val(),
               Qty: parseInt($("#Qty").val()),
               ProductionTime: $("#ProductionTime").val(),
               InspectMark: $("#InspectMark").val(),
               BitBoxMark: $("#BitBoxMark").val(),
               Origin: "录入",
            };
            return param;
         }
         // 导入箱支关系
         function uploadExcel(files) {
            console.log("123");
            var list = [];
            try {
               var excel = layui.excel;
               excel.importExcel(files, {
                  // 读取数据的同时梳理数据
                  fields: {
                     'BoxNo': 'A', //箱号
                     'BoxNo2': 'B', //盒号
                     'BoxNo3': 'C', //支号
                     'Qty': 'D', //数量
                     'SkuNo': 'E', //物料号
                     'LotNo': 'F', //批次
                     'LotText': 'G', //批次描述
                     'ProductionTime': 'H', //生产日期
                     'InspectMark': 'I',  //检验标记
                     'BitBoxMark': 'J', //零箱标记
                  }
               },
                  function (data) {
                     console.log(data);
                     // var arr = new Array();
                     //excel第一行不读取、设置为标题
                     for (i = 1; i < data[0].Sheet1.length; i++) {
                        var Qty = 0;
                        if (isIntNum(data[0].Sheet1[i].Qty)) {
                           Qty = parseInt(data[0].Sheet1[i].Qty);
                        }
                        var InspectMark = "0";
                        var BitBoxMark = "0";
                        if (data[0].Sheet1[i].InspectMark == "是") {
                           InspectMark = "1";
                        }
                        if (data[0].Sheet1[i].BitBoxMark == "是") {
                           BitBoxMark = "1";
                        }
                        var tt = {
                           BoxNo: data[0].Sheet1[i].BoxNo,
                           BoxNo2: data[0].Sheet1[i].BoxNo2,
                           BoxNo3: data[0].Sheet1[i].BoxNo3,
                           Qty: Qty,
                           SkuNo: data[0].Sheet1[i].SkuNo,
                           LotNo: data[0].Sheet1[i].LotNo,
                           LotText: data[0].Sheet1[i].LotText,
                           ProductionTime: data[0].Sheet1[i].ProductionTime,
                           InspectMark: InspectMark,
                           BitBoxMark: BitBoxMark,
                        };
                        list.push(tt);
                        console.log(data[0].Sheet1[i].ProductionTime);
                     }
                     console.log(list);
                     var param = {
                        "OperType": "Add",
                        "ListBoxInfo": list,
                     }
                     console.log(param)
                     layer.load();//打开loading
                     sendData(IP + "/BllAsn/ImportBllBoxInfo", param, 'post', function (res) {
                        layer.closeAll(); //关闭loading
                        if (res.code == 0) { //成功
                           layer.msg(res.msg, {
                              icon: 1,
                              time: 2000 //2秒关闭(如果不配置,默认是3秒)
                           }, function () {
                              bindTable();
                              doing = true
                           });
                        } else { //不成功
                           if (res.msg == undefined) {
                              layer.msg("后台正在导入中,请稍后查看结果", {
                                 icon: 2,
                                 time: 3000 //2秒关闭(如果不配置,默认是3秒)
                              }, function () { bindTable(); doing = true });
                           } else {
                              layer.msg(res.msg, {
                                 icon: 2,
                                 time: 2000 //2秒关闭(如果不配置,默认是3秒)
                              }, function () { bindTable(); doing = true });
                           }
                        }
                     });
                  });
            } catch (e) {
               layer.alert(e.message);
            }
         }
         //#endregion
         //#region 自定义表头
         //自定义表头         
         active = {