Browse Source

入库

master
tianyi@bogon 3 years ago
parent
commit
bac0cb425e
  1. 132
      pages/inventory/addinventory.vue

132
pages/inventory/addinventory.vue

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

Loading…
Cancel
Save