Qukatie 7 mēneši atpakaļ
vecāks
revīzija
9f455f47d4

+ 18 - 1
src/views/boxManagement/boxPoolDynamics/components/importModule.vue

@@ -110,13 +110,30 @@ export default {
     },
     created() { },
     methods: {
+        //去重判断
+        mergeAndDeduplicate(arr1, arr2) {
+            // 合并两个数组
+            const combined = [...arr1, ...arr2];
+            // 使用Map来存储唯一对象(基于id和name)
+            const uniqueMap = new Map();
+            combined.forEach(item => {
+                // 创建一个唯一的键值对
+                const key = `${item.containerNumber}-${item.boxCode}`;
+                if (!uniqueMap.has(key)) {
+                    // 添加到Map中,确保唯一性
+                    uniqueMap.set(key, item);
+                }
+            });
+            // 从Map转换回数组
+            return Array.from(uniqueMap.values());
+        },
         //文件上传时的钩子
         onProgress(event, file, fileList) {
             this.loading = true
         },
         //文件上传成功时的钩子
         onSuccess(res, file) {
-            this.data = res.data
+            this.data = this.mergeAndDeduplicate(this.data, res.data)
             this.loading = false
         },
         //文件上传失败时的钩子