From d0a0275d2edcc29c03af5b644c35a92f73de2cec Mon Sep 17 00:00:00 2001 From: weipengfei <2187978347@qq.com> Date: Fri, 27 Oct 2023 19:06:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BB=84=E4=BB=B6=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=95=86=E5=93=81=E5=90=8E=E5=86=8D=E6=AC=A1=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=95=B0=E9=87=8F=E4=B8=8D=E5=8F=98=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/realselist/realselist.vue | 39 +++++++++++------------- components/shoppinglist/shoppinglist.vue | 4 ++- 2 files changed, 21 insertions(+), 22 deletions(-) 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) {