|
|
|
@ -90,14 +90,14 @@ |
|
|
|
</view> |
|
|
|
</li> |
|
|
|
</ul> |
|
|
|
<view class="checkList" v-for="item in temporaryList"> |
|
|
|
<view class="checkList" v-for="item in Array.from(temporaryList)" :key="key"> |
|
|
|
<view class="checkList-box"> |
|
|
|
{{item.name}} |
|
|
|
{{item[0]}} |
|
|
|
</view> |
|
|
|
<uni-number-box v-model="item.productCount" @change="temporaryChange" /> |
|
|
|
<uni-number-box v-model="item[1].productCount" @change="temporaryChange" /> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="popup-bottom" v-for="item in temporaryList"> |
|
|
|
<view class="popup-bottom"> |
|
|
|
<view class="popup-bottom-left"> |
|
|
|
<text>数量:{{zNum}} 件</text> |
|
|
|
<!-- <text>¥{{zPrice}}</text> --> |
|
|
|
@ -171,23 +171,22 @@ |
|
|
|
temporaryNum: 0, |
|
|
|
goodsDetail: [], |
|
|
|
attrNameList: [], |
|
|
|
temporaryList: [], |
|
|
|
carList: [], |
|
|
|
temporaryList: new Map(), |
|
|
|
carList: new Map(), |
|
|
|
columns: [], |
|
|
|
keyList: [], |
|
|
|
specsList: [], |
|
|
|
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: { |
|
|
|
@ -219,8 +218,7 @@ |
|
|
|
this.goodsDetail.attributeList[index].value[index1].isChecked = true; |
|
|
|
var name = '', |
|
|
|
evalue = [], |
|
|
|
obj = {}, |
|
|
|
specsList = [] |
|
|
|
obj = {} |
|
|
|
for (var i = 0; i < this.goodsDetail.attributeList.length; i++) { |
|
|
|
for (var m = 0, Ien = this.goodsDetail.attributeList[i].value; m < Ien.length; m++) { |
|
|
|
if (Ien[m].isChecked == true) { |
|
|
|
@ -238,45 +236,50 @@ |
|
|
|
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 |
|
|
|
} |
|
|
|
if (this.temporaryList.length == 0) { |
|
|
|
this.temporaryList.push(this.attributeList); |
|
|
|
} else { |
|
|
|
for (var i = 0; i < this.temporaryList.length; i++) { |
|
|
|
if (this.temporaryList[i].name.indexOf(this.attributeList.name) != -1) { |
|
|
|
this.temporaryList[i] = this.attributeList |
|
|
|
return |
|
|
|
} else { |
|
|
|
if (this.temporaryList.length == (i+1)) { |
|
|
|
this.temporaryList.push(this.attributeList); |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
for (let i = 0; i < this.goodsDetail.attributeList.length; i++) { |
|
|
|
this.goodsDetail.attributeList[i].isChecked = false; |
|
|
|
for (let m = 0; m < this.goodsDetail.attributeList[i].value.length; m++) { |
|
|
|
this.goodsDetail.attributeList[i].value[m].isChecked = false |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
// if (this.temporaryList.size == 0) { |
|
|
|
this.temporaryList.set(name, this.attributeList); |
|
|
|
// } else { |
|
|
|
// console.log(this.carList) |
|
|
|
// console.log(this.goodsDetail.id) |
|
|
|
console.log(Array.from(this.temporaryList)) |
|
|
|
// if (this.carList.get(this.goodsDetail.id).saleDetailQueryDTO.has(this.attributeList.name)) { |
|
|
|
|
|
|
|
// this.carList.get(this.goodsDetail.id).saleDetailQueryDTO.get(this.attributeList.name).value = this.attributeList |
|
|
|
// } else { |
|
|
|
// this.temporaryList.set(name, this.attributeList); |
|
|
|
// // this.temporaryList.push(this.attributeList); |
|
|
|
// } |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
temporaryChange(val) { |
|
|
|
temporaryChange(val) { |
|
|
|
this.zNum = 0 |
|
|
|
for (var i=0;i<this.temporaryList.length;i++) { |
|
|
|
this.zNum += this.temporaryList[i].productCount |
|
|
|
} |
|
|
|
for (var i = 0; i < this.temporaryList.length; i++) { |
|
|
|
this.zNum += this.temporaryList[i].productCount |
|
|
|
} |
|
|
|
this.zPrice = this.zNum * this.purchasePrice |
|
|
|
}, |
|
|
|
//点击底部选好了,返回上一页 |
|
|
|
backPrevPage() { |
|
|
|
let pages = getCurrentPages(); // 获取当前页面栈的实例,以数组形式按栈的顺序给出,第一个元素为首页,最后一个元素为当前页面。 |
|
|
|
let prevPage = pages[pages.length - 2]; //上一页页面实例 |
|
|
|
prevPage.$vm.carList = this.carList |
|
|
|
prevPage.$vm.carList1 = this.carList |
|
|
|
uni.navigateBack({ |
|
|
|
delta: 1 |
|
|
|
}) |
|
|
|
@ -306,10 +309,10 @@ |
|
|
|
this.type = type |
|
|
|
// open 方法传入参数 等同在 uni-popup 组件上绑定 type属性 |
|
|
|
if (type == 'carPopup') { |
|
|
|
this.$refs.carPopup.open('bottom') |
|
|
|
for (let i=0;i<this.carList.length;i++) { |
|
|
|
this.carNum += this.carList[i].num |
|
|
|
} |
|
|
|
this.$refs.carPopup.open('bottom') |
|
|
|
for (let i = 0; i < this.carList.length; i++) { |
|
|
|
this.carNum += this.carList[i].num |
|
|
|
} |
|
|
|
this.carType = this.carList.length |
|
|
|
} else { |
|
|
|
this.checkGoods(item); |
|
|
|
@ -377,72 +380,78 @@ |
|
|
|
}, |
|
|
|
//弹窗选择规格后,点击弹窗中选好了按钮 |
|
|
|
temporaryCheck() { |
|
|
|
// if(this.storageType == 0 && this.purchasePrice == 0){ |
|
|
|
// uni.showToast({ |
|
|
|
// title: "请输入采购价!", |
|
|
|
// icon: 'none' |
|
|
|
// }) |
|
|
|
// }else{ |
|
|
|
let data = { |
|
|
|
id: this.goodsDetail.id, |
|
|
|
price: this.zPrice, |
|
|
|
num: this.zNum, |
|
|
|
productName: this.goodsDetail.productName, |
|
|
|
productSn: this.goodsDetail.productSn, |
|
|
|
productPicture: this.goodsDetail.productPicture, |
|
|
|
supplierName: this.goodsDetail.supplierName, |
|
|
|
saleDetailQueryDTO:this.temporaryList |
|
|
|
} |
|
|
|
this.carList.push(data) |
|
|
|
console.log(this.carList) |
|
|
|
this.temporaryList = [] |
|
|
|
this.purchasePrice = 0 |
|
|
|
this.zPrice = '' |
|
|
|
this.zNum = '' |
|
|
|
for(let i=0;i<this.goodsDetail.attributeList.length;i++){ |
|
|
|
this.goodsDetail.attributeList[i].isChecked = false; |
|
|
|
for (let m=0;m<this.goodsDetail.attributeList[i].value.length;m++) { |
|
|
|
this.goodsDetail.attributeList[i].value[m].isChecked = false |
|
|
|
let that = this; |
|
|
|
let data = { |
|
|
|
id: this.goodsDetail.id, |
|
|
|
price: this.zPrice, |
|
|
|
num: this.zNum, |
|
|
|
productName: this.goodsDetail.productName, |
|
|
|
productSn: this.goodsDetail.productSn, |
|
|
|
productPicture: this.goodsDetail.productPicture, |
|
|
|
supplierName: this.goodsDetail.supplierName, |
|
|
|
saleDetailQueryDTO: this.temporaryList |
|
|
|
} |
|
|
|
if(that.carList.has(that.goodsDetail.id)== true){ //新增的商品在list里面有了 |
|
|
|
console.log("有了") |
|
|
|
console.log(that.carList.get(that.goodsDetail.id).saleDetailQueryDTO) |
|
|
|
data.saleDetailQueryDTO.forEach (function(value, key) { |
|
|
|
console.log(value) |
|
|
|
console.log(key) |
|
|
|
if(that.carList.get(that.goodsDetail.id).saleDetailQueryDTO.has(key) ==true){ |
|
|
|
console.log("有规格") |
|
|
|
that.carList.get(that.goodsDetail.id).saleDetailQueryDTO.get(key).productCount += value.productCount |
|
|
|
}else{ |
|
|
|
console.log("没有规格") |
|
|
|
that.carList.get(that.goodsDetail.id).saleDetailQueryDTO.set(key,value) |
|
|
|
} |
|
|
|
} |
|
|
|
this.$refs.popup.close() |
|
|
|
// } |
|
|
|
}) |
|
|
|
console.log(that.carList.get(that.goodsDetail.id).saleDetailQueryDTO) |
|
|
|
}else{ //商品在list中没有 |
|
|
|
this.carList.set(this.goodsDetail.id, data) |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
//删除整条商品 |
|
|
|
delShop(id){ |
|
|
|
var that = this; |
|
|
|
for (let i=0;i<this.carList.length;i++) { |
|
|
|
if(this.carList[i].id == id){ |
|
|
|
uni.showModal({ |
|
|
|
title: "提示", |
|
|
|
content: "确定删除此条商品吗?", |
|
|
|
success: function(res) { |
|
|
|
that.carList.splice(i,1) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
//删除商品下的某一个规格 |
|
|
|
delShopSpec(name){ |
|
|
|
var that = this; |
|
|
|
for (let i=0;i<this.carList.length;i++) { |
|
|
|
for (let m=0;m<this.carList[i].saleDetailQueryDTO.length;m++) { |
|
|
|
if(this.carList[i].saleDetailQueryDTO[m].name == name){ |
|
|
|
uni.showModal({ |
|
|
|
title: "提示", |
|
|
|
content: "确定删除此条商品吗?", |
|
|
|
success: function(res) { |
|
|
|
that.carList[i].saleDetailQueryDTO.splice(m,1) |
|
|
|
if(that.carList[i].saleDetailQueryDTO.length == 0){ |
|
|
|
that.carList.splice(i,1) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
console.log(this.carList) |
|
|
|
this.temporaryList = new Map(); |
|
|
|
this.purchasePrice = 0 |
|
|
|
this.zPrice = '' |
|
|
|
this.zNum = '' |
|
|
|
this.$refs.popup.close() |
|
|
|
|
|
|
|
}, |
|
|
|
//删除整条商品 |
|
|
|
delShop(id) { |
|
|
|
var that = this; |
|
|
|
for (let i = 0; i < this.carList.length; i++) { |
|
|
|
if (this.carList[i].id == id) { |
|
|
|
uni.showModal({ |
|
|
|
title: "提示", |
|
|
|
content: "确定删除此条商品吗?", |
|
|
|
success: function(res) { |
|
|
|
that.carList.splice(i, 1) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
//删除商品下的某一个规格 |
|
|
|
delShopSpec(name) { |
|
|
|
var that = this; |
|
|
|
for (let i = 0; i < this.carList.length; i++) { |
|
|
|
for (let m = 0; m < this.carList[i].saleDetailQueryDTO.length; m++) { |
|
|
|
if (this.carList[i].saleDetailQueryDTO[m].name == name) { |
|
|
|
uni.showModal({ |
|
|
|
title: "提示", |
|
|
|
content: "确定删除此条商品吗?", |
|
|
|
success: function(res) { |
|
|
|
that.carList[i].saleDetailQueryDTO.splice(m, 1) |
|
|
|
if (that.carList[i].saleDetailQueryDTO.length == 0) { |
|
|
|
that.carList.splice(i, 1) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|