修复组件选择商品后再次修改数量不变的bug

This commit is contained in:
weipengfei 2023-10-27 19:06:38 +08:00
parent fb50530bb3
commit d0a0275d2e
2 changed files with 21 additions and 22 deletions

View File

@ -173,27 +173,23 @@
// //
producrprice(e, i, item) { producrprice(e, i, item) {
this.bought[i].price = e.detail.value this.bought[i].price = e.detail.value
this.$set(item, 'check', false); // this.$set(item, 'check', false);
for (let i in this.checkedArr) { // for (let i in this.checkedArr) {
if (this.checkedArr[i].product_id == item.product_id) { // if (this.checkedArr[i].product_id == item.product_id) {
this.checkedArr.splice(i, 1) // this.checkedArr.splice(i, 1)
} // }
} // }
}, },
incrementTotal(e, i, item) { incrementTotal(e, i, item) {
this.$set(item, 'check', false); // this.$set(item, 'check', false);
for (let i in this.checkedArr) { // for (let i in this.checkedArr) {
if (this.checkedArr[i].product_id == item.product_id) { // if (this.checkedArr[i].product_id == item.product_id) {
this.checkedArr.splice(i, 1) // this.checkedArr.splice(i, 1)
} // }
} // }
}, },
// picker // picker
@ -216,8 +212,10 @@
}, },
numberChange(data, i) { numberChange(data, i) {
this.peicenumber = data.number; this.peicenumber = data.number;
this.bought[i].number = data.number this.bought[i].number = data.number;
// , ,
let obj = this.checkedArr.find((item)=>item.product_id==this.bought[i].product_id);
obj ? obj.number = data.number:null;
}, },
tabs(index) { tabs(index) {
@ -300,7 +298,6 @@
this.checkedArr.forEach((item, index) => { this.checkedArr.forEach((item, index) => {
this.checkedArr.push(item) this.checkedArr.push(item)
}) })
}, },
/*点击选中与否*/ /*点击选中与否*/
@ -330,7 +327,7 @@
} }
acc.push(cru) acc.push(cru)
} else { } else {
console.log(acc, hash[cru[name]]) // console.log(acc, hash[cru[name]])
acc.splice(hash[cru[name]]['index'], 1, cru) acc.splice(hash[cru[name]]['index'], 1, cru)
} }
@ -344,7 +341,7 @@
}, },
/*确定提交*/ /*确定提交*/
submit() { submit() {
console.log(this.checkedArr);
this.$emit('getProduct', this.checkedArr); this.$emit('getProduct', this.checkedArr);
}, },

View File

@ -209,7 +209,9 @@
numberChange(data, i) { numberChange(data, i) {
this.peicenumber = data.number; this.peicenumber = data.number;
this.bought[i].number = data.number this.bought[i].number = data.number
// , ,
let obj = this.checkedArr.find((item)=>item.product_id==this.bought[i].product_id);
obj ? obj.number = data.number:null;
}, },
tabs(index) { tabs(index) {