diff --git a/components/realselist/realselist.vue b/components/realselist/realselist.vue index 47ee770..0d22916 100644 --- a/components/realselist/realselist.vue +++ b/components/realselist/realselist.vue @@ -173,27 +173,23 @@ //价格 producrprice(e, i, item) { this.bought[i].price = e.detail.value - this.$set(item, 'check', false); - for (let i in this.checkedArr) { - if (this.checkedArr[i].product_id == item.product_id) { - this.checkedArr.splice(i, 1) - } - } + // this.$set(item, 'check', false); + // for (let i in this.checkedArr) { + // if (this.checkedArr[i].product_id == item.product_id) { + // this.checkedArr.splice(i, 1) + // } + // } }, incrementTotal(e, i, item) { - this.$set(item, 'check', false); - for (let i in this.checkedArr) { - if (this.checkedArr[i].product_id == item.product_id) { - this.checkedArr.splice(i, 1) - } - } - - - - + // this.$set(item, 'check', false); + // for (let i in this.checkedArr) { + // if (this.checkedArr[i].product_id == item.product_id) { + // this.checkedArr.splice(i, 1) + // } + // } }, // picker修改事件 @@ -216,8 +212,10 @@ }, numberChange(data, i) { 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) { @@ -300,7 +298,6 @@ this.checkedArr.forEach((item, index) => { this.checkedArr.push(item) - }) }, /*点击选中与否*/ @@ -330,7 +327,7 @@ } acc.push(cru) } else { - console.log(acc, hash[cru[name]]) + // console.log(acc, hash[cru[name]]) acc.splice(hash[cru[name]]['index'], 1, cru) } @@ -344,7 +341,7 @@ }, /*确定提交*/ submit() { - + console.log(this.checkedArr); this.$emit('getProduct', this.checkedArr); }, diff --git a/components/shoppinglist/shoppinglist.vue b/components/shoppinglist/shoppinglist.vue index a125106..2f4912f 100644 --- a/components/shoppinglist/shoppinglist.vue +++ b/components/shoppinglist/shoppinglist.vue @@ -209,7 +209,9 @@ numberChange(data, i) { this.peicenumber = 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) {