diff --git a/pages/inventory/addinventory.vue b/pages/inventory/addinventory.vue
index b6f357e..4b59071 100644
--- a/pages/inventory/addinventory.vue
+++ b/pages/inventory/addinventory.vue
@@ -34,18 +34,17 @@
品名:{{value[1].productName}}
货号:{{value[1].productSn}}
- 总价:{{value[1].price}} 数量:{{value[1].num}}
+ 总价:{{value[1].price}} 数量:{{value[1].productCount}}
-
- {{item.name}}
+
+ {{values[0]}}
- 数量:{{item.productCount}}
+ 数量:{{values[1]}}
-
+
采购价
@@ -141,28 +140,67 @@
//this.lsList //这个页的规格数组
console.log(this.carList1)
if (this.carList.size == 0) { //当前页没有数据
- for (let i = 0; i < this.carList1.length; i++) {
+ for (let i = 0; i < this.carList1.length; i++) {
+ let obj = {
+ purchasePrice: this.carList1[i].price, //进货价
+ productCount: this.carList1[i].num,
+ productId: this.carList1[i].id,
+ productName: this.carList1[i].productName,
+ productPicture: this.carList1[i].productPicture,
+ stockLogList: new Map()
+ }
+ 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)
+ }
console.log("没有数据")
- this.carList.set(this.carList1[i].id, this.carList1[i])
- this.lsList.set(this.carList1[i].id, this.carList1[i].saleDetailQueryDTO)
+ this.carList.set(this.carList1[i].id, obj)
+ console.log(this.carList)
+ // this.lsList.set(this.carList1[i].id, obj)
}
- } else { //当前页有数据
+ } 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(this.carList.has(this.carList1[i].id) == true){ //商品相同
+ for (let m = 0; m < this.carList1[i].saleDetailQueryDTO.length; m++) {
+ if(this.carList.get(this.carList1[i].id).stockLogList.has(this.carList1[i].saleDetailQueryDTO[m].name)==true){ //规格相同
+ console.log("规格相同")
+ this.carList.get(this.carList1[i].id).stockLogList.set(this.carList1[i].saleDetailQueryDTO[m].name,this.carList.get(this.carList1[i].id).stockLogList.get(this.carList1[i].saleDetailQueryDTO[m].name) + this.carList1[i].saleDetailQueryDTO[m].productCount)
+ }else{ //规格不同
+ console.log("规格不同")
+ this.carList.get(this.carList1[i].id).stockLogList.set(this.carList1[i].saleDetailQueryDTO[m].name,this.carList1[i].saleDetailQueryDTO[m].productCount)
+ }
}
+ }else{//商品不同
+ let obj = {
+ purchasePrice: this.carList1[i].price, //进货价
+ productCount: this.carList1[i].num,
+ productId: this.carList1[i].id,
+ productName: this.carList1[i].productName,
+ productPicture: this.carList1[i].productPicture,
+ stockLogList: new Map()
+ }
+ 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)
+ }
+ 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) {
@@ -242,7 +280,7 @@
},
inventorySubmit() {
console.log(this.khName)
- console.log(this.carList)
+ console.log(Array.from(this.carList)[1])
if (this.khName == '' || this.carList == '') {
uni.showToast({
title: "信息填写完成后入库!",
@@ -259,36 +297,23 @@
supplierId: this.khName.id, //供应商id和姓名
supplierName: this.khName.consigneeName
}
- let purchaseDetails = []
- that.carList.forEach(function(value, key) {
- for (let i = 0; i < value.saleDetailQueryDTO.length; i++) {
- let obj = {
- purchasePrice: value.price, //进货价
- productCount: value.num,
- productId: key,
- productName: value.productName,
- productPicture: value.productPicture,
- stockLogList: value.saleDetailQueryDTO
-
- }
- purchaseDetails.push(obj)
- }
-
- })
- // for (let i = 0; i < this.carList.length; i++) {
- // for (let m = 0; m < this.carList[i].saleDetailQueryDTO.length; m++) {
+ // that.carList.forEach(function(value, key) {
+ // for (let i = 0; i < value.saleDetailQueryDTO.length; i++) {
// let obj = {
- // allPrice: this.carList[i].saleDetailQueryDTO[m].price * this.carList[i].saleDetailQueryDTO[
- // m].productCount,
- // attributeList: this.carList[i].saleDetailQueryDTO[m].attributeList,
- // productCount: this.carList[i].saleDetailQueryDTO[m].productCount,
- // productId: this.carList[i].id,
- // purchasePrice: this.carList[i].saleDetailQueryDTO[m].price, //进货价
+ // purchasePrice: value.price, //进货价
+ // productCount: value.num,
+ // productId: key,
+ // productName: value.productName,
+ // productPicture: value.productPicture,
+ // stockLogList: value.saleDetailQueryDTO
+
// }
// purchaseDetails.push(obj)
- // }
-
- // }
+ // }
+ let purchaseDetails = [];
+ this.carList.forEach(function(value,key){
+ purchaseDetails.push(value)
+ })
this.tui.request("/app/stock/putInOfProduct", "post", {
purchase: purchase,
purchaseDetails: purchaseDetails
@@ -310,7 +335,8 @@
})
},
//编辑每一个的单价
- clickCollapse(index) {
+ clickCollapse(index) {
+ console.log(index)
this.index = index
this.$refs.inputDialog.open()
},
@@ -319,9 +345,9 @@
let that = this;
that.shouldPay = 0
console.log(that.carList.get(that.index))
- that.carList.get(that.index).price = val * that.carList.get(that.index).num;
+ that.carList.get(that.index).purchasePrice = val * that.carList.get(that.index).productCount;
that.carList.forEach(function(value, key) {
- that.shouldPay += value.price
+ that.shouldPay += value.purchasePrice
})
// this.carList.get(this.index)
// this.shouldPay = 0