From dc0cf67cafa9b954ecdfb02732d1ad4b3e049e69 Mon Sep 17 00:00:00 2001 From: "tianyi@bogon" Date: Sun, 5 Nov 2023 23:35:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A5=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/inventory/addinventory.vue | 75 ++++++++++---------------------- 1 file changed, 22 insertions(+), 53 deletions(-) diff --git a/pages/inventory/addinventory.vue b/pages/inventory/addinventory.vue index 4b59071..02224bc 100644 --- a/pages/inventory/addinventory.vue +++ b/pages/inventory/addinventory.vue @@ -147,7 +147,9 @@ productId: this.carList1[i].id, productName: this.carList1[i].productName, productPicture: this.carList1[i].productPicture, - stockLogList: new Map() + productSn:this.carList1[i].productSn, + stockLogList: new Map(), + stockLogList1:[] } for (let m = 0; m < this.carList1[i].saleDetailQueryDTO.length; m++) { obj.stockLogList.set(this.carList1[i].saleDetailQueryDTO[m].name,this.carList1[i].saleDetailQueryDTO[m].productCount) @@ -156,7 +158,8 @@ this.carList.set(this.carList1[i].id, obj) console.log(this.carList) // this.lsList.set(this.carList1[i].id, obj) - } + } + this.carList1 = [] } else { //当前页有数据 for (let i = 0; i < this.carList1.length; i++) { if(this.carList.has(this.carList1[i].id) == true){ //商品相同 @@ -176,7 +179,8 @@ productId: this.carList1[i].id, productName: this.carList1[i].productName, productPicture: this.carList1[i].productPicture, - stockLogList: new Map() + stockLogList: new Map(), + stockLogList1:[] } for (let m = 0; m < this.carList1[i].saleDetailQueryDTO.length; m++) { obj.stockLogList.set(this.carList1[i].saleDetailQueryDTO[m].name,this.carList1[i].saleDetailQueryDTO[m].productCount) @@ -184,54 +188,8 @@ this.carList.set(this.carList1[i].id,obj) } - } - // for (let i = 0; i < this.carList1.length; i++) { - // for (let m = 0; m < this.carList1[i].saleDetailQueryDTO.length; m++) { - // if(this.carList.has(this.carList1[i].id) ==true){ //商品相同 - // this.lsList.get(this.carList1[i].id).forEach(function(value, key) { - // if(value.name == that.carList1[i].saleDetailQueryDTO[m].name){ //规格相同,数量相加 - // value.productCount = value.productCount + that.carList1[i].saleDetailQueryDTO[m].productCount - // }else{ //规格不同,直接set - // console.log("规格不同") - // that.lsList.set(that.carList1[i].id,that.carList1[i].saleDetailQueryDTO) - // } - // }) - // }else{ //商品不同 - // this.carList.set(this.carList1[i].id,this.carList1[i]) - // } - // } - // } - // if (that.carList.has(that.carList1[i].id) == true) { - // console.log("商品相同") - // that.lsList.forEach(function(value, key) { - // for (let m = 0; m <= that.carList1[i].saleDetailQueryDTO.length; m++) { - - // if (value.name == that.carList1[i].saleDetailQueryDTO[m].name) { - // console.log("规格相同") - // that.lsList.get(that.carList1[i].id)[key].productCount = that.lsList.get(that - // .carList1[i].id)[key].productCount + value.productCount - - // } else { - // console.log('key', key) - // console.log("规格不同") - // console.log(that.carList1[i].saleDetailQueryDTO[m]) - // if (key + 1 == that.lsList.size) { - // that.lsList.set(that.carList1[i].id, that.carList1[i].saleDetailQueryDTO[ - // m]) - // } - - - // } - - // } - // }) - - // } else { //商品id不同 - // console.log("商品不同") - // this.carList.set(this.carList1[i].id, this.carList1[i]) - // this.lsList.set(this.carList1[i].id, this.carList1[i].saleDetailQueryDTO) - // } - + } + this.carList1 = [] } console.log('carList1', this.carList1) @@ -311,9 +269,20 @@ // purchaseDetails.push(obj) // } let purchaseDetails = []; - this.carList.forEach(function(value,key){ + this.carList.forEach(function(value, key){ + console.log(value.stockLogList) + value.stockLogList.forEach(function(values, keys){ + let obj={ + productSpecs:values, + changeStock:keys + } + value.stockLogList1.push(obj) + }) + console.log(value) purchaseDetails.push(value) - }) + }) + + console.log(purchaseDetails) this.tui.request("/app/stock/putInOfProduct", "post", { purchase: purchase, purchaseDetails: purchaseDetails