llj
2025-12-16 1b5293c8ca79ce81b0ce5de7f4a89cc96aee6cb3
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 è¿›å…¥é¡µé¢å³åŠ è½½
@@ -365,6 +372,9 @@
                if ($("#HBarCode_Batch").val() == "" || $("#HBarCode_Batch").val() == null) {
                    layer.msg("未扫批次码请先扫码");
                    $("#HBarCode_Batch").focus();
                    return
                }
                if (!checkHSNAndDate(HBarCode_SN)) {
                    return
                }
                if (HBarCode_SN) {
@@ -862,6 +872,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();