diff --git a/pages/inventory/addinventory.vue b/pages/inventory/addinventory.vue index 353753c..709e43c 100644 --- a/pages/inventory/addinventory.vue +++ b/pages/inventory/addinventory.vue @@ -26,22 +26,27 @@ - + - - 品名:{{item.productName}} - 货号:{{item.productSn}} - 总价:{{item.price}} 数量:{{item.num}} + 品名:{{value[1].productName}} + 货号:{{value[1].productSn}} + 总价:{{value[1].price}} 数量:{{value[1].num}} + - - {{items.name}} - 单价:¥{{items.price}} - 数量:{{items.productCount}} + + {{item.name}} + + 数量:{{item.productCount}} + + + 采购价 @@ -115,7 +120,8 @@ single: '' }, khName: [], - carList: [], + carList: new Map(), + lsList: new Map(), remask: '', otherPay: 0, noPay: 0, @@ -128,37 +134,53 @@ } }, onShow() { + let that = this; this.khName = JSON.parse(JSON.stringify(this.khName)) || '' - let lsList = this.carList; - if (lsList.length == 0) { - this.carList = this.carList1 || [] - } else { //111 222 - for (var i = 0; i < lsList.length; i++) { - for (var s = 0; s < lsList[i].saleDetailQueryDTO.length; s++) { - for (var m = 0; m < this.carList1.length; m++) { - if (lsList[i].id == this.carList1[m].id) { //是相同商品 - for (var v = 0; v < this.carList1[m].saleDetailQueryDTO.length; v++) { //不是相同规格 - if (lsList[i].saleDetailQueryDTO[s].name != this.carList1[m].saleDetailQueryDTO[v].name) { - //已经是最后一项循环 - if (s + 1 == lsList[i].saleDetailQueryDTO.length) { - - this.carList[i].saleDetailQueryDTO.push(this.carList1[m].saleDetailQueryDTO[v]) - } - } else { //是相同规格 - this.carList[i].saleDetailQueryDTO[s].productCount += this.carList1[m].saleDetailQueryDTO[v].productCount - } - } - }else{ - if (i + 1 == lsList.length) { //已经是最后一项循环 - this.carList.push(this.carList1[m]) - } - } - } - } + //this.carList1 //上个页回来的 + //this.carList //这个页的最终数组 + //this.lsList //这个页的规格数组 + console.log(this.carList1) + for (let i = 0; i < this.carList1.length; i++) { + if (this.carList.size == 0) { //当前页没有数据 + 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 { //商品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(this.carList) - console.log(lsList) + console.log('carList', this.carList) + console.log('lsList', this.lsList) for (let i = 0; i < this.carList.length; i++) { this.totalAmount += this.carList[i].num this.shouldPay += this.carList[i].price @@ -219,22 +241,37 @@ supplierId: this.khName.id, //供应商id和姓名 supplierName: this.khName.consigneeName } - let purchaseDetails = [] - for (let i = 0; i < this.carList.length; i++) { - for (let m = 0; m < this.carList[i].saleDetailQueryDTO.length; m++) { - 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, //进货价 - } - purchaseDetails.push(obj) - } - - } - this.tui.request("/app/stock/putIn", "post", { + let purchaseDetails = [] + that.carList.forEach(function(value, key) { + for (let i=0;i { @@ -255,24 +292,31 @@ }) }, //编辑每一个的单价 - clickCollapse(index, index1) { + clickCollapse(index) { this.index = index - this.index1 = index1 this.$refs.inputDialog.open() }, //计算价格 - changePrice(val) { - this.shouldPay = 0 - this.carList[this.index].price = 0 - this.carList[this.index].saleDetailQueryDTO[this.index1].price = val; - console.log(this.carList) - for (let m = 0; m < this.carList[this.index].saleDetailQueryDTO.length; m++) { - this.carList[this.index].price += this.carList[this.index].saleDetailQueryDTO[m].productCount * this - .carList[this.index].saleDetailQueryDTO[m].price - } - for (let i = 0; i < this.carList.length; i++) { - this.shouldPay += this.carList[i].price - } + changePrice(val) { + 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.forEach(function(value, key) { + that.shouldPay += value.price + }) + // this.carList.get(this.index) + // this.shouldPay = 0 + // this.carList[this.index].price = 0 + // this.carList[this.index].saleDetailQueryDTO[this.index1].price = val; + // console.log(this.carList) + // for (let m = 0; m < this.carList[this.index].saleDetailQueryDTO.length; m++) { + // this.carList[this.index].price += this.carList[this.index].saleDetailQueryDTO[m].productCount * this + // .carList[this.index].saleDetailQueryDTO[m].price + // } + // for (let i = 0; i < this.carList.length; i++) { + // this.shouldPay += this.carList[i].price + // } } } } diff --git a/pages/inventory/changeGoods1.vue b/pages/inventory/changeGoods1.vue index 8cdc213..d6b54b3 100644 --- a/pages/inventory/changeGoods1.vue +++ b/pages/inventory/changeGoods1.vue @@ -90,14 +90,14 @@ - + - {{item[0]}} + {{item.name}} - + - + 数量:{{zNum}} 件 @@ -171,22 +171,22 @@ temporaryNum: 0, goodsDetail: [], attrNameList: [], - temporaryList: new Map(), - carList: new Map(), + temporaryList: [], + carList: [], columns: [], keyList: [], evalue: [], attributeList: [], - purchasePrice: 0, - zPrice: 0, - zNum: 0, - storageType: 0, - carNum: 0, - carType: 0 + purchasePrice: 0, + zPrice:0, + zNum:0, + storageType:0, + carNum:0, + carType:0 } }, onLoad() { - this.getGategoryList() + this.getGategoryList() this.storageType = uni.getStorageSync('type') }, methods: { @@ -236,43 +236,46 @@ jishuqi++ } } - // this.temporaryList = new Map(); if (this.goodsDetail.attributeList.length == jishuqi) { + let data = {} this.attributeList = { attributeList: JSON.stringify(obj), - productCount: this.temporaryNum, - name: name, - price: this.purchasePrice + productCount: this.temporaryNum, + name:name, + price:this.purchasePrice + } + + for(let i=0;i