From dce4643a6790f51f07288bc3cb0e7644c289c147 Mon Sep 17 00:00:00 2001
From: duhe <226547893@qq.com>
Date: 星期三, 02 七月 2025 17:02:13 +0800
Subject: [PATCH] 1

---
 WebTM/layuiadmin/common.js |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/WebTM/layuiadmin/common.js b/WebTM/layuiadmin/common.js
index f4f6ddd..68b2fd1 100644
--- a/WebTM/layuiadmin/common.js
+++ b/WebTM/layuiadmin/common.js
@@ -20,8 +20,63 @@
         }, delay);
 
         // 閰嶇疆绔嬪嵆鎵ц
-        if(callNow) {
+        if(callNow == true) {
             func.apply(context, args)
         }
     };
-}
\ No newline at end of file
+}
+
+// 鍒ょ┖鍑芥暟
+function isEmpty(value, zeroIsEmpty = false, falseIsEmpty = false){
+    let val = value
+    // 妫�鏌ユ槸鍚︿负null  鎴栬�� undefind
+    if(val === null || val === undefined){
+        return true;
+    }
+    //濡傛灉瀛楃涓插叏閮ㄦ槸鐢辨暟瀛楁瀯鎴愮殑锛屽垯杞寲涓烘暟瀛楀瀷
+    if(isAllDigits(val) === true){
+        val = Number(val)
+    }
+
+    // 鏄惁鏄瓧绗︿覆绫诲瀷
+    if(typeof val === 'string') {
+        return val.trim().length === 0;
+    }
+
+    // 鏄惁鏄暟缁�
+    if(Array.isArray(val)) {
+        return val.length === 0;
+    }
+
+    //鏄惁鏄璞�
+    if(typeof val === 'object') {
+        return Object.keys(val).length === 0;
+    }
+
+    // 鏁板瓧绫诲瀷榛樿涓嶄负绌� 
+    if(typeof val === 'number'){
+        // 鏁板瓧涓�0瑙嗕负绌�
+        if(zeroIsEmpty == true){
+            if(val === 0){
+                return true
+            }
+        }
+        return false
+    }
+
+    // 甯冨皵绫诲瀷榛樿涓嶄负绌�
+    if (typeof val === 'boolean') {
+        // false鍊艰涓虹┖
+        if(falseIsEmpty == true){
+            if(val === 0){
+                return true
+            }
+        }
+        return false;
+    }
+}
+
+// 鍒ゆ柇鏄惁鍏ㄦ槸鏁板瓧
+function isAllDigits(str) {
+  return /^\d+$/.test(str);
+}

--
Gitblit v1.9.1