|
|
|
@ -26,22 +26,27 @@ |
|
|
|
</u-grid-item> |
|
|
|
</u-grid> |
|
|
|
</view> |
|
|
|
<view class="shop-box" style="border-top:5px solid #eee;" v-for="(item,index) in carList" :key="item"> |
|
|
|
<view class="shop-box" style="border-top:5px solid #eee;" v-for="(value,key) in Array.from(carList)" |
|
|
|
:key="key"> |
|
|
|
<view class="shop-name"> |
|
|
|
<img :src="item.productPicture" alt="" |
|
|
|
<img :src="value[1].productPicture" alt="" |
|
|
|
style="width: 140rpx;height: 140rpx;margin: 30rpx 0 0 30rpx;"> |
|
|
|
<view class="shop-productName"> |
|
|
|
<view style="color:#FF5809;">品名:{{item.productName}}</view> |
|
|
|
<view>货号:{{item.productSn}}</view> |
|
|
|
<view>总价:{{item.price}} 数量:{{item.num}}</view> |
|
|
|
<view style="color:#FF5809;">品名:{{value[1].productName}}</view> |
|
|
|
<view>货号:{{value[1].productSn}}</view> |
|
|
|
<view>总价:{{value[1].price}} 数量:{{value[1].num}}</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
</view> |
|
|
|
<view class="shop-type"> |
|
|
|
<view class="shop-collapse" v-for="(items,index1) in item.saleDetailQueryDTO" |
|
|
|
@tap="clickCollapse(index,index1)"> |
|
|
|
<text>{{items.name}}</text> |
|
|
|
<text style="color: red;">单价:¥{{items.price}}</text> |
|
|
|
<text>数量:{{items.productCount}}</text> |
|
|
|
<view class="shop-collapse" v-for="(item,index) in value[1].saleDetailQueryDTO" |
|
|
|
@tap="clickCollapse(key,index)"> |
|
|
|
<text>{{item.name}}</text> |
|
|
|
<!-- <text style="color: red;">单价:¥{{item.price}}</text> --> |
|
|
|
<text>数量:{{item.productCount}}</text> |
|
|
|
</view> |
|
|
|
<view class="" style="position: absolute;top:0;right:0;" @tap="clickCollapse(value[1].id)"> |
|
|
|
采购价 |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
@ -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<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 = { |
|
|
|
// 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/putInOfProduct", "post", { |
|
|
|
purchase: purchase, |
|
|
|
purchaseDetails: purchaseDetails |
|
|
|
}, false, false).then((res) => { |
|
|
|
@ -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 |
|
|
|
// } |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|