From ecd9d731c0970ea9abc764afad5432477ecc23ef Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期四, 26 三月 2026 10:57:31 +0800
Subject: [PATCH] 修改 webconfig 实现 全局 ajax请求自动载入 Token , 全局配置打开弹出层后,自动隐藏父级滚动条的功能

---
 WebTM/views/user/login.html                            |    4 +
 WebTM/views/user/login_pda.html                        |    4 +
 WebTM/layuiadmin/Scripts/webConfig.js                  |  110 +++++++++++++++++++++++++++++++++++-
 WebTM/views/生产管理/订单状态分布/Sc_OrderStateDistribution.html |    7 +-
 4 files changed, 117 insertions(+), 8 deletions(-)

diff --git a/WebTM/layuiadmin/Scripts/webConfig.js b/WebTM/layuiadmin/Scripts/webConfig.js
index e4e378d..6db8126 100644
--- a/WebTM/layuiadmin/Scripts/webConfig.js
+++ b/WebTM/layuiadmin/Scripts/webConfig.js
@@ -6,15 +6,15 @@
     //var WEBURL = "http://localhost:8082/API/";        //鏉滆春鏈湴閰嶇疆
     //var WEBURL = "http://localhost:81/API/"           //缈佹稕娑涙湰鍦伴厤缃�
     // var WEBURL = "http://localhost:8082/API/";        //寮犵憺骞挎湰鍦伴厤缃�
-    // var WEBURL = "http://localhost:81/API/";          //闄堥晲鍝叉湰鍦伴厤缃�
+    var WEBURL = "http://localhost:81/API/";          //闄堥晲鍝叉湰鍦伴厤缃�
     //var WEBURL = "http://localhost:8082/LuBaoAPI/";   //鏉庢灄淇婃湰鍦伴厤缃�
     //var WEBURL = "http://localhost:8080/API/";        //鐜嬩华鏈湴閰嶇疆
     //var WEBURL = "http://localhost:8082/LuBaoAPI/";   //浣欐�濇澃鏈湴閰嶇疆
     //var WEBURL = "http://localhost:8088/ARAPI/";      //浣欐�濇澃鏈湴閰嶇疆(瀹夌憺)
     //var WEBURL = "http://47.96.97.237/API/";          //鏅轰簯鏈嶅姟鍣�
-   /* var WEBURL = "http://localhost:8082/LuBaoAPI/";  //浣欐�濇澃鏈湴閰嶇疆*/
-    var WEBURL = "http://localhost:81/API/";            // 闄堥晲鍝叉湰鍦伴厤缃�*/
-     //var WEBURL = "http://localhost:8082/LuBaoAPI/";  //鏉庢灄淇婃湰鍦伴厤缃�
+    /* var WEBURL = "http://localhost:8082/LuBaoAPI/";  //浣欐�濇澃鏈湴閰嶇疆*/
+    // var WEBURL = "http://localhost:81/API/";            // 闄堥晲鍝叉湰鍦伴厤缃�*/
+    //var WEBURL = "http://localhost:8082/LuBaoAPI/";  //鏉庢灄淇婃湰鍦伴厤缃�
     //var WEBURL = "http://localhost:8088/ARAPI/";      //浣欐�濇澃鏈湴閰嶇疆(瀹夌憺)
     //var WEBURL = "http://61.164.86.218:8099/ABAPI/";  //濂ラ偊
     //var WEBURL = "http://10.1.4.155/API/";            //姹熶赴瀹㈡埛NEW
@@ -34,6 +34,7 @@
     //var WEBURL = "http://121.36.199.126:8181/API/";   //涓夊崌
     //var WEBURL = "http://36.134.2.30:200/WEBS-API/";  //閲戝竻
     //var WEBURL = "http://172.16.1.85/API/";           //杩﹀崡
+    // var WEBURL = "http://61.164.64.222:8082/API_WW/"
     return WEBURL
 }
 
@@ -41,3 +42,104 @@
     return GetWEBURL()
 }
 
+
+layui.use(['jquery', 'layer'], function () {
+    var $ = layui.jquery,
+        layer = layui.layer;
+
+    // 鍏ㄥ眬閰嶇疆
+    layer.config({
+        scrollbar: false
+    });
+
+    // 鍏ㄥ眬閰嶇疆 榛樿涓嶆樉绀虹埗绾ф粴鍔ㄦ
+    var _open = layer.open;
+    layer.open = function (opts) {
+        // 鍚堝苟榛樿閰嶇疆
+        var options = $.extend({}, layer.config, opts);
+
+        var oldSuccess = options.success;
+        var oldEnd = options.end;
+        var needHideScroll = options.scrollbar === false;
+
+        // 鎵撳紑寮圭獥鏃�
+        options.success = function (layero, index) {
+            if (needHideScroll) {
+                $('body').css('overflow', 'hidden');
+            }
+            if (oldSuccess) oldSuccess.call(this, layero, index);
+        };
+
+        // 鍏抽棴寮圭獥鏃�
+        options.end = function () {
+            if (needHideScroll) {
+                // 鍙湁鏈�鍚庝竴涓脊绐楀叧闂墠鎭㈠
+                if ($('.layui-layer:visible').length <= 1) {
+                    $('body').css('overflow', '');
+                }
+            }
+            if (oldEnd) oldEnd.call(this);
+        };
+
+        return _open.call(this, options);
+    };
+
+    // 鍏ㄥ眬鎷︽埅鎵�鏈� layui ajax 璇锋眰
+    $(document).ajaxSend(function (event, jqxhr, settings) {
+        var token = localStorage.getItem('token');
+        if (token) {
+            // 鑷姩甯︿笂 token
+            jqxhr.setRequestHeader('Authorization', 'Bearer ' + token);
+        }
+
+    });
+
+
+    // 缁熶竴澶勭悊 鏈璇�/鏈巿鏉冭姹�
+    $(document).ajaxComplete(function (event, jqxhr, settings) {
+        // HTTP 鐘舵�佺爜
+        var status = jqxhr.status;
+
+        if (status === 401) {
+            // 鏈櫥褰� / token 杩囨湡
+            layer.confirm('鐧诲綍宸茶繃鏈燂紝璇烽噸鏂扮櫥褰�', { icon: 7, title: '鎻愮ず' }, function () {
+                localStorage.removeItem('token');
+                window.top.location.href = '../../views/user/login.html'; // 璺冲埌鐧诲綍椤�
+
+            });
+        } else if (status === 403) {
+            // 鏃犳潈闄�
+            layer.msg('鎮ㄦ病鏈夎妯″潡鐨勬搷浣滄潈闄�', { icon: 2, time: 2000 });
+        }
+    });
+});
+
+if (typeof $ != 'undefined') {
+    $(document).ajaxSend(function (event, jqxhr, settings) {
+        var token = localStorage.getItem('token');
+        if (token) {
+            // 鑷姩甯︿笂 token
+            jqxhr.setRequestHeader('Authorization', 'Bearer ' + token);
+        }
+
+    });
+
+
+    // 缁熶竴澶勭悊 鏈璇�/鏈巿鏉冭姹�
+    $(document).ajaxComplete(function (event, jqxhr, settings) {
+        // HTTP 鐘舵�佺爜
+        var status = jqxhr.status;
+
+        if (status === 401) {
+            // 鏈櫥褰� / token 杩囨湡
+            layer.confirm('鐧诲綍宸茶繃鏈燂紝璇烽噸鏂扮櫥褰�', { icon: 7, title: '鎻愮ず' }, function () {
+                localStorage.removeItem('token');
+                window.top.location.href = '../../views/user/login.html'; // 璺冲埌鐧诲綍椤�
+
+            });
+        } else if (status === 403) {
+            // 鏃犳潈闄�
+            layui.layer.msg('鎮ㄦ病鏈夎妯″潡鐨勬搷浣滄潈闄�', { icon: 2, time: 2000 });
+        }
+    });
+}
diff --git a/WebTM/views/user/login.html b/WebTM/views/user/login.html
index e324913..b92848c 100644
--- a/WebTM/views/user/login.html
+++ b/WebTM/views/user/login.html
@@ -450,6 +450,10 @@
                             sessionStorage["Organization"] = $("#Organization option:selected").text();
                             sessionStorage["HTranSlate"] = $("#HTranSlate option:selected").val();
                             //sessionStorage["IP"] = System.Configuration.ConfigurationSettings.AppSettings("name");
+                             if(result.token) {
+                                localStorage.setItem('token', result.token)
+                            }
+                            
                             get_WriteConfigFile();
                             if (!judgeMorPCflag) {//绉诲姩绔�
                                 window.location.href = '../../views/index_Mobile.html'
diff --git a/WebTM/views/user/login_pda.html b/WebTM/views/user/login_pda.html
index 06d6fd3..eb685a2 100644
--- a/WebTM/views/user/login_pda.html
+++ b/WebTM/views/user/login_pda.html
@@ -278,7 +278,9 @@
                             sessionStorage["HWorkCenter"] = result.data[0].HWorkCenterName;
                             sessionStorage["HSPID"] = result.data[0].HSPID;
                             sessionStorage["HSPName"] = result.data[0].HSPName;
-
+                            if(result.token) {
+                                localStorage.setItem('token', result.token)
+                            }
                             layer.msg(result.Message, { icon: 1 });
                             //鐧诲綍绉诲姩绔�
                             window.location.href = '../../views/index_Mobile.html'
diff --git "a/WebTM/views/\347\224\237\344\272\247\347\256\241\347\220\206/\350\256\242\345\215\225\347\212\266\346\200\201\345\210\206\345\270\203/Sc_OrderStateDistribution.html" "b/WebTM/views/\347\224\237\344\272\247\347\256\241\347\220\206/\350\256\242\345\215\225\347\212\266\346\200\201\345\210\206\345\270\203/Sc_OrderStateDistribution.html"
index 843d4e4..107a8c0 100644
--- "a/WebTM/views/\347\224\237\344\272\247\347\256\241\347\220\206/\350\256\242\345\215\225\347\212\266\346\200\201\345\210\206\345\270\203/Sc_OrderStateDistribution.html"
+++ "b/WebTM/views/\347\224\237\344\272\247\347\256\241\347\220\206/\350\256\242\345\215\225\347\212\266\346\200\201\345\210\206\345\270\203/Sc_OrderStateDistribution.html"
@@ -121,21 +121,22 @@
             background-color: #007dff;
             color: #fff;
             padding: 8px 12px;
-            font-size: 32px;
+            font-size: 20px;
             font-weight: bold;
         }
 
         .param-list {
             display: flex;
+            gap: 4px;
             flex-wrap: wrap;
             padding: 10px 20px;
             background-color: #f2f2f2;
         }
 
         .param-item {
-            width: 24%;
+            width: 10%;
             margin-bottom: 8px;
-            font-size: 28px;
+            font-size: 14px;
             color: #333;
         }
 

--
Gitblit v1.9.1