From c104bf2b4ecf604245b38590bf1e8119530de10b Mon Sep 17 00:00:00 2001
From: yaowanxin <3588231647@qq.com>
Date: 星期二, 12 八月 2025 16:26:55 +0800
Subject: [PATCH] Merge branch 'ywx' of http://114.132.189.42:9002/r/product-inventory-management into dev_ai

---
 src/utils/util.js |   92 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 92 insertions(+), 0 deletions(-)

diff --git a/src/utils/util.js b/src/utils/util.js
new file mode 100644
index 0000000..78846dc
--- /dev/null
+++ b/src/utils/util.js
@@ -0,0 +1,92 @@
+//闃叉姈
+export  function debounce(fn) {
+    console.log(1)
+    let t = null //鍙細鎵ц涓�娆�
+    debugger
+
+    return function (){
+        if(t){
+            clearTimeout(t)
+        }
+        t = setTimeout(()=>{
+            console.log(temp);  //鍙互鑾峰彇
+            // console.log(arguments[0]) //undefined
+            fn.apply(this,arguments)
+            //鍦ㄨ繖涓洖璋冨嚱鏁伴噷闈㈢殑argument鏄繖涓洖璋冨嚱鏁扮殑鍙傛暟锛屽洜涓烘病鏈夊弬鏁版墍浠ndefined锛屽彲浠ラ�氳繃澶栭潰鐨勫嚱鏁拌祴鍊兼潵杩涜璁块棶
+            //涔熷彲浠ユ敼鍙樻垚绠ご鍑芥暟,绠ご鍑芥暟鐨則his鏄寚鍚戝畾涔夊嚱鏁扮殑閭d竴灞傜殑锛屾墍浠ヨ闂埌鐨刟rguments鏄笂涓�灞傚嚱鏁扮殑arguments
+        },1000)
+
+    }
+}
+//鑺傛祦
+export function throttle(fn, delay = 200) {
+    let timer = null
+    console.log(fn);
+    debugger
+    return function () {
+        if(timer) return
+        timer = setTimeout(() => {
+            debugger
+          fn.apply(this,arguments)
+          timer = null
+        })
+    }
+ }
+//涓嬫媺鍔ㄧ敾
+ export function animation(obj, target, fn1) {
+    // console.log(fn1);
+    // fn鏄竴涓洖璋冨嚱鏁帮紝鍦ㄥ畾鏃跺櫒缁撴潫鐨勬椂鍊欐坊鍔�
+    // 姣忔寮�瀹氭椂鍣ㄤ箣鍓嶅厛娓呴櫎鎺夊畾鏃跺櫒
+    clearInterval(obj.timer);
+    obj.timer = setInterval(function () {
+      // 姝ラ暱璁$畻鍏紡  瓒婃潵瓒婂皬
+      // 姝ラ暱鍙栨暣
+      var step = (target - obj.scrollTop) / 10;
+      step = step > 0 ? Math.ceil(step) : Math.floor(step);
+      if (obj.scrollTop >= target) {
+        clearInterval(obj.timer);
+        // 濡傛灉fn1瀛樺湪锛岃皟鐢╢n
+        if (fn1) {
+          fn1();
+        }
+      } else {
+        // 姣�30姣灏卞皢鏂扮殑鍊肩粰obj.left
+        obj.scrollTop = obj.scrollTop + step;
+      }
+    }, 10);
+  }
+
+  //鍒ゆ柇鏂囦欢绫诲瀷
+  export function judgeFileType(file) {
+    if (file == null||file == ""){  
+         alert("璇烽�夋嫨瑕佷笂浼犵殑鍥剧墖!");  
+         return false;  
+    }  
+    if (file.lastIndexOf('.')==-1){    //濡傛灉涓嶅瓨鍦�"."    
+        alert("璺緞涓嶆纭�!");  
+        return false;  
+    }  
+    var AllImgExt=".jpg|.jpeg|.gif|.bmp|.png|";  
+    var extName = file.substring(file.lastIndexOf(".")).toLowerCase();//锛堟妸璺緞涓殑鎵�鏈夊瓧姣嶅叏閮ㄨ浆鎹负灏忓啓锛�          
+    if(AllImgExt.indexOf(extName+"|")==-1)          
+    {  
+        ErrMsg="璇ユ枃浠剁被鍨嬩笉鍏佽涓婁紶銆傝涓婁紶 "+AllImgExt+" 绫诲瀷鐨勬枃浠讹紝褰撳墠鏂囦欢绫诲瀷涓�"+extName;  
+        alert(ErrMsg);  
+        return false;  
+    }  
+  }
+
+  //鏂囦欢绫诲瀷
+  export function fileType() {
+    return {
+      'application/msword': 'word',
+      'application/pdf': 'pdf',
+      'application/vnd.ms-powerpoint': 'ppt',
+      'application/vnd.ms-excel': 'excel',
+      'aplication/zip': 'zpi',
+    }
+  }
+
+  export function filterArr(arr) {
+      return arr.filter(item => item.flag !== false);
+  }
\ No newline at end of file

--
Gitblit v1.9.3