diff --git a/pages/inventory/addinventory.vue b/pages/inventory/addinventory.vue index 709e43c..b6f357e 100644 --- a/pages/inventory/addinventory.vue +++ b/pages/inventory/addinventory.vue @@ -140,45 +140,63 @@ //this.carList //这个页的最终数组 //this.lsList //这个页的规格数组 console.log(this.carList1) - for (let i = 0; i < this.carList1.length; i++) { - if (this.carList.size == 0) { //当前页没有数据 + if (this.carList.size == 0) { //当前页没有数据 + for (let i = 0; i < this.carList1.length; i++) { console.log("没有数据") this.carList.set(this.carList1[i].id, this.carList1[i]) this.lsList.set(this.carList1[i].id, this.carList1[i].saleDetailQueryDTO) - } else { //当前页有数据 - //商品id是相同的 - if (that.carList.has(that.carList1[i].id) == true) { - console.log("商品相同") - that.lsList.get(that.carList1[i].id).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 { //当前页有数据 + 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[m]) + } + }) + }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++) { - } 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) - } + // 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) + // } - } } + console.log('carList1', this.carList1) console.log('carList', this.carList) console.log('lsList', this.lsList) for (let i = 0; i < this.carList.length; i++) { @@ -241,21 +259,21 @@ supplierId: this.khName.id, //供应商id和姓名 supplierName: this.khName.consigneeName } - let purchaseDetails = [] - that.carList.forEach(function(value, key) { - for (let i=0;i