From 3a2ab7f3a7f89cd299df07126d74a2c6f3ce91f8 Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期三, 03 六月 2026 20:18:59 +0800
Subject: [PATCH] 提交:山西林昇焱工贸有限公司/山西羿神晟农生物科技发展有限公司 配置文件

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

diff --git a/src/utils/util.js b/src/utils/util.js
new file mode 100644
index 0000000..be08cc1
--- /dev/null
+++ b/src/utils/util.js
@@ -0,0 +1,121 @@
+//闃叉姈
+import dayjs from "dayjs";
+
+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 const deepCopySameProperties = (source, target) =>{
+    for (const key in source) {
+        if (target.hasOwnProperty(key)) {
+            if (typeof source[key] === 'object' && source[key] !== null &&
+                typeof target[key] === 'object' && target[key] !== null) {
+                // 閫掑綊澶勭悊瀵硅薄
+                deepCopySameProperties(source[key], target[key]);
+            } else {
+                // 鍩烘湰绫诲瀷鐩存帴璧嬪��
+                target[key] = source[key];
+            }
+        }
+    }
+    return target;
+}
+  export function filterArr(arr) {
+      return arr.filter(item => item.flag !== false);
+  }
+
+ export function getCurrentMonth () {
+    let month = dayjs().month() + 1
+    if (month <= 3) {
+        return '1';
+    } else if (month <= 6) {
+        return '2';
+    } else if (month <= 9) {
+        return '3';
+    } else if (month <= 12) {
+        return '4';
+    }
+}
\ No newline at end of file

--
Gitblit v1.9.3