|
@@ -98,27 +98,45 @@ export default {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
handleSelect(goodsList, address) {
|
|
handleSelect(goodsList, address) {
|
|
- let fileList = [];
|
|
|
|
- if (this.fileList.length == 0) {
|
|
|
|
|
|
+ let fileList = this.fileList;
|
|
|
|
+ if (fileList.length == 0) {
|
|
fileList.push({ goodsList, address });
|
|
fileList.push({ goodsList, address });
|
|
- this.$set(this, 'fileList', fileList);
|
|
|
|
} else {
|
|
} 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;
|
|
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() {
|
|
toFile() {
|
|
const workbook = new ExcelJS.Workbook();
|
|
const workbook = new ExcelJS.Workbook();
|