guhongwei 2 年之前
父節點
當前提交
3184b3a2a8
共有 1 個文件被更改,包括 32 次插入14 次删除
  1. 32 14
      src/views/selfShop/order/parts/parts/detail-2.vue

+ 32 - 14
src/views/selfShop/order/parts/parts/detail-2.vue

@@ -98,27 +98,45 @@ export default {
       }
     },
     handleSelect(goodsList, address) {
-      let fileList = [];
-      if (this.fileList.length == 0) {
+      let fileList = this.fileList;
+      if (fileList.length == 0) {
         fileList.push({ goodsList, address });
-        this.$set(this, 'fileList', fileList);
       } else {
-        for (const val of this.fileList) {
-          // 判断this.fileList里是否有和选中的地址id相同的
-          if (val.address._id == address._id) {
-            // 判断是否有选中的商品,没有就过滤掉
-            if (goodsList.length == 0) {
-              let p2 = this.fileList.filter((f) => f.address._id != address._id);
-              this.fileList = p2;
-            } else {
+        if (goodsList.length > 0) {
+          for (const val of fileList) {
+            if (address._id == val.address._id) {
               val.goodsList = goodsList;
+            } else {
+              fileList.push({ goodsList, address });
             }
-          } else {
-            // 判断this.fileList里是否有和选中的地址id相同的,不同就push到fileList里
-            this.fileList.push({ goodsList, address });
           }
+        } else {
+          let p1 = fileList.filter((i) => i.address._id != address._id);
+          fileList = p1;
         }
       }
+      let list = _.uniqBy(fileList, 'address._id');
+      this.$set(this, 'fileList', list);
+      // if (this.fileList.length == 0) {
+      //   fileList.push({ goodsList, address });
+      //   this.$set(this, 'fileList', fileList);
+      // } else {
+      //   for (const val of this.fileList) {
+      //     // 判断this.fileList里是否有和选中的地址id相同的
+      //     if (val.address._id == address._id) {
+      //       // 判断是否有选中的商品,没有就过滤掉
+      //       if (goodsList.length == 0) {
+      //         let p2 = this.fileList.filter((f) => f.address._id != address._id);
+      //         this.fileList = p2;
+      //       } else {
+      //         val.goodsList = goodsList;
+      //       }
+      //     } else {
+      //       // 判断this.fileList里是否有和选中的地址id相同的,不同就push到fileList里
+      //       this.fileList.push({ goodsList, address });
+      //     }
+      //   }
+      // }
     },
     toFile() {
       const workbook = new ExcelJS.Workbook();