1
wtt
2026-04-08 b7237a51c665ec1150bef9ab6c9bcfc7847755aa
WebTM/views/³µ¼ä¹ÜÀí/µ¥Æ·¹ýÕ¾_СÎÀ/Cj_ProcessItemStationPlatform_batchKeyElement.html
@@ -64,11 +64,17 @@
                                                <input type="text" class="layui-input" name="HBarCode_BatchSec" lay-verify="HBarCode_BatchSec" id="HBarCode_BatchSec" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                        <div class="layui-inline" style="display: none">
                                            <label class="layui-form-label" style="width: 85px;">追溯单号</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HBillNo" lay-verify="HBillNo" id="HBillNo" style="background-color:#EDEDED;" readonly>
                                                <input type="hidden" name="HInterID" id="HInterID" lay-verify="HInterID">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;" id="">校验年月:</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HCheckDate" lay-verify="HCheckDate" id="HCheckDate" style="background-color:#efefef4d;"placeholder="请输入年月格式如2501(共四位前两位代表年份后两位代表月份)">
                                            </div>
                                        </div>
                                        <!--<div class="layui-inline">
@@ -288,6 +294,7 @@
        var HModName2 = "Cj_ProcessItemStationPlatform_batchKeyElement2";
        var option = [];
        var option2 = [];
        var previousHBarCode = "";
        //#endregion
        //#region è¿›å…¥é¡µé¢å³åŠ è½½
@@ -367,6 +374,9 @@
                    $("#HBarCode_Batch").focus();
                    return
                }
                if (!checkHSNAndDate(HBarCode_SN)) {
                    return
                }
                if (HBarCode_SN) {
                    createBillNo();
                    txtHBarCodeSN_KeyDown(HBarCode_SN);
@@ -388,6 +398,19 @@
                    $("#HBarCode_SN").focus();
                    return
                }
                if ($("#HBarCode_SN").val().substring(0, 5) == "51510" || $("#HBarCode_SN").val().substring(0, 5) == "77217") {
                    var sql = "exec h_p_Cj_BlueToothBarCodeSave '" + $("#HBarCode_Key").val() + "'," + option.data[0].HMaterID + "," + "100004" + ",'" + sessionStorage["HUserName"] + "'";
                    $.ajax({
                        type: "GET",
                        url: GetWEBURL() + "/Gy_SOPBillList/UpDelSQL", //方法所在页面和方法名
                        async: false,
                        data: { "sWhere": sql },
                        success: function (result) {
                        }
                    })
                }
                if (HBarCode_Key) {
                    txtHBarCodeKey_KeyDown(HBarCode_Key);
                }
@@ -403,36 +426,17 @@
        });
        //换产品
        form.on('submit(btnNextProc)', function (data) {
            //for (var i = 0; i < option.data.length; i++) {
            //    if (option.data[i].HBindingQty < 1 || option.data[i].HBarCode == "") {
            //        layer.alert("第<span style='color: red;'>" + (i + 1) + "</span>行,配件 <span style='color: blue;'>" + option.data[i].HMaterName + "</span> æœªç»‘定齐整!")
            //        return;
            //    }
            //}
            //保存关键件
            if (AllowLoadData(data)) {
                set_SaveBill(data);
            }
            $("#HBarCode_SN").val("");
            $("#HBarCode_Key").val("");
            option.data = [];
            table.render(option);
            //启用输入框,背景色恢复
            $("#HBarCode_SN").prop("readonly", false);
            $("#HBarCode_SN").css('background', '#FFFFFF')//产品码文本框背景色恢复
            $("#HBarCode_SN").focus();
            //重新获取单据号
            //$.ajax({
            //    url: GetWEBURL() + "/Web/GetMAXNumPDA",
            //    type: "GET",
            //    data: { "HBillType": '3727' },
            //    success: function (d) {
            //        $("#HInterID").val(d.data[0].HInterID);
            //        $("#HBillNo").val(d.data[0].HBillNo);
            //        $("#HDate").val(Format(new Date(), "yyyy-MM-dd"));  //默认为当前日期
            //        //重新启用保存按钮
            //        $("#btnSave").removeClass("layui-btn-disabled").attr("disabled", false);
            //    }
            //});
            //历史绑定记录查询
            //get_Display();
        });
@@ -740,12 +744,13 @@
            var HBillNo = $("#HBillNo").val();
            $.ajax({
                type: "GET",
                url: GetWEBURL() + "/Cj_SingleStation/BarCodeBillBomMatch_XW",
                url: GetWEBURL() + "/Cj_SingleStation/BarCodeBillBomBind_XW",
                async: false,
                data: { "HBillNo": HBillNo,"HBarCode": HBarCode, "HBarCode_P": $('#HBarCode_SN').val(), "HProcID": $('#HProcID').val(), "user": sessionStorage["HUserName"], "HOrgID": sessionStorage["OrganizationID"] },
                dataType: "json",
                success: function (data1) {
                    if (data1.count == 1) {
                        layer.close(indexs);
                        var data = data1.data
                        for (var i = 0; i < option.data.length; i++) {
@@ -777,9 +782,7 @@
                            if (AllowLoadData(data)) {
                                set_SaveBill(data);
                            }
                        }
                        layer.close(indexs);
                        }
                    }
                    else {
                        layer.close(indexs);
@@ -821,7 +824,7 @@
                "field": {
                    "HProcID": $("#HProcID").val(), "HBatchNo": $("#HBarCode_Batch").val(),
                    "HGroupID": $("#HGroupID").val(), "HSourceID": $("#HSourceID").val(),
                    "HProdOrgID": sessionStorage["OrganizationID"],
                    "HPRDOrgID": sessionStorage["OrganizationID"],
                    "HEmpID": $("#HEmpID").val(), "HDeptID": $("#HDeptID").val()
                }
            };
@@ -862,6 +865,74 @@
        }
        //#endregion
        //校验 äº§å“å’Œå¹´æœˆ
        function checkHSNAndDate(HBarCode) {
             // 1. æ ¡éªŒHBarCode长度
            if (!HBarCode || HBarCode.length < 20) {
                layer.confirm("HBarCode长度不足20位");
                return false;
            }
            // 2. è§£æžHBarCode的年月日
            const yearLastDigit = HBarCode[12]; // ç¬¬13位(索引12),年份最后一位
            const monthCode = HBarCode[13].toUpperCase(); // ç¬¬14位,月份(N-Z)
            // è®¡ç®—年份(假设当前世纪,如2020-2029)
            const year = yearLastDigit;
            // è®¡ç®—月份(N=1, ..., Z=12)
            const validChars = "NPQRSTUVWXYZ";
            if (!validChars.includes(monthCode)) {
                layer.confirm("字符必须是 N, P-Z ä¹‹ä¸€ï¼ˆè·³è¿‡ O)");
                return false;
            }
            // è®¡ç®—月份:N=1, P=2, ..., Z=12
            const month = validChars.indexOf(monthCode) + 1;
            // 3. èŽ·å–è¾“å…¥æ¡†çš„å¹´æœˆï¼ˆæ ¼å¼NNMM,如2307表示2023å¹´7月)
            const checkDateInput = document.getElementById("HCheckDate");
            if (!checkDateInput) {
                layer.confirm("找不到HCheckDate输入框");
                return false;
            }
            const inputValue = checkDateInput.value.trim();
            if (!/^\d{4}$/.test(inputValue)) {
                layer.confirm("输入框格式错误(必须是NNMM,如2307)");
                return false;
            }
            const inputYear = inputValue.substring(1, 2); // NN(如23)
            const inputMonth = parseInt(inputValue.substring(2, 4), 10); // MM(如07)
            // 4. æ ¡éªŒå¹´æœˆæ˜¯å¦ä¸€è‡´
            if (year !== inputYear || month !== inputMonth) {
                layer.confirm(
                    `年月不匹配:HBarCode=${year}å¹´${month}月,输入框=${inputYear}å¹´${inputMonth}月`
                );
                return false;
            }
            // 5. æ ¡éªŒå‰äº”位是否与上一次一致
            const currentFirstFive = HBarCode.substring(0, 5);
            if (previousHBarCode) {
                const previousFirstFive = previousHBarCode.substring(0, 5);
                if (currentFirstFive !== previousFirstFive) {
                    layer.confirm(
                        `前五位不一致:当前=${currentFirstFive},上一次=${previousFirstFive}`
                    );
                    return false;
                }
            }
            // 6. æ›´æ–°ä¸Šä¸€æ¬¡çš„HBarCode
            previousHBarCode = HBarCode;
            $("#HCheckDate").prop("readonly", true);
            console.log("校验通过");
            return true;
        }
        function get_Display(sWhere = '') {
            var ajaxLoad = layer.load();