diff --git a/pages/inventory/addinventory.vue b/pages/inventory/addinventory.vue index cbc2639..b644b0a 100644 --- a/pages/inventory/addinventory.vue +++ b/pages/inventory/addinventory.vue @@ -40,12 +40,14 @@ - {{values[0]}} + {{values[0] | sliceMsg}} 数量:{{values[1]}} - - 采购价 + + 维护采购价 @@ -132,6 +134,21 @@ index1: '' } }, + filters: { + sliceMsg(val) { + var name = '' + if (typeof(val) == 'string') { + let newObj = JSON.parse(val) + for (let as in newObj) { + for (var i = 0; i < newObj[as].length; i++) { + console.log(newObj[as]) + name += newObj[as] + '/' + } + } + } + return name; + } + }, onShow() { let that = this; this.khName = JSON.parse(JSON.stringify(this.khName)) || '' @@ -140,69 +157,75 @@ //this.lsList //这个页的规格数组 console.log(this.carList1) if (this.carList.size == 0) { //当前页没有数据 - for (let i = 0; i < this.carList1.length; i++) { - let obj = { - purchasePrice: this.carList1[i].price, //进货价 - price:0, - productCount: this.carList1[i].num, - productId: this.carList1[i].id, - productName: this.carList1[i].productName, - productPicture: this.carList1[i].productPicture, - 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].attributeList,this.carList1[i].saleDetailQueryDTO[m].productCount) + for (let i = 0; i < this.carList1.length; i++) { + let obj = { + purchasePrice: this.carList1[i].price, //进货价 + price: 0, + productCount: this.carList1[i].num, + productId: this.carList1[i].id, + productName: this.carList1[i].productName, + productPicture: this.carList1[i].productPicture, + 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].attributeList, this.carList1[i] + .saleDetailQueryDTO[m].productCount) } console.log("没有数据") - this.carList.set(this.carList1[i].id, obj) + 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){ //商品相同 - 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].attributeList)==true){ //规格相同 - console.log("规格相同") - this.carList.get(this.carList1[i].id).stockLogList.set(this.carList1[i].saleDetailQueryDTO[m].attributeList,this.carList.get(this.carList1[i].id).stockLogList.get(this.carList1[i].saleDetailQueryDTO[m].attributeList) + this.carList1[i].saleDetailQueryDTO[m].productCount) - }else{ //规格不同 - console.log("规格不同") - this.carList.get(this.carList1[i].id).stockLogList.set(this.carList1[i].saleDetailQueryDTO[m].attributeList,this.carList1[i].saleDetailQueryDTO[m].productCount) - } - } - }else{//商品不同 - let obj = { - purchasePrice: this.carList1[i].price, //进货价 - price:0, - productCount: this.carList1[i].num, - productId: this.carList1[i].id, - productName: this.carList1[i].productName, - productPicture: this.carList1[i].productPicture, - stockLogList: new Map(), - stockLogList1:[], - name:'' - } - for (let m = 0; m < this.carList1[i].saleDetailQueryDTO.length; m++) { - obj.stockLogList.set(this.carList1[i].saleDetailQueryDTO[m].attributeList,this.carList1[i].saleDetailQueryDTO[m].productCount) - obj.name = this.carList1[i].saleDetailQueryDTO[m].name - } - this.carList.set(this.carList1[i].id,obj) - } - - } + } else { //当前页有数据 + for (let i = 0; i < this.carList1.length; 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].attributeList) == true) { //规格相同 + console.log("规格相同") + this.carList.get(this.carList1[i].id).stockLogList.set(this.carList1[i].saleDetailQueryDTO[ + m].attributeList, this.carList.get(this.carList1[i].id).stockLogList.get(this + .carList1[i].saleDetailQueryDTO[m].attributeList) + this.carList1[i] + .saleDetailQueryDTO[m].productCount) + } else { //规格不同 + console.log("规格不同") + this.carList.get(this.carList1[i].id).stockLogList.set(this.carList1[i].saleDetailQueryDTO[ + m].attributeList, this.carList1[i].saleDetailQueryDTO[m].productCount) + } + } + } else { //商品不同 + let obj = { + purchasePrice: this.carList1[i].price, //进货价 + price: 0, + productCount: this.carList1[i].num, + productId: this.carList1[i].id, + productName: this.carList1[i].productName, + productPicture: this.carList1[i].productPicture, + stockLogList: new Map(), + stockLogList1: [], + name: '' + } + for (let m = 0; m < this.carList1[i].saleDetailQueryDTO.length; m++) { + obj.stockLogList.set(this.carList1[i].saleDetailQueryDTO[m].attributeList, this.carList1[i] + .saleDetailQueryDTO[m].productCount) + obj.name = this.carList1[i].saleDetailQueryDTO[m].name + } + this.carList.set(this.carList1[i].id, obj) + } + + } this.carList1 = [] } console.log('carList1', this.carList1) 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 - } + this.carList.forEach(function(value, key) { + that.totalAmount += value.productCount + }) this.noPay = this.shouldPay }, onLoad() { @@ -271,21 +294,21 @@ // } // purchaseDetails.push(obj) - // } - let purchaseDetails = []; - this.carList.forEach(function(value, key){ - console.log(value.stockLogList) - value.stockLogList.forEach(function(values, keys){ - let obj={ - productCount:values, - attributeList:keys - } - value.stockLogList1.push(obj) - }) - console.log(value) - purchaseDetails.push(value) - }) - + // } + let purchaseDetails = []; + this.carList.forEach(function(value, key) { + console.log(value.stockLogList) + value.stockLogList.forEach(function(values, keys) { + let obj = { + productCount: values, + attributeList: keys + } + value.stockLogList1.push(obj) + }) + console.log(value) + purchaseDetails.push(value) + }) + console.log(purchaseDetails) this.tui.request("/app/stock/putInOfProduct", "post", { purchase: purchase, @@ -308,7 +331,7 @@ }) }, //编辑每一个的单价 - clickCollapse(index) { + clickCollapse(index) { console.log(index) this.index = index this.$refs.inputDialog.open() @@ -317,7 +340,7 @@ changePrice(val) { let that = this; that.shouldPay = 0 - that.carList.get(that.index).purchasePrice = val + that.carList.get(that.index).purchasePrice = val that.carList.get(that.index).price = val * that.carList.get(that.index).productCount; that.carList.forEach(function(value, key) { that.shouldPay += value.price @@ -348,7 +371,7 @@ .content { border-top: 1px solid #eee; overflow-y: scroll; - max-height: 100vh; + max-height: 100vh; margin-bottom: 100rpx; } @@ -422,7 +445,7 @@ .shop-box { width: 95%; - margin: 0 auto; + margin: 0 auto; position: relative; }