From 3425237a2b54ca28fc3e3c5f7c35a7fbef4e15fa Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期一, 29 十二月 2025 09:19:29 +0800
Subject: [PATCH] 1

---
 WebTM/views/车间管理/单品过站_小卫/Cj_ProcessItemStationPlatform_generateSNCode.html |  187 +++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 181 insertions(+), 6 deletions(-)

diff --git "a/WebTM/views/\350\275\246\351\227\264\347\256\241\347\220\206/\345\215\225\345\223\201\350\277\207\347\253\231_\345\260\217\345\215\253/Cj_ProcessItemStationPlatform_generateSNCode.html" "b/WebTM/views/\350\275\246\351\227\264\347\256\241\347\220\206/\345\215\225\345\223\201\350\277\207\347\253\231_\345\260\217\345\215\253/Cj_ProcessItemStationPlatform_generateSNCode.html"
index cba9f25..5f01e8f 100644
--- "a/WebTM/views/\350\275\246\351\227\264\347\256\241\347\220\206/\345\215\225\345\223\201\350\277\207\347\253\231_\345\260\217\345\215\253/Cj_ProcessItemStationPlatform_generateSNCode.html"
+++ "b/WebTM/views/\350\275\246\351\227\264\347\256\241\347\220\206/\345\215\225\345\223\201\350\277\207\347\253\231_\345\260\217\345\215\253/Cj_ProcessItemStationPlatform_generateSNCode.html"
@@ -18,6 +18,7 @@
     <script src="../../../layuiadmin/MESLanguage.js"></script>
     <script src="../../../layuiadmin/SetColumn.js"></script>
     <script src="../../../layuiadmin/PubCustom.js"></script>
+    <script src="../../../layuiadmin/grwebapp.js"></script>
 </head>
 <body>
     <div class="layui-fluid" style="padding: 0;">
@@ -83,11 +84,17 @@
                                             </div>
                                         </div>
                                         <div class="layui-inline">
-                                            <label class="layui-form-label" style="width: 85px; color: red; ">鎵撳嵃妯℃澘</label>
+                                            <label class="layui-form-label" style="width: 85px;" id="">鏍¢獙骞存湀:</label>
                                             <div class="layui-input-block" style="margin-left: 120px;">
-                                                <select name="HPrintTemplate" id="HPrintTemplate" lay-filter="HPrintTemplate" >
-                                                    <option>鎵撳嵃妯℃澘1</option>
-                                                    <option>鎵撳嵃妯℃澘2</option>
+                                                <input type="text" class="layui-input" name="HCheckDate" lay-verify="HCheckDate" id="HCheckDate" style="background-color:#efefef4d;" placeholder="璇疯緭鍏ュ勾鏈堟牸寮忓2501锛堝叡鍥涗綅鍓嶄袱浣嶄唬琛ㄥ勾浠藉悗涓や綅浠h〃鏈堜唤锛�">
+                                            </div>
+                                        </div>
+                                        <div class="layui-inline">
+                                            <label class="layui-form-label">妯℃澘鍚嶇О</label>
+                                            <div class="layui-input-block" style="margin-left: 120px; width: 185px;">
+                                                <select name="HPrintTemplate" id="HPrintTemplate" class="ForFilteringSchemes" lay-filter="HPrintTemplate"
+                                                        lay-verify="HPrintTemplate">
+                                                    <!--鍔ㄦ�佹覆鏌撶粍缁�-->
                                                 </select>
                                             </div>
                                         </div>
@@ -269,6 +276,7 @@
         var HModName = "Cj_ProcessItemStationPlatform_generateSN";
         //var HModName2 = "Cj_ProcessItemStationPlatform_batch2";
         var option = [];
+        var previousHBarCode = "";
         //var option2 = [];
         //#endregion
 
@@ -281,6 +289,21 @@
         //#endregion
 
         //#region 瑙﹀彂浜嬩欢锛氬寘鎷琭orm.on(){}鏍煎紡鐨勬墍鏈夌偣鍑讳簨浠躲�侀�夋嫨浜嬩欢绛�
+
+
+        form.on('select(HPrintTemplate)', function (data) {
+            // 2. 鑾峰彇閫変腑鐨勫��
+            const selectedValue = data.value;
+
+            // 3. 淇濆瓨鍒� localStorage锛堥敭鍚嶄负 "BlueToothselectedTemplate"锛�
+            localStorage.setItem('SNselectedTemplate', selectedValue);
+
+            // 濡傛灉闇�瑕佷細璇濈骇瀛樺偍锛堟祻瑙堝櫒鍏抽棴鍚庢竻闄わ級锛屾敼鐢� sessionStorage锛�
+            // sessionStorage.setItem('selectedTemplate', selectedValue);
+
+            console.log('宸蹭繚瀛橀�夋嫨鐨勬ā鏉�:', selectedValue);
+        });
+
         //澶村伐鍏锋爮浜嬩欢
         table.on('toolbar(mainTable)', function (obj) {
             switch (obj.event) {
@@ -312,6 +335,10 @@
             if (event.keyCode == 13) {
                 var HBarCode = $('#HBarCode_SN').val();
                 if (event.keyCode == 13) {
+
+                    if (!checkHSNAndDate(HBarCode)) {
+                        return
+                    }
                     //濡傛灉闀洉鐮佷笉涓虹┖
                     if (HBarCode) {
                         txtHBarCode_KeyDown(HBarCode);
@@ -365,6 +392,31 @@
 
         //#region 姝ら〉闈㈡墍鏈夌殑鏂规硶
 
+        //#region 鑾峰彇鎵撳嵃妯℃澘
+        function getTem() {
+            //鑾峰彇鐧诲綍椤电粍缁囧垪
+            $.ajax({
+                type: "get",
+                async: false,
+                url: GetWEBURL() + "/Open_PrintTem/GetOpenTmpList_Json",
+                data: { "HNumber": "HGy_BarCodeBill" },
+                success: function (result) {
+                    var template = "";
+                    if (result.count == 1) { // 璇存槑楠岃瘉鎴愬姛浜嗭紝
+                        var data = result.data;
+                        for (var i = 0; i < data.length; i++) {
+                            template += '<option  style="color:blue;" value="' + data[i].HName + '">' + data[i].HName + '</option>';
+                        }
+                        $("#HPrintTemplate").append(template);
+                        $("#HPrintTemplate").val(localStorage.getItem('SNselectedTemplate'))
+                        form.render('select');
+                    }
+                    layer.closeAll("loading");
+                }
+            })
+        }
+            //#endregion
+
         //鍒濆鍖栫晫闈�
         function set_ClearBill() {
             //杩涘叆椤甸潰榛樿鍏夋爣鍦ㄦ祦杞崱涓�
@@ -378,6 +430,8 @@
             set_InitGrid();
             //
             get_Display();
+
+            getTem();
         }
 
         //#region 閫氳繃鐧诲綍鐢ㄦ埛鑾峰彇榛樿鍊�
@@ -423,7 +477,7 @@
                 , totalRow: true
                 , cellMinWidth: 120
                 , data: []
-                , height: 400
+                , height: 550
                 , limit: 10
                 , cols: [[
                     { type: 'numbers', title: '搴忓彿' }
@@ -498,7 +552,7 @@
                 "field": {
                     "HProcID": $("#HProcID").val(), "HBatchNo": "",
                     "HGroupID": $("#HGroupID").val(), "HSourceID": $("#HSourceID").val(),
-                    "HProdOrgID": sessionStorage["OrganizationID"],
+                    "HPRDOrgID": sessionStorage["OrganizationID"],
                     "HEmpID": $("#HEmpID").val(), "HDeptID": $("#HDeptID").val()
                 }
             };
@@ -520,6 +574,8 @@
                         $("#HBarCode_SN").focus();
 
                         $("#HReturnMessage").text("鎴愬姛鎵爜涓�涓�:" + HBarCode);
+                        //鑷姩鎵撳嵃
+                        dy_PL(HBarCode);
                         get_Display();
                     }
                     else {
@@ -537,6 +593,125 @@
             });
         }
 
+        //鎵归噺鎵撳嵃
+        function dy_PL(HBarCode) {
+            var sWhere = "select Top 1 * from h_v_IF_BarCodeBillList with(nolock) where 鏉$爜缂栧彿 = '" + HBarCode + "'"
+
+            $.ajax({
+                type: "GET",
+                url: GetWEBURL() + "/Gy_SOPBillList/WindowPrintList", //鏂规硶鎵�鍦ㄩ〉闈㈠拰鏂规硶鍚�
+                async: false,
+                data: { "sWhere": sWhere },
+                success: function (data) {
+                    if (data.count == 1) { // 璇存槑楠岃瘉鎴愬姛浜嗭紝
+
+                        if (data.data.length != 0) {
+
+
+                            var Customer = {
+                                "Table": data.data
+                            }
+
+                            var args = {
+                                type: "print",//鎵撳嵃妯″紡
+                                //type: "preview",//棰勮妯″紡
+                                showOptionDlg: false, //濡傛灉涓嶆樉绀烘墦鍗板璇濇鑰岀洿鎺ユ墦鍗帮紝灏嗘琛屾敞閲婂幓鎺夊嵆鍙�
+                                report: urlAddRandomNo("../../grf/" + $("#HPrintTemplate").val()+".grf"),
+                                data: Customer
+                            };
+
+                            console.log(data.data[0].鏉$爜缂栧彿);
+                            //var args = {
+                            //    report: urlAddRandomNo("../../grf/cs10.grf"),
+                            //    data: Customer
+                            //};
+                            webapp_ws_ajax_run(args);
+
+                        } else {
+                            layer.msg("鏌ユ棤鏁版嵁!");
+                        }
+                    }
+                    else {
+                        layer.msg(data.Message, { icon: 5 });
+                    }
+                    layer.closeAll("loading");
+                },
+                error: function (err) {
+                    layer.msg("閿欒:" + err, { icon: 5 });
+                }
+            })
+
+        }
+
+        //鏍¢獙 浜у搧鍜屽勾鏈�
+        function checkHSNAndDate(HBarCode) {
+            // 1. 鏍¢獙HBarCode闀垮害
+            if (!HBarCode || HBarCode.length < 20) {
+                layer.confirm("HBarCode闀垮害涓嶈冻20浣�");
+                return false;
+            }
+
+            // 2. 瑙f瀽HBarCode鐨勫勾鏈堟棩
+            const yearLastDigit = HBarCode[12]; // 绗�13浣嶏紙绱㈠紩12锛夛紝骞翠唤鏈�鍚庝竴浣�
+            const monthCode = HBarCode[13].toUpperCase(); // 绗�14浣嶏紝鏈堜唤锛圢-Z锛�
+
+
+            // 璁$畻骞翠唤锛堝亣璁惧綋鍓嶄笘绾紝濡�2020-2029锛�
+
+            const year = yearLastDigit;
+
+            // 璁$畻鏈堜唤锛圢=1, ..., Z=12锛�
+            const validChars = "NPQRSTUVWXYZ";
+            if (!validChars.includes(monthCode)) {
+                layer.confirm("瀛楃蹇呴』鏄� N, P-Z 涔嬩竴锛堣烦杩� O锛�");
+                return false;
+            }
+
+            // 璁$畻鏈堜唤锛歂=1, P=2, ..., Z=12
+            const month = validChars.indexOf(monthCode) + 1;
+
+
+            // 3. 鑾峰彇杈撳叆妗嗙殑骞存湀锛堟牸寮廚NMM锛屽2307琛ㄧず2023骞�7鏈堬級
+            const checkDateInput = document.getElementById("HCheckDate");
+            if (!checkDateInput) {
+                layer.confirm("鎵句笉鍒癏CheckDate杈撳叆妗�");
+                return false;
+            }
+            const inputValue = checkDateInput.value.trim();
+            if (!/^\d{4}$/.test(inputValue)) {
+                layer.confirm("杈撳叆妗嗘牸寮忛敊璇紙蹇呴』鏄疦NMM锛屽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();

--
Gitblit v1.9.1