Commit 7113e787 by 李伟康

feat(OrderPopup): 优化多规格商品选择逻辑,避免重复添加

feat(DailyReport): 动态控制输入框最大长度并修复数值上限判断
feat(CreateOrder): 支持弹窗确认回调传递标识参数并优化商品过滤逻辑
1 parent 34e4a7d4
......@@ -419,11 +419,17 @@ export default {
let goodsArr = goodsList[index].multipleSpecificationsGoods.specificationGoodsMap[str]
//当多规格商品只有一个时,直接选中
if (goodsArr.length == 1) {
let { chooseList } = this,
addIndex = -1
chooseList.map((item, ind) => {
if (item.goodsFlag == 2 && item.multipleSpecificationsGoods.id == goodsList[index].multipleSpecificationsGoods.id) addIndex = ind
})
goodsList[index].active = true
goodsList[index].multipleSpecificationsGoods.goods = goodsArr[0]
goodsList[index].multipleSpecificationsGoods.goods.goodsId = goodsList[index].multipleSpecificationsGoods.goods.merchantGoodsId
goodsList[index].multipleSpecificationsGoods.goods.specificationStr = goodsList[index].multipleSpecificationsGoods.goods.specificationData.replace(/;~;/g, '/')
this.chooseList.push(goodsList[index])
if (addIndex == -1) this.chooseList.push(goodsList[index])
else this.chooseList[addIndex] = goodsList[index]
this.$emit('choose', this.chooseList)
} else {
//多个多规格商品时出现弹窗
......@@ -450,12 +456,16 @@ export default {
})
let { chooseList } = this
chooseList.forEach((item, ind) => {
if (item.multipleSpecificationsGoods.id === goodsList[index].multipleSpecificationsGoods.id) {
if (item.goodsFlag == 2 && item.multipleSpecificationsGoods.id == goodsList[index].multipleSpecificationsGoods.id) {
chooseList.splice(ind, 1)
console.log(chooseList)
}
})
// this.chooseList = chooseList
console.log(this.chooseList)
this.$emit('choose', this.chooseList)
}
// console.log(this.list, index, goodsList[index])
this.$set(this.list, index, goodsList[index])
} else {
if (goodsList[index].active) {
......@@ -466,7 +476,7 @@ export default {
})
let { chooseList } = this
chooseList.forEach((item, ind) => {
if (item.multipleSpecificationsGoods.id === goodsList[index].multipleSpecificationsGoods.id) {
if (item.goodsFlag == 2 && item.multipleSpecificationsGoods.id === goodsList[index].multipleSpecificationsGoods.id) {
chooseList.splice(ind, 1)
}
})
......
......@@ -127,7 +127,7 @@
:placeholder="i.inputPlaceholder || '请输入'"
placeholder-class="placeholder"
@blur="handleCarInputBlur($event, i , item , index)"
:maxlength="3"
:maxlength="i.maxlength || 3"
:key="dateKey[`${i.key}_${index}`]"
auto-blur
>
......@@ -353,6 +353,7 @@ export default {
required: true,
min: 0,
max: 3000,
maxlength: 4,
inputPlaceholder: ''
},
{
......@@ -362,6 +363,7 @@ export default {
required: true,
min: 0,
max: 3000,
maxlength: 4,
inputPlaceholder: ''
},
]),
......@@ -635,11 +637,11 @@ export default {
handleCarInputBlur (e, i, item, index) {
let { value } = e.detail
if (value) {
let { key } = i,
let { key, max } = i,
numbers = value.match(/\d+/g)
numbers = numbers ? numbers.join('') : ''
if (numbers.length > 1) numbers = numbers.replace(/^0+/, '')
item[key] = Math.min(Math.max(Number(numbers), 0), 100).toString()
item[key] = Math.min(Math.max(Number(numbers), 0), max).toString()
this.dateKey[`${key}_${index}`] = Date.now()
}
},
......
......@@ -449,7 +449,7 @@ export default {
if (val.value == 'payee') this.changePayee()
},
// 弹窗确认回调
onConfirm (val) {
onConfirm (val, flag) {
console.log(val, 'onConfirm')
this.externalData = []
// // const { chooseContent } = val
......@@ -474,14 +474,13 @@ export default {
this.$set(this.orderObj, 'skuGoods', chooseContent)
} else {
// 过滤出已选的goodFlag为2的对象
const selectedGoods = this.orderObj.skuGoods.filter(item => item.goodsFlag === 2)
const singleGoods = chooseContent.filter(item => item.goodsFlag != 2)
const selectedGoods = this.orderObj[_typeValue.key].filter(item => item.goodsFlag === 2)
const singleGoods = flag ? this.orderObj[_typeValue.key].filter(item => item.goodsFlag != 2) : chooseContent.filter(item => item.goodsFlag != 2)
const moreGoods = chooseContent
.filter(item => item.goodsFlag === 2)
.filter(item => {
return !selectedGoods.some(selectedItem => selectedItem.multipleSpecificationsGoods.goods.goodsId === item.multipleSpecificationsGoods.goods.goodsId)
})
console.log(singleGoods, '===')
// 合并已选的goodFlag为2的对象
this.orderObj.skuGoods = [...singleGoods, ...moreGoods, ...selectedGoods]
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!