1
llj
2025-09-13 fc98ef7296017bcd15f32b16ffc81f915513ad89
WebSRM/layuiAdmin.std-v1.2.1/src/views/SRM/SRM_MaterialBarCodeBill.html
@@ -40,9 +40,9 @@
                            <div class="layui-form-item">
                                <div class="layui-row">
                                    <div class="layui-col-xs3">
                                        <label class="layui-form-label"> 供 应 商:</label>
                                        <label class="layui-form-label"> 供应商代码:</label>
                                        <div class="layui-input-inline">
                                            <input class="layui-input" name="HSupName" lay-verify="HSupName" id="HSupName" readonly="readonly" autocomplete="off">
                                            <input class="layui-input" name="HSupNumber" lay-verify="HSupNumber" id="HSupNumber" readonly="readonly" autocomplete="off">
                                            <input id="HSupID" name="HSupID" type="hidden" />
                                        </div>
                                    </div>
@@ -50,9 +50,9 @@
                                        <label class="layui-form-label"> 供 应 商:</label>
                                        <div class="layui-input-inline">
                                            <input class="layui-input" name="HSupName" lay-verify="HSupName" id="HSupName" readonly="readonly" autocomplete="off">
                                            <input id="HSupName" name="HSupName" type="hidden" />
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
@@ -64,11 +64,11 @@
                                <div class="layui-tab-item layui-show">
                                    <table class="layui-hide" id="mainTable" lay-filter="mainTable"></table>
                                    <script type="text/html" id="toolbarDemo">
                                        <div class="layui-btn-container">
                                        <!--<div class="layui-btn-container">
                                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-add"><i class="layui-icon layui-icon-addition"></i>拆分</button>
                                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn_HideColumn"><i class="layui-icon layui-icon-addition"></i>列设置</button>
                                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-del"><i class="layui-icon layui-icon-subtraction"></i>删行</button>
                                        </div>
                                        </div>-->
                                    </script>
                                    <!-- 条码类型下拉框模板 -->
                                    <script type="text/html" id="barCodeTypeTpl">
@@ -166,6 +166,7 @@
                , element = layui.element; //Tab的切换功能,切换事件监听等,需要依赖element模块
            var option;
            FetchSupInfo();
            option = {
                elem: '#mainTable'
                , toolbar: '#toolbarDemo'
@@ -176,24 +177,25 @@
                , cols: [[
                    { type: 'checkbox', fixed: 'left' }
                    , { field: 'HMaterID', title: '物料ID', width: 100, hide: true }
                    , { field: 'HItemID', title: 'ID', width: 100, hide: true }
                    , { field: 'HMaterNumber', title: '物料编码', width: 120 }
/*                    , { field: 'HOldMaterNumber', title: '旧物料编码', width: 120, hide: true }*/
/*                   , { field: 'HOldMaterNumber', title: '旧物料编码', width: 120, hide: true }*/
                    , { field: 'HMaterShortNumber', title: '物料代码', width: 120, hide: true }
                   /* , { field: 'HSubjoin', title: '物料代码', width: 120, hide: true }*/
                  , { field: 'HSubjoin', title: '物料简称', width: 120, }
                    , { field: 'HMaterName', title: '物料名称', width: 120 }
                    , { field: 'HMaterModel', title: '规格型号', width: 120 }
                    , { field: 'HQty', title: '本次生成条码数量', width: 135, edit: 'text', event: "inputHQty" }
                    , { field: 'HMinQty', title: '标准包装数(内箱装箱数)', width: 100, edit: 'text', event: "inputHMinQty" }
                    , { field: 'HMinQty', title: '标准包装数(内箱装箱数)', width: 100, event: "inputHMinQty" }
                    , { field: 'HBQty', title: '最小包装数(内箱数)', width: 100 } 
                    , { field: 'biaoqianzhangshu', title: '标签张数', width: 100 }
                    , { field: 'HBatchNo', title: '批号', width: 100, edit: 'text' }
                    , { field: 'HBatchNo', title: '批号', width: 100, edit: 'text', hide: true }
                    , { field: 'HBatchManager', title: '启用批号', width: 100, hide: true }
                    , { field: 'HISKFPERIOD', title: '是否启用保质期', width: 100, edit: 'text', hide: true }
                    , { field: 'HEXPUNIT', title: '保质期单位', width: 100, edit: 'text', hide: true }
                    , { field: 'HSourceBillType', title: '条码类型', width: 100, templet: '#barCodeTypeTpl' }  
                    , { field: 'HKFDate', title: '生产日期', align: 'center', width: 150, data_field: 'HKFDate', event: "chooseHKFDate" }//, event: "chooseHKFDate"
                    , { field: 'HKFPeriod', title: '保质期', width: 100,event:"inputHKFPeriod" }//
                    , { field: 'HKFDQDate', title: '到期日期', align: 'center', width: 150, data_field: 'HKFDQDate' }//, event: "chooseHKFDQDate"
                    , { field: 'HKFPeriod', title: '保质期', width: 100, event: "inputHKFPeriod", hide: true }//
                    , { field: 'HKFDQDate', title: '到期日期', align: 'center', width: 150, data_field: 'HKFDQDate', hide: true }//, event: "chooseHKFDQDate"
                    , { field: 'HSupID', title: '供应商ID', width: 150, hide: true }
                    , { field: 'HSupName', title: '供应商名称', width: 150, hide: true }
                ]]
@@ -234,17 +236,17 @@
                        , { field: 'HMaterName', title: '物料名称', width: 120 }
                        , { field: 'HMaterModel', title: '规格型号', width: 120 }
                        , { field: 'HQty', title: '本次生成条码数量', width: 135, edit: 'text', event: "inputHQty" }
                        , { field: 'HMinQty', title: '标准包装数(内箱装箱数)', width: 100, edit: 'text', event: "inputHMinQty" }
                        , { field: 'HMinQty', title: '标准包装数(内箱装箱数)', width: 100, event: "inputHMinQty" }
                        , { field: 'HBQty', title: '最小包装数(内箱数)', width: 100 }
                        , { field: 'biaoqianzhangshu', title: '标签张数', width: 100 }
                        , { field: 'HBatchNo', title: '批号', width: 100, edit: 'text' }
                        , { field: 'HBatchNo', title: '批号', width: 100, edit: 'text', hide: true }
                        , { field: 'HBatchManager', title: '启用批号', width: 100, hide: true }
                        , { field: 'HISKFPERIOD', title: '是否启用保质期', width: 100, edit: 'text', hide: true }
                        , { field: 'HEXPUNIT', title: '保质期单位', width: 100, edit: 'text', hide: true }
                        , { field: 'HSourceBillType', title: '条码类型', width: 100 }
                        , { field: 'HKFDate', title: '生产日期', align: 'center', width: 150, data_field: 'HKFDate', event: "chooseHKFDate" }//, event: "chooseHKFDate"
                        , { field: 'HKFPeriod', title: '保质期', width: 100 }//
                        , { field: 'HKFDQDate', title: '到期日期', align: 'center', width: 150, data_field: 'HKFDQDate' }//, event: "chooseHKFDQDate"
                        , { field: 'HKFDate', title: '生产日期', align: 'center', width: 150, data_field: 'HKFDate', event: "chooseHKFDate", hide: true }//, event: "chooseHKFDate"
                        , { field: 'HKFPeriod', title: '保质期', width: 100, hide: true }//
                        , { field: 'HKFDQDate', title: '到期日期', align: 'center', width: 150, data_field: 'HKFDQDate', hide: true}//, event: "chooseHKFDQDate"
                        , { field: 'HSupID', title: '供应商ID', width: 150, hide: true }
                        , { field: 'HSupName', title: '供应商名称', width: 150, hide: true }
@@ -257,7 +259,6 @@
            else {
                //合并数量生成条码
                layer.load(3);
                FetchSupInfo();
                $("#HDate").val(Format(new Date(), "yyyy-MM-dd"));
                $.ajax({
                    type: "GET",
@@ -272,11 +273,12 @@
                            for (var i = 0; i < data.length; i++) {
                                rowdata.push({
                                    "HMaterID": data[i].HItemID,
                                    "HMaterID": data[i].MaterID,
                                    "HItemID": data[i].HItemID,
                                    "HMaterNumber": data[i].物料代码,
/*                                    "HOldMaterNumber": "",*/
                                    "HMaterShortNumber": "",
                                    /*"HSubjoin": "",*/
                                    "HSubjoin": data[i].物料简称,
                                    "HMaterName": data[i].物料名称,
                                    "HMaterModel": data[i].规格型号,
                                    "HMinQty": data[i].标准包装数,
@@ -288,7 +290,7 @@
                                    "HKFDQDate": data[i].有效期,
                                    "HKFDate": data[i].生产日期,
                                    "HBatchManager": data[i].是否启用批号,
                                    "HSupID": data[i].供应商代码,
                                    "HSupID": data[i].HSupID,
                                    "HSupName": data[i].供应商名称,
                                    "HEXPUNIT": data[i].保质期单位,
                                    "HQty": 1, // 默认生成条码数量
@@ -411,7 +413,7 @@
                    
                }
                else if (obj.event == 'inputHMinQty') {
                    var oldHMinQty = data.HMinQty;
                    var $input = $(this), val = $input.val();
                    $(obj.tr).find(".layui-table-edit").keyup(function () {
                        var $input = $(this), val = $input.val();
@@ -487,10 +489,13 @@
                    }
                    if (HMinQty < HBQty) {
                        f_alert("标准包装数量不能小于最小包装数量!请重新输入!")
                        obj.update({
                            HBQty: Math.ceil(parseFloat(obj.data.HQty) / parseFloat(obj.value)),
                        });
                        return;
                    }
                    else {
                        obj.update({
                            biaoqianzhangshu: Math.ceil(parseFloat(obj.data.HQty) / parseFloat(obj.value)),
                        });
                    }
                    break;  
            }
@@ -584,17 +589,20 @@
                                var option_Success;
                                option_Success = {
                                    elem: '#subTable'
                                   // , url: GetWEBURL() + 'showHBarCodeBillDetail'  //h_v_Web_BarCodeBill_ForWeb1
                                    // , url: GetWEBURL() + 'showHBarCodeBillDetail'  //h_v_Web_BarCodeBill_ForWeb1
                                    , toolbar: '#toolbarDemo1'
                                    , defaultToolbar: ['filter', 'exports']
                                    , limit: 500
                                    , cols: [[
                                        , { field: 'HBarCode', title: '条码', width: 100 }
                                        { field: 'HBarCode', title: '条码', width: 230, ellipsis: true }
                                        , { field: 'HMaterID', title: '物料ID', width: 100, hide: true }
                                        , { field: 'HBarItemID', title: '条码ID', width: 100, hide: true }
                                        , { field: 'HMaterNumber', title: '物料编码', width: 120 }
/*                                        , { field: 'LSH', title: '流水号', width: 120 }*/
                                        /*                    , { field: 'HOldMaterNumber', title: '旧物料编码', width: 120, hide: true }*/
                                        , { field: 'HMaterShortNumber', title: '物料代码', width: 120, hide: true }
                                        /* , { field: 'HSubjoin', title: '物料代码', width: 120, hide: true }*/
                                        , { field: 'HMaterName', title: '物料名称', width: 120 }
                                        , { field: 'HMaterShortNumber', title: '物料代码', width: 120 }
                                        , { field: 'HSubjoin', title: '物料简称', width: 120, hide: true }
                                        , { field: 'HMaterName', title: '物料名称', width: 120, hide: true }
                                        , { field: 'HMaterModel', title: '规格型号', width: 120 }
                                        , { field: 'HQty', title: '本次生成条码数量', width: 135 }
                                        , { field: 'HMinQty', title: '标准包装数(内箱装箱数)', width: 100 }
@@ -613,32 +621,34 @@
                                    ]]
                                }
                                //#region ADD
                                var barcodes = data.data;
                                // 将条码列表转换为逗号分隔的字符串
                                //var barcodeStr = barcodes.join('~');
                                $.ajax({
                                    type: "GET",
                                    url: GetWEBURL() + "/showHBarCodeBillDetail",
                                    async: true,
                                    data: { sMsg: lentryid, user: sessionStorage["Organization"] },
                                    url: GetWEBURL() + "/GetBarcodeDetails",
                                    data: { barcodes: barcodes },
                                    dataType: "json",
                                    success: function (data_1) {
                                        if (data_1.count != 0) {
                                            var data = data_1.data;
                                            var rowdata_1 = [];
                                            var IDdif = data[0].HItemID;
                                            for (var i = 0,k=1; i < data.length; i++,k++) {
                                                    var totalQty = data[i].生成条码数量; // 总条码数
                                                    var standardQty = data[i].标准包装数; // 标准包装数
                                                    var labelCount = Math.ceil(totalQty / standardQty); // 计算标签数
                                                    var lastQty_sign = (totalQty % standardQty == 0) ? 0 : 1;//判断是否有余数
                                                if (k == labelCount && lastQty_sign==1) {
                                            for (var i = 0; i < data.length; i++) {
                                                    rowdata_1.push({
                                                        "HMaterID": data[i].HItemID,
                                                        "HMaterID": data[i].HMaterID,
                                                        "HBarItemID": data[i].HBarItemID,
/*                                                        "LSH": data[i].HBarItemID,*/
                                                        "HBarCode": data[i].HBarCode,
                                                        "HMaterNumber": data[i].物料代码,
                                                        "HMaterShortNumber": "",
                                                        "HSubjoin": data[i].物料简称,
                                                        "HMaterName": data[i].物料名称,
                                                        "HMaterModel": data[i].规格型号,
                                                        "HMinQty": standardQty ,
                                                        "HMinQty": data[i].标准包装数,
                                                        "HBQty": data[i].最小包装数,
                                                        "HSourceBillType": data[i].条码类型,
                                                        "HBatchNo": data[i].批号,
@@ -647,68 +657,122 @@
                                                        "HKFDQDate": data[i].有效期,
                                                        "HKFDate": data[i].生产日期,
                                                        "HBatchManager": data[i].是否启用批号,
                                                        "HSupID": data[i].供应商代码,
                                                        "HSupID": data[i].HSupID,
                                                        "HSupName": data[i].供应商名称,
                                                        "HEXPUNIT": data[i].保质期单位,
                                                        "HQty": (totalQty % standardQty), // 本次生成条码数量
                                                        "HQty":data[i].生成条码数量 , // 本次生成条码数量
                                                        "biaoqianzhangshu": 1
                                                    });
                                                    k = 1;
                                                }
                                                else {
                                                    rowdata_1.push({
                                                        "HMaterID": data[i].HItemID,
                                                        "HBarCode": data[i].HBarCode,
                                                        "HMaterNumber": data[i].物料代码,
                                                        "HMaterShortNumber": "",
                                                        "HMaterName": data[i].物料名称,
                                                        "HMaterModel": data[i].规格型号,
                                                        "HMinQty":  standardQty,
                                                        "HBQty": data[i].最小包装数,
                                                        "HSourceBillType": data[i].条码类型,
                                                        "HBatchNo": data[i].批号,
                                                        "HISKFPERIOD": data[i].是否启用保质期 == null ? 0 : data[i].是否启用保质期,
                                                        "HKFPeriod": data[i].保质期 == null ? 0 : data[i].保质期,
                                                        "HKFDQDate": data[i].有效期,
                                                        "HKFDate": data[i].生产日期,
                                                        "HBatchManager": data[i].是否启用批号,
                                                        "HSupID": data[i].供应商代码,
                                                        "HSupName": data[i].供应商名称,
                                                        "HEXPUNIT": data[i].保质期单位,
                                                        "HQty": standardQty, // 本次生成条码数量
                                                        "biaoqianzhangshu": 1
                                                    });
                                                }
                                            }
                                            // 更新表格数据
                                            option_Success.data = rowdata_1;
                                            table.render(option_Success);
                                        }
                                        else {
                                            // $("#verifycode").click();
                                            f_alert(data.Message);
                                    }
                                });
                                //#endregion
                                            // #region 成功条码展示
                                            //$.ajax({
                                            //    type: "GET",
                                            //    url: GetWEBURL() + "/showHBarCodeBillDetail",
                                            //    async: true,
                                            //    data: { sMsg: lentryid, user: sessionStorage["Organization"] },
                                            //    dataType: "json",
                                            //    success: function (data_1) {
                                            //        if (data_1.count != 0) {
                                            //            var data = data_1.data;
                                            //            var rowdata_1 = [];
                                            //            var IDdif = data[0].HItemID;
                                            //            for (var i = 0,k=1; i < data.length; i++,k++) {
                                            //                    var totalQty = data[i].生成条码数量; // 总条码数
                                            //                    var standardQty = data[i].标准包装数; // 标准包装数
                                            //                    var labelCount = Math.ceil(totalQty / standardQty); // 计算标签数
                                            //                    var lastQty_sign = (totalQty % standardQty == 0) ? 0 : 1;//判断是否有余数
                                            //                if (k == labelCount && lastQty_sign==1) {
                                            //                    rowdata_1.push({
                                            //                        "HMaterID": data[i].HItemID,
                                            //                        "HBarCode": data[i].HBarCode,
                                            //                        "HMaterNumber": data[i].物料代码,
                                            //                        "HMaterShortNumber": "",
                                            //                        "HMaterName": data[i].物料名称,
                                            //                        "HMaterModel": data[i].规格型号,
                                            //                        "HMinQty": standardQty ,
                                            //                        "HBQty": data[i].最小包装数,
                                            //                        "HSourceBillType": data[i].条码类型,
                                            //                        "HBatchNo": data[i].批号,
                                            //                        "HISKFPERIOD": data[i].是否启用保质期 == null ? 0 : data[i].是否启用保质期,
                                            //                        "HKFPeriod": data[i].保质期 == null ? 0 : data[i].保质期,
                                            //                        "HKFDQDate": data[i].有效期,
                                            //                        "HKFDate": data[i].生产日期,
                                            //                        "HBatchManager": data[i].是否启用批号,
                                            //                        "HSupID": data[i].供应商代码,
                                            //                        "HSupName": data[i].供应商名称,
                                            //                        "HEXPUNIT": data[i].保质期单位,
                                            //                        "HQty": (totalQty % standardQty), // 本次生成条码数量
                                            //                        "biaoqianzhangshu": 1
                                            //                    });
                                            //                    k = 1;
                                            //                }
                                            //                else {
                                            //                    rowdata_1.push({
                                            //                        "HMaterID": data[i].HItemID,
                                            //                        "HBarCode": data[i].HBarCode,
                                            //                        "HMaterNumber": data[i].物料代码,
                                            //                        "HMaterShortNumber": "",
                                            //                        "HMaterName": data[i].物料名称,
                                            //                        "HMaterModel": data[i].规格型号,
                                            //                        "HMinQty":  standardQty,
                                            //                        "HBQty": data[i].最小包装数,
                                            //                        "HSourceBillType": data[i].条码类型,
                                            //                        "HBatchNo": data[i].批号,
                                            //                        "HISKFPERIOD": data[i].是否启用保质期 == null ? 0 : data[i].是否启用保质期,
                                            //                        "HKFPeriod": data[i].保质期 == null ? 0 : data[i].保质期,
                                            //                        "HKFDQDate": data[i].有效期,
                                            //                        "HKFDate": data[i].生产日期,
                                            //                        "HBatchManager": data[i].是否启用批号,
                                            //                        "HSupID": data[i].供应商代码,
                                            //                        "HSupName": data[i].供应商名称,
                                            //                        "HEXPUNIT": data[i].保质期单位,
                                            //                        "HQty": standardQty, // 本次生成条码数量
                                            //                        "biaoqianzhangshu": 1
                                            //                    });
                                            //                }
                                            //            }
                                            //            option_Success.data = rowdata_1;
                                            //            table.render(option_Success);
                                            //        }
                                            //        else {
                                            //            // $("#verifycode").click();
                                            //            f_alert(data.Message);
                                            //        }
                                            //        layer.closeAll("loading");
                                            //    },
                                            //    error: function (err) {
                                            //        f_alert("错误:" + err);
                                            //        layer.closeAll("loading");
                                            //    }
                                            //});
                                            // #endregion
                                        }
                                        layer.closeAll("loading");
                                    },
                                    error: function (err) {
                                        f_alert("错误:" + err);
                                        layer.closeAll("loading");
                                    }
                                });
                            }
                            layer.closeAll("loading");
                        },
                        error: function (err) {
                            f_alert("错误:" + err);
                        }
                    });
                return false;
                                return false;
            });
           //#endregion
@@ -724,7 +788,7 @@
                    return;
                }
                for (var j = 0; j < data2.length; j++) {
                    rows += data2[j].HMaterID.toString() + ',';
                    rows += data2[j].HBarItemID.toString() + ',';
                    rows2 += data2[j].HBarCode.toString() + ',';
                }
                rows = rows.substring(rows.length - 1, 0);
@@ -776,8 +840,9 @@
                    data: { "sWhere": sWhere, "user": '', "Organization": sessionStorage["Organization"] },
                    success: function (result) {
                        if (result.data.length > 0) {
                            $("#HSupID").val(result.data[0].HItemID);
                            $("#HSupNumber").val(result.data[0].供应商代码);
                            $("#HSupName").val(result.data[0].供应商名称);
                            $("#HSupID").val(result.data[0].供应商代码);
                        } else {
                            layer.msg("供应商信息未维护", { time: 5000 });
                        }