|
|
|
@ -63,23 +63,16 @@ |
|
|
|
<view class="popup-content"> |
|
|
|
<view class="popup-title"> |
|
|
|
<view class="popup-title-left"> |
|
|
|
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/c09dfa8c61c949f8b0dbb8f041d5a501.png" |
|
|
|
<img :src="goodsDetail.productPicture" |
|
|
|
alt=""> |
|
|
|
</view> |
|
|
|
<view class="popup-title-right"> |
|
|
|
<view class="popup-title-right-box" style="color: #088FEB;">{{goodsDetail.productName}} |
|
|
|
</view> |
|
|
|
<view class="popup-title-right-box">{{goodsDetail.productSn}}</view> |
|
|
|
<!-- <view class="popup-title-right-box" style="color: darkorange;" @tap="inputDialogToggle"> |
|
|
|
<text style="margin-right:20rpx;">修改价格</text> |
|
|
|
</view> --> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="popup-container"> |
|
|
|
<!-- <view class="purchase-price" v-if="storageType == 0"> |
|
|
|
<view style="margin-right: 20rpx;">实际价格</view> |
|
|
|
<uni-easyinput type="text" v-model="purchasePrice" placeholder="请输入实际价格" /> |
|
|
|
</view> --> |
|
|
|
<ul style="border-top:20rpx;"> |
|
|
|
<li v-for="(items,index) in goodsDetail.attributeList" :key="index"> |
|
|
|
<view class="title-fur"> |
|
|
|
@ -104,7 +97,7 @@ |
|
|
|
<view class="popup-bottom" v-for="(item,index) in temporaryList" :key="index"> |
|
|
|
<view class="popup-bottom-left"> |
|
|
|
<text>{{zNum}} 件</text> |
|
|
|
<text>¥{{zPrice}}</text> |
|
|
|
<!-- <text>¥{{zPrice}}</text> --> |
|
|
|
</view> |
|
|
|
<view class="popup-bottom-right"> |
|
|
|
<view class="bottom-btn" @tap="temporaryCheck">选好了</view> |
|
|
|
@ -113,51 +106,36 @@ |
|
|
|
</view> |
|
|
|
</uni-popup> |
|
|
|
</view> |
|
|
|
<!-- 弹出输入框 --> |
|
|
|
<uni-popup ref="inputDialog" background-color="#fff" @change="change"> |
|
|
|
<view class="popup-pay-content"> |
|
|
|
<view class="popup-pay-title"> |
|
|
|
<text>选择商品价格</text> |
|
|
|
</view> |
|
|
|
<view class="popup-pay-container" @tap="checkPay(goodsDetail.price)"> |
|
|
|
<text style="display: inline-block">零售价:¥{{goodsDetail.price}}</text> |
|
|
|
</view> |
|
|
|
<view class="popup-pay-container" @tap="checkPay(goodsDetail.wholesalePrice)"> |
|
|
|
<text style="display: inline-block">批发价:¥{{goodsDetail.wholesalePrice}}</text> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</uni-popup> |
|
|
|
<!-- 购物车弹出层 --> |
|
|
|
<uni-popup ref="carPopup" background-color="#fff" @change="change"> |
|
|
|
<view class="popup-content"> |
|
|
|
<view v-for="(value,key) in Array.from(newList)" :key="key" style="position: relative;"> |
|
|
|
<view v-for="(item,index) in carList" :key="index" style="position: relative;"> |
|
|
|
<view class="popup-title"> |
|
|
|
<view class="popup-title-left"> |
|
|
|
<img src="https://jewel-shop.oss-cn-beijing.aliyuncs.com/c09dfa8c61c949f8b0dbb8f041d5a501.png" |
|
|
|
<img :src="item.productPicture" |
|
|
|
alt=""> |
|
|
|
</view> |
|
|
|
<view class="popup-title-right"> |
|
|
|
<view class="popup-title-right-box" style="color: #088FEB;">{{value[1].productName}}</view> |
|
|
|
<view class="popup-title-right-box">{{value[1].productSn}}</view> |
|
|
|
<view class="popup-title-right-box" style="color: darkorange;" @tap="inputDialogToggle"> |
|
|
|
<text style="margin-right:20rpx;">¥{{value[1].price}}</text> |
|
|
|
<!-- <uni-icons color="#088FEB" type="compose" size="16"></uni-icons> --> |
|
|
|
<view style="position: absolute;top: 30rpx;right: 30rpx;" @tap.stop="delShop(value[1].id)"> |
|
|
|
<view class="popup-title-right-box" style="color: #088FEB;">{{item.productName}}</view> |
|
|
|
<view class="popup-title-right-box">{{item.productSn}}</view> |
|
|
|
<view class="popup-title-right-box"> |
|
|
|
<text style="margin-right:20rpx;">供应商:{{item.supplierName}}</text> |
|
|
|
<view style="position: absolute;top: 30rpx;right: 30rpx;" @tap.stop="delShop(item)"> |
|
|
|
<uni-icons color="red" type="trash" size="26"></uni-icons> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="popup-container" v-for="(values,keys) in Array.from(value[1].stockLogList)" :key="keys"> |
|
|
|
<view class="popup-container" v-for="(item1,index1) in item.saleDetailQueryDTO" :key="index1"> |
|
|
|
<view class="checkList"> |
|
|
|
<view style="margin-right:5%;" @tap="delShopSpec(value[0],values[0])"> |
|
|
|
<view style="margin-right:5%;" @tap="delShopSpec(item.id,item1.attributeList)"> |
|
|
|
<uni-icons color="red" type="minus" size="26"></uni-icons> |
|
|
|
</view> |
|
|
|
<view class="checkList-box"> |
|
|
|
{{values[0] | sliceMsg}} |
|
|
|
{{item1.attributeList | sliceMsg}} |
|
|
|
</view> |
|
|
|
<uni-number-box max="100000" v-model="values[1]" @change="change" /> |
|
|
|
<uni-number-box max="100000" v-model="item1.productCount" @change="carChange($event,index,index1)" /> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
@ -204,9 +182,7 @@ |
|
|
|
storageType: '', |
|
|
|
carNum: 0, |
|
|
|
carType: 0, |
|
|
|
type: '', |
|
|
|
oldList: [], |
|
|
|
newList: new Map() |
|
|
|
type: '' |
|
|
|
} |
|
|
|
}, |
|
|
|
filters: { |
|
|
|
@ -235,9 +211,7 @@ |
|
|
|
methods: { |
|
|
|
//初始化获取分类列表 |
|
|
|
getGategoryList() { |
|
|
|
this.tui.request("/app/productCategory/list", "get", { |
|
|
|
// shopId: 1, |
|
|
|
}, false, true).then((res) => { |
|
|
|
this.tui.request("/app/productCategory/list", "get", {}, false, true).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
this.indexList = res.result; |
|
|
|
for (var i = 0; i < this.indexList.length; i++) { |
|
|
|
@ -298,15 +272,15 @@ |
|
|
|
if (this.temporaryList.length == 0) { |
|
|
|
this.temporaryList.push(this.attributeList); |
|
|
|
} else { |
|
|
|
for (var i = 0; i < this.temporaryList.length; i++) { |
|
|
|
for (var i = 0; i < this.temporaryList.length; i++) { |
|
|
|
console.log(this.temporaryList[i].name.indexOf(this.attributeList.name)) |
|
|
|
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 |
|
|
|
} |
|
|
|
}else{ |
|
|
|
if (this.temporaryList.length == (i + 1)) { |
|
|
|
this.temporaryList.push(this.attributeList); |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -316,9 +290,7 @@ |
|
|
|
|
|
|
|
}, |
|
|
|
temporaryChange(val) { |
|
|
|
console.log(val) |
|
|
|
this.zNum = 0 |
|
|
|
console.log(this.temporaryList) |
|
|
|
for (var i = 0; i < this.temporaryList.length; i++) { |
|
|
|
this.zNum += this.temporaryList[i].productCount |
|
|
|
} |
|
|
|
@ -343,24 +315,36 @@ |
|
|
|
pageSize: '10' |
|
|
|
}, false, false).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
console.log(res.result.records) |
|
|
|
|
|
|
|
this.shopList = res.result.records |
|
|
|
} else { |
|
|
|
this.tui.toast(res.message) |
|
|
|
} |
|
|
|
}).catch((res) => {}) |
|
|
|
}, |
|
|
|
change(){ |
|
|
|
|
|
|
|
}, |
|
|
|
//获取弹出层状态 |
|
|
|
change(e) { |
|
|
|
console.log('当前模式:' + e.type + ',状态:' + e.show); |
|
|
|
// |
|
|
|
carChange(e,index,index1) { |
|
|
|
console.log(this.carList) |
|
|
|
this.carNum = 0 |
|
|
|
for (let i = 0; i < this.carList.length; i++) { |
|
|
|
this.carList[i].num = 0 |
|
|
|
for (let m = 0; m < this.carList[i].saleDetailQueryDTO.length; m++) { |
|
|
|
this.carList[i].num += this.carList[i].saleDetailQueryDTO[m].productCount |
|
|
|
} |
|
|
|
this.carNum += this.carList[i].num |
|
|
|
} |
|
|
|
}, |
|
|
|
//弹出购物车或者商品规格选择弹窗 |
|
|
|
toggle(type, item) { |
|
|
|
// open 方法传入参数 等同在 uni-popup 组件上绑定 type属性 |
|
|
|
if (type == 'carPopup') { |
|
|
|
|
|
|
|
this.oldList = this.carList |
|
|
|
console.log(this.carList) |
|
|
|
this.oldList = this.carList |
|
|
|
this.newFun() |
|
|
|
// this.newFun() |
|
|
|
this.carNum = 0 |
|
|
|
for (let i = 0; i < this.carList.length; i++) { |
|
|
|
this.carNum += this.carList[i].num |
|
|
|
@ -373,114 +357,55 @@ |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
newFun() { |
|
|
|
//newList 已经是map格式了 新数组 初始为空 |
|
|
|
//carList 旧数组 |
|
|
|
for (let i = 0; i < this.carList.length; i++) { |
|
|
|
if (this.newList.size == 0) { //首次放值,直接放就行 |
|
|
|
let obj = { |
|
|
|
purchasePrice: this.carList[i].price, //采购价 |
|
|
|
price: 0, //总价 |
|
|
|
discount: 10, //折扣 |
|
|
|
unitPrice: 0, //单价 |
|
|
|
discountAmount: 0, //折后价 |
|
|
|
wholesalePrice: this.carList[i].wholesalePrice, //批发价 |
|
|
|
lsprice: this.carList[i].lsprice, //零售价 |
|
|
|
productCount: 0, //总数量 |
|
|
|
productId: this.carList[i].id, |
|
|
|
productName: this.carList[i].productName, |
|
|
|
productPicture: this.carList[i].productPicture, |
|
|
|
productSn: this.carList[i].productSn, |
|
|
|
stockLogList: new Map(), |
|
|
|
stockLogList1: [], |
|
|
|
supplierName: this.carList[i].supplierName //供应商 |
|
|
|
} |
|
|
|
for (let m = 0; m < this.carList[i].saleDetailQueryDTO.length; m++) { |
|
|
|
obj.stockLogList.set(this.carList[i].saleDetailQueryDTO[m].attributeList, this.carList[i] |
|
|
|
.saleDetailQueryDTO[m].productCount) |
|
|
|
} |
|
|
|
this.newList.set(this.carList[i].id, obj) |
|
|
|
} else { //不是首次,里面有值 |
|
|
|
|
|
|
|
if (this.newList.has(this.carList[i].id) == true) { //商品相同 ,给循环,判断规格是不是相同 |
|
|
|
for (let m = 0; m < this.carList[i].saleDetailQueryDTO.length; m++) { |
|
|
|
if (this.newList.get(this.carList[i].id).stockLogList.has(this.carList[i] |
|
|
|
.saleDetailQueryDTO[m].attributeList) == true) { //规格相同 |
|
|
|
this.newList.get(this.carList[i].id).stockLogList.set(this.carList[i].saleDetailQueryDTO[m].attributeList, this.newList.get(this.carList[i].id).stockLogList.get(this.carList[i].saleDetailQueryDTO[m].attributeList) + this.carList[i].saleDetailQueryDTO[m].productCount) |
|
|
|
} else { //规格不同 |
|
|
|
this.newList.get(this.carList[i].id).stockLogList.set(this.carList[i] |
|
|
|
.saleDetailQueryDTO[m]) |
|
|
|
} |
|
|
|
} |
|
|
|
} else { //商品不同,可以直接给map.set |
|
|
|
let obj = { |
|
|
|
purchasePrice: this.carList[i].price, //采购价 |
|
|
|
price: 0, |
|
|
|
discount: 10, |
|
|
|
discountAmount: 0, |
|
|
|
unitPrice: 0, //单价 |
|
|
|
wholesalePrice: this.carList[i].wholesalePrice, //批发价 |
|
|
|
lsprice: this.carList[i].lsprice, //零售价 |
|
|
|
productCount: 0, |
|
|
|
productId: this.carList[i].id, |
|
|
|
productName: this.carList[i].productName, |
|
|
|
productPicture: this.carList[i].productPicture, |
|
|
|
stockLogList: new Map(), |
|
|
|
stockLogList1: [], |
|
|
|
productSn: this.carList[i].productSn, |
|
|
|
supplierName: this.carList[i].supplierName |
|
|
|
} |
|
|
|
for (let m = 0; m < this.carList[i].saleDetailQueryDTO.length; m++) { |
|
|
|
obj.stockLogList.set(this.carList[i].saleDetailQueryDTO[m].attributeList, this.carList[i] |
|
|
|
.saleDetailQueryDTO[m].productCount) |
|
|
|
obj.productCount += this.carList[i].saleDetailQueryDTO[m].productCount |
|
|
|
} |
|
|
|
this.newList.set(this.carList[i].id, obj) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
//选择商品查询商品规格 |
|
|
|
checkGoods(item) { |
|
|
|
this.tui.request("/app/product/getById/" + item.id, "POST", {}, false, true).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
this.goodsDetail = res.result; |
|
|
|
this.tui.request("/app/productAttribute/selectAttributeAndValueByCategoryId", "POST", { |
|
|
|
categoryId: this.goodsDetail.categoryId |
|
|
|
}, false, true).then((res1) => { |
|
|
|
if (res1.code == 200) { |
|
|
|
if (typeof(res1.result) == 'string') { |
|
|
|
let newObj = JSON.parse(res1.result) |
|
|
|
let newArr = [] |
|
|
|
for (let val in newObj) { |
|
|
|
let valueObj = []; |
|
|
|
for (var i = 0; i < newObj[val].length; i++) { |
|
|
|
valueObj.push({ |
|
|
|
value: newObj[val][i], |
|
|
|
isChecked: false |
|
|
|
}) |
|
|
|
} |
|
|
|
newArr.push({ |
|
|
|
name: val, |
|
|
|
value: valueObj |
|
|
|
}) |
|
|
|
} |
|
|
|
this.goodsDetail.attributeList = newArr; |
|
|
|
this.goodsDetail.attributeList.forEach((item, index) => { |
|
|
|
this.columns[index] = item.value; |
|
|
|
this.keyList[index] = item.name; |
|
|
|
this.goodsDetail = item; |
|
|
|
this.temporaryList = [] |
|
|
|
this.columns = [] |
|
|
|
this.keyList = [] |
|
|
|
console.log(this.temporaryList) |
|
|
|
console.log(this.carList) |
|
|
|
if(this.carList != ''){ |
|
|
|
this.zNum = 0 |
|
|
|
for(let i=0;i<this.carList.length;i++){ |
|
|
|
|
|
|
|
if(item.id == this.carList[i].id){ |
|
|
|
this.zNum = this.carList[i].num |
|
|
|
this.temporaryList = this.carList[i].saleDetailQueryDTO |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
this.tui.request("/app/productAttribute/selectAttributeAndValueByCategoryId", "POST", { |
|
|
|
categoryId: this.goodsDetail.categoryId |
|
|
|
}, false, true).then((res1) => { |
|
|
|
if (res1.code == 200) { |
|
|
|
if (typeof(res1.result) == 'string') { |
|
|
|
let newObj = JSON.parse(res1.result) |
|
|
|
let newArr = [] |
|
|
|
for (let val in newObj) { |
|
|
|
let valueObj = []; |
|
|
|
for (var i = 0; i < newObj[val].length; i++) { |
|
|
|
valueObj.push({ |
|
|
|
value: newObj[val][i], |
|
|
|
isChecked: false |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
this.tui.toast(res.message) |
|
|
|
newArr.push({ |
|
|
|
name: val, |
|
|
|
value: valueObj |
|
|
|
}) |
|
|
|
} |
|
|
|
}).catch((res) => {}) |
|
|
|
this.goodsDetail.attributeList = newArr; |
|
|
|
this.goodsDetail.attributeList.forEach((item, index) => { |
|
|
|
this.columns[index] = item.value; |
|
|
|
this.keyList[index] = item.name; |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
this.tui.toast(res.message) |
|
|
|
} |
|
|
|
}).catch((res) => {}) |
|
|
|
|
|
|
|
}, |
|
|
|
//顶部搜索框 |
|
|
|
search(res) { |
|
|
|
@ -513,9 +438,9 @@ |
|
|
|
this.categoryId = this.indexList[index].id |
|
|
|
this.getShareList(this.indexList[index].id) |
|
|
|
}, |
|
|
|
inputDialogToggle() { |
|
|
|
this.$refs.inputDialog.open() |
|
|
|
}, |
|
|
|
// inputDialogToggle() { |
|
|
|
// this.$refs.inputDialog.open() |
|
|
|
// }, |
|
|
|
//临时改价 |
|
|
|
changePrice(val) { |
|
|
|
this.goodsDetail.price = this.temporaryList[0].price = val |
|
|
|
@ -534,16 +459,30 @@ |
|
|
|
saleDetailQueryDTO1: [], |
|
|
|
wholesalePrice: this.goodsDetail.wholesalePrice, |
|
|
|
lsprice: this.goodsDetail.price |
|
|
|
} |
|
|
|
if(this.carList.length == 0){ |
|
|
|
this.carList.push(data) |
|
|
|
}else{ |
|
|
|
let aa = true; |
|
|
|
for(let i = 0; i < this.carList.length; i++){ |
|
|
|
if(this.carList[i].id == data.id){ |
|
|
|
this.carList[i] = data |
|
|
|
aa = false |
|
|
|
} |
|
|
|
} |
|
|
|
if(aa){ |
|
|
|
this.carList.push(data) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this.carList.push(data) |
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < this.carList.length; i++) { |
|
|
|
this.carList[i].num = 0 |
|
|
|
for (let m = 0; m < this.carList[i].saleDetailQueryDTO.length; m++) { |
|
|
|
this.carList[i].num += this.carList[i].saleDetailQueryDTO[m].productCount |
|
|
|
} |
|
|
|
} |
|
|
|
console.log(this.carList) |
|
|
|
|
|
|
|
this.temporaryList = [] |
|
|
|
this.purchasePrice = '' |
|
|
|
this.zPrice = '' |
|
|
|
@ -558,33 +497,50 @@ |
|
|
|
|
|
|
|
}, |
|
|
|
//删除整条商品 |
|
|
|
delShop(id) { |
|
|
|
delShop(item) { |
|
|
|
var that = this; |
|
|
|
uni.showModal({ |
|
|
|
title: "提示", |
|
|
|
content: "确定删除此条商品吗?", |
|
|
|
success: function(res) { |
|
|
|
if (res.confirm) { |
|
|
|
if (that.newList.has(id) == true) { |
|
|
|
that.newList.delete(id) |
|
|
|
if (res.confirm) { |
|
|
|
for(let i=0;i<that.carList.length;i++){ |
|
|
|
if(that.carList[i].id == item.id){ |
|
|
|
that.carNum -= that.carList[i].num |
|
|
|
that.carList.splice(i, 1) |
|
|
|
} |
|
|
|
} |
|
|
|
that.carType = that.carList.length |
|
|
|
} |
|
|
|
that.$forceUpdate() |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
//删除商品下的某一个规格 |
|
|
|
delShopSpec(name) { |
|
|
|
delShopSpec(index,index1) { |
|
|
|
var that = this; |
|
|
|
uni.showModal({ |
|
|
|
title: "提示", |
|
|
|
content: "确定删除此条商品吗?", |
|
|
|
success: function(res) { |
|
|
|
if (res.confirm) { |
|
|
|
that.newList.get(id).stockLogList.delete(name) |
|
|
|
if (that.newList.get(id).stockLogList.size == 0) { |
|
|
|
that.newList.delete(id) |
|
|
|
for(let i=0;i<that.carList.length;i++){ |
|
|
|
for(let m=0;m<that.carList[i].saleDetailQueryDTO.length;m++){ |
|
|
|
if(that.carList[i].id == index){ |
|
|
|
if(that.carList[i].saleDetailQueryDTO[m].attributeList == index1){ |
|
|
|
that.carList[i].num -= that.carList[i].saleDetailQueryDTO[m].productCount |
|
|
|
that.carNum -= that.carList[i].saleDetailQueryDTO[m].productCount |
|
|
|
that.carList[i].saleDetailQueryDTO.splice(m, 1) |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
if(that.carList[i].saleDetailQueryDTO.length == 0){ |
|
|
|
that.carList.splice(i, 1) |
|
|
|
} |
|
|
|
} |
|
|
|
that.carType = that.carList.length |
|
|
|
} |
|
|
|
that.$forceUpdate() |
|
|
|
} |
|
|
|
|