From 0a3994b8a4e5d89639a0348f28754fc595d4d0e9 Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Mon, 17 Oct 2022 17:26:18 +0800
Subject: [PATCH] 相同投入品合并,优化显示

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

diff --git a/src/utils/public.js b/src/utils/public.js
index dfd16a7..2be0eb7 100644
--- a/src/utils/public.js
+++ b/src/utils/public.js
@@ -7,6 +7,50 @@
     num = num-0
     return (num > 9999) ? (num / 10000).toFixed(2) + 'w' : num.toFixed(0)
 }
+export const getObjType = obj => {
+    var toString = Object.prototype.toString;
+    var map = {
+        '[object Boolean]': 'boolean',
+        '[object Number]': 'number',
+        '[object String]': 'string',
+        '[object Function]': 'function',
+        '[object Array]': 'array',
+        '[object Date]': 'date',
+        '[object RegExp]': 'regExp',
+        '[object Undefined]': 'undefined',
+        '[object Null]': 'null',
+        '[object Object]': 'object'
+    };
+    if (obj instanceof Element) {
+        return 'element';
+    }
+    return map[toString.call(obj)];
+};
+/**
+ * 对象深拷贝
+ */
+export const deepClone = data => {
+    var type = getObjType(data);
+    var obj;
+    if (type === 'array') {
+        obj = [];
+    } else if (type === 'object') {
+        obj = {};
+    } else {
+        //不再具有下一层次
+        return data;
+    }
+    if (type === 'array') {
+        for (var i = 0, len = data.length; i < len; i++) {
+            obj.push(deepClone(data[i]));
+        }
+    } else if (type === 'object') {
+        for (var key in data) {
+            obj[key] = deepClone(data[key]);
+        }
+    }
+    return obj;
+};
 
 export default {
     numUnitConversion

--
Gitblit v1.9.3