test
14 小时以前 587d9d9cec49585729d8f141dd3b0df2ffb637dc
HTML/views/SOSetting/ExportNoticeAddFrom.html
@@ -39,7 +39,8 @@
            <div class="layui-inline">
               <label class="layui-form-label">出库仓库</label>
               <div class="layui-input-inline">
                  <select name="WarehouseId" id="WarehouseId" lay-filter="WarehouseId" lay-verify="required" lay-search>
               <select name="WarehouseId" id="WarehouseId" lay-filter="WarehouseId" lay-verify="required"
                  lay-search>
                     <option value=""></option>
                  </select>
               </div>
@@ -151,7 +152,7 @@
               page: true,
               limit: pageCnt,
               limits: pageLimits,
               cellMinWidth: 60, //全局定义常规单元格的最小宽度,layui 2.2.1 新增
            cellMinWidth: 60,
               cols: [
                  [{
                     field: 'SkuNo',
@@ -178,14 +179,26 @@
                     title: '库存数量',  
                     align: 'center',
                     width:100,
                  // 格式化库存数量显示为4位小数
                  templet: function (d) {
                     return parseFloat(d.Qty).toFixed(4);
                  }
                  }, {
                     field: 'ExQty',
                     title: '出库数量',
                     align: 'center',
                     width:100,  
                     edit: 'number',
                  edit: 'text', // 改为text支持小数输入
                     event: 'dataNumber'
                  },
               }, {
                  title: '操作',
                  align: 'center',
                  width: 90,
                  templet: '#table-content-list',
                  fixed: 'right',
               }]
            ],
         };
                  // {
                  //    field:'IsBale', 
                  //    title:'是否裹包',
@@ -199,15 +212,6 @@
                  //    templet: '#checkboxTpl', 
                  //    unresize: true //是否禁用拖拽列宽
                  // }, 
                  {
                     title: '操作',
                     align: 'center',
                     width:90,
                     templet: '#table-content-list',
                     fixed: 'right',
                  }]
               ],
            };
            // //监听裹包操作
            // form.on('switch(IsBaleDemo)', function(obj){
            //    if (obj.elem.checked) {
@@ -243,6 +247,7 @@
            //       }
            //    }
            // });
            //初始渲染
            refreshTable(null);
            var $ = layui.$;
@@ -352,66 +357,59 @@
               }
               var DataList = [];
               
            // 只保留一个验证循环,移除重复代码
               for (var i in infoOptions.data) {
                  console.log(infoOptions.data[i].ExQty);
                  if (infoOptions.data[i].ExQty == "") {
                     layer.msg("请输入出库数量!", {
                        icon: 2,
                        time: 2000 //2秒关闭(如果不配置,默认是3秒)
                     }, function() {});
               const exqtyStr = (infoOptions.data[i].ExQty || '').trim();
               const stockQty = parseFloat(infoOptions.data[i].Qty) || 0;
               // 验证是否为空
               if (exqtyStr === "") {
                  layer.msg("请输入出库数量!", { icon: 2, time: 2000 });
                     isrun = 0;
                     return;
                  }
                  
                  if(infoOptions.data[i].ExQty.indexOf('.')>=0){
                     layer.msg("出库数量必须是大于0的整数", {
                        icon: 2,
                        time: 2000 //2秒关闭(如果不配置,默认是3秒)
                     }, function() {});
                     isrun = 0;
                     return;
                  }
                  if(infoOptions.data[i].ExQty.indexOf('-')>=0){
                     layer.msg("出库数量必须是大于0的整数", {
                        icon: 2,
                        time: 2000 //2秒关闭(如果不配置,默认是3秒)
                     }, function() {});
                     isrun = 0;
                     return;
                  }
                  if(infoOptions.data[i].ExQty.charAt(0)=='0'){
                     layer.msg("出库数量必须是大于0的整数", {
                        icon: 2,
                        time: 2000 //2秒关闭(如果不配置,默认是3秒)
                     }, function() {});
               // 验证数字格式(支持正数和最多4位小数)
               const decimalRegex = /^(0|[1-9]\d*)(\.\d{1,4})?$/;
               if (!decimalRegex.test(exqtyStr)) {
                  layer.msg("出库数量必须是大于0的数字,且最多保留4位小数!", { icon: 2, time: 2000 });
                     isrun = 0;
                     return;
                  }
                  
                  if (infoOptions.data[i].ExQty <= 0) {
                     layer.msg("出库数量必须大于0!", {
                        icon: 2,
                        time: 2000 //2秒关闭(如果不配置,默认是3秒)
                     }, function() {});
               // 转换为浮点数并处理精度
               const precision = 10000;
               const exqty = Math.round(parseFloat(exqtyStr) * precision) / precision;
               // 验证是否大于0
               if (exqty < 0) {
                  layer.msg("出库数量必须大于0!", { icon: 2, time: 2000 });
                     isrun = 0;
                     return;
                  }
                  if (infoOptions.data[i].ExQty > infoOptions.data[i].Qty) {
                     layer.msg("出库数量不能大于库存数量!", {
                        icon: 2,
                        time: 2000 //2秒关闭(如果不配置,默认是3秒)
                     }, function() {});
               // 验证不超过库存数量
               if (exqty > stockQty) {
                  layer.msg("出库数量不能大于库存数量!", { icon: 2, time: 2000 });
                     isrun = 0;
                     return;
                  }
               // 格式化出库数量为4位小数
               const formattedExQty = exqty.toFixed(4);
               infoOptions.data[i].ExQty = formattedExQty;
               // 构建数据对象
                  var item = {
                     SkuNo: infoOptions.data[i].SkuNo,
                     LotNo: infoOptions.data[i].LotNo,
                     Qty: parseInt(infoOptions.data[i].ExQty),
                  Qty: parseFloat(infoOptions.data[i].Qty), // 保留4位小数精度
                     IsBale:infoOptions.data[i].IsBale,
                     IsBelt:infoOptions.data[i].IsBelt,
                  ExQty: parseFloat(formattedExQty),
                  };
                  DataList.push(item); //属性
               DataList.push(item);
               }
               
               var param = {
@@ -485,8 +483,7 @@
                     for (var i = 0; i < res.data.length; i++) {
                        var TypeNum = 0;
                        
                        switch($("#Type").val())
                        {
                     switch ($("#Type").val()) {
                           case "0": //成品出库
                              TypeNum = 0;
                              console.log(TypeNum)
@@ -504,28 +501,22 @@
                              break;
                        }
                        //判断单据类型
                        if (TypeNum == 0)
                        {
                           if (res.data[i].Type == 0)
                           {
                     if (TypeNum == 0) {
                        if (res.data[i].Type == 0) {
                              $("#CustomerNamep").html("客户");
                              $("#CustomerNo").append('<option value =' + res.data[i].CustomerNo + '>' +
                              res.data[i].CustomerName + '</option>');
                           }
                        }
                        else if (TypeNum == 1)
                        {
                           if (res.data[i].Type == 1)
                           {
                     else if (TypeNum == 1) {
                        if (res.data[i].Type == 1) {
                              $("#CustomerNamep").html("供应商");
                              $("#CustomerNo").append('<option value =' + res.data[i].CustomerNo + '>' +
                              res.data[i].CustomerName + '</option>');
                           }
                        }
                        else if (TypeNum == 2)
                        {
                           if (res.data[i].Type == 2)
                           {
                     else if (TypeNum == 2) {
                        if (res.data[i].Type == 2) {
                              $("#CustomerNamep").html("货主");
                              $("#CustomerNo").append('<option value =' + res.data[i].CustomerNo + '>' +
                              res.data[i].CustomerName + '</option>');
@@ -563,4 +554,5 @@
         })
      </script>
   </body>
</html>