Commit d36bc044 by cen

Merge branch 'V4.56.0' of http://192.168.3.233:8090/glsx/gl_tape into V4.56.0

2 parents 795dbdde 07b64f2f
......@@ -18,10 +18,10 @@
</Product>
</template>
<template slot="package">
<Package v-if="orderObj.package" :list="orderObj.package" :positionTypeList="positionTypeList"></Package>
<Package v-if="orderObj.package" @changeTotalPrice="changeTotalPrice" :list="orderObj.package" :positionTypeList="positionTypeList"></Package>
</template>
<template slot="skuGoods">
<SkuGoods v-if="orderObj.skuGoods" :list="orderObj.skuGoods" :positionTypeList="positionTypeList" :baseConfigData="baseConfigData"></SkuGoods>
<SkuGoods v-if="orderObj.skuGoods" :list="orderObj.skuGoods" @changeTotalPrice="changeTotalPrice" :positionTypeList="positionTypeList" :baseConfigData="baseConfigData"></SkuGoods>
<view class="total" v-if="totalPrice > 0">
<view class="total-left">总价</view>
<view class="total-right">¥{{totalPrice}}</view>
......@@ -211,12 +211,26 @@ export default {
})
this.$set(this.orderObj, 'couponInfo', couponName + customerCouponCode)
} else if (productFields.includes(_typeValue.key)) {
if (_typeValue.key == 'skuGoods') {
if (!this.orderObj[_typeValue.key]) {
this.$set(this.orderObj, _typeValue.key, chooseContent)
} else {
// 过滤出已选的goodFlag为2的对象
const selectedGoods = this.orderObj[_typeValue.key].filter(item => item.goodsFlag === 2)
const singleGoods = chooseContent.filter(item => item.goodsFlag === 1)
const moreGoods = chooseContent.filter(item => item.goodsFlag === 2).filter(item => {
return !selectedGoods.some(selectedItem => selectedItem.multipleSpecificationsGoods.id === item.multipleSpecificationsGoods.id)
})
// 合并已选的goodFlag为2的对象
this.orderObj[_typeValue.key] = [...singleGoods, ...moreGoods, ...selectedGoods]
}
} else {
this.$set(this.orderObj, _typeValue.key, chooseContent)
}
// 商品类,需计算总价
this.$set(this.orderObj, _typeValue.key, val.chooseContent)
this.$nextTick(() => {
// 确保数据更新后再计算总价
setTimeout(() => {
this.changeTotalPrice()
})
}, 0)
} else if (_typeValue.key) {
this.orderObj[_typeValue.targetIdKey] = chooseContent[_typeValue.sourceIdKey]
this.$set(this.orderObj, _typeValue.targetNameKey, chooseContent[_typeValue.sourceNameKey])
......@@ -276,7 +290,7 @@ export default {
// 处理onlyLabel为true的特殊校验
if (onlyLabelItem.length > 0) {
// 检查frontGear、frontWindow、rearGear、rearWindow、sunRoof和couponInfo字段中是否至少有一个不为空
const labelFields = ['frontGear', 'frontWindow', 'rearGear', 'rearWindow', 'sunRoof']
const labelFields = ['frontGear', 'frontWindow', 'rearGear', 'rearWindow', 'sunRoof', 'package', 'skuGoods']
const hasValue = labelFields.some(field => {
console.log(field, this.orderObj[field])
const value = this.orderObj[field]
......@@ -285,7 +299,7 @@ export default {
console.log(hasValue, hasValue)
if (!hasValue) {
uni.showToast({
title: '请至少选择一个产品',
title: '商品不能为空',
icon: 'none'
})
return false
......@@ -313,8 +327,9 @@ export default {
}, {})
}
// 将 frontGear、frontWindow、rearGear、rearWindow、sunRoof 字段合并到 goodsList 中
const labelFields = ['frontGear', 'frontWindow', 'rearGear', 'rearWindow', 'sunRoof']
const labelFields = ['frontGear', 'frontWindow', 'rearGear', 'rearWindow', 'sunRoof', 'package', 'skuGoods']
let goodsList = []
let subGoodsList = []
labelFields.forEach(field => {
if (Array.isArray(obj[field]) && obj[field].length > 0) {
goodsList = goodsList.concat(obj[field]);
......@@ -322,13 +337,18 @@ export default {
delete obj[field];
});
if (goodsList.length > 0) {
obj.subOrderList = goodsList.map(item => {
return {
totalPrice: item.goods.sellPrice,
number: item.goods.number,
merchantGoodsId: item.goods.merchantGoodsId
goodsList.map(e => {
if (e.goodsFlag == 1) {
// 单商品
}
})
// obj.subOrderList = goodsList.map(item => {
// return {
// totalPrice: item.goods.sellPrice,
// number: item.goods.number,
// merchantGoodsId: item.goods.merchantGoodsId
// }
// })
}
delete obj.carBrand
delete obj.couponInfo
......@@ -357,6 +377,9 @@ export default {
total += parseFloat(item.goods.sellPrice) * parseInt(item.goods.number)
} else if (item.packageGoods && item.packageGoods.upgradePrice && item.packageGoods.number) {
total += parseFloat(item.packageGoods.upgradePrice) * parseInt(item.packageGoods.number)
// item.packageGoods.goodsList.forEach(i => {
// total += parseFloat(i.sellPrice) * parseInt(item.packageGoods.number)
// })
} else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods && item.multipleSpecificationsGoods.goods.sellPrice && item.multipleSpecificationsGoods.number) {
total += parseFloat(item.multipleSpecificationsGoods.goods.sellPrice) * parseInt(item.multipleSpecificationsGoods.number)
}
......
......@@ -61,18 +61,6 @@ export default {
buttonsList: []
}
},
computed: {
// 根据类型返回对应的图标
iconSrc() {
const iconMap = {
success: 'https://img01.glsx.com.cn/weapp/resource/app-tape/media/common/icon-success.png',
error: 'https://img01.glsx.com.cn/weapp/resource/app-tape/media/common/icon-error.png',
warning: '@/assets/images/common/warning-notice.png',
info: 'https://img01.glsx.com.cn/weapp/resource/app-tape/media/common/icon-info.png'
}
return iconMap[this.type] || iconMap.info
}
},
methods: {
open() {
this.$refs.popup.open("center");
......
......@@ -12,7 +12,7 @@
<view class="add" @click="increaseNumber(item)">+</view>
</view>
</view>
<view class="price">¥{{item.packageGoods.upgradePrice}}</view>
<view class="price">¥{{changeTotal(item)}}</view>
</view>
<view class="goods-item" v-for="(goods, ind) in item.packageGoods.goodsList" :key="ind">
<view class="goods-name">{{goods.goodsAlias || goods.upgradeGoodsName}}</view>
......@@ -47,13 +47,27 @@ export default {
},
created() {
// 初始化商品数量
this.initProductNumbers()
},
mounted() {
// 确保每次使用组件时都检查并设置number属性
this.initProductNumbers()
},
updated() {
// 当组件数据更新时也检查number属性
this.initProductNumbers()
},
methods: {
// 初始化商品数量方法
initProductNumbers() {
if (this.list && this.list.length > 0) {
this.list.forEach(item => {
if (!item.packageGoods.number) {
this.$set(item.packageGoods, 'number', '1')
}
})
}
},
methods: {
// 格式化位置信息
formatPosition(item, positionTypeList) {
const filterData = positionTypeList.filter(v => v.positionValue == item)
......@@ -129,6 +143,10 @@ export default {
// 如果validMinSellPrice为Y,则强制修改值为最小值
if (goods.validMinSellPrice === 'Y' && goods.minSellPrice && parseFloat(value) < parseFloat(goods.minSellPrice)) {
console.log('最小值', goods.minSellPrice)
uni.showToast({
title: '单价不可低于商品最低价',
icon: 'none'
})
value = goods.minSellPrice.toString()
}
// 更新值
......@@ -139,6 +157,15 @@ export default {
deleteGoods(index) {
this.list.splice(index, 1)
this.$emit('changeTotalPrice')
},
// 计算套餐的总价
changeTotal(item) {
let total = 0
item.packageGoods.goodsList.forEach(i => {
total += parseFloat(i.sellPrice) * parseInt(item.packageGoods.number)
})
item.packageGoods.upgradePrice = total
return total
}
}
}
......
......@@ -87,9 +87,15 @@ export default {
if (selectedItem.name !== 'CreateOrder') {
this.transmissionOfData = null
}
this.$refs.notice.close()
}
}, {
text: '继续编辑',
type: 'primary',
callback: () => {
this.$refs.notice.close()
}
]
}]
// 打开弹窗
this.$refs.notice.open()
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!