From d034b575793694f8100bbef3fa691c8fa76773da Mon Sep 17 00:00:00 2001 From: weinan2087 Date: Mon, 24 Oct 2022 17:48:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B7=B2=E8=AF=BB=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/portal/user/Message.vue | 37 ++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/views/portal/user/Message.vue b/src/views/portal/user/Message.vue index 1350d00d..1f77bb79 100644 --- a/src/views/portal/user/Message.vue +++ b/src/views/portal/user/Message.vue @@ -44,10 +44,10 @@
- +
- + 未读 已读 @@ -56,7 +56,7 @@
{{ item.msgTime }}
- +
@@ -112,6 +112,7 @@ export default { checkAll: false, data: [], totalPages: '', + checkedIds:[], isIndeterminate: false, url: '' }; @@ -181,8 +182,14 @@ export default { // console.log(this.data,"点击加载中最后一次添加操作的data数据") // } // }, - setCheckAll(e) { - let flag = !e; + setCheckAll(item) { + if(item.checked){ + this.checkedIds.push(item.id); + }else{ + let obj = this.checkedIds.indexOf(item.id); + this.checkedIds.splice(obj, 1) + } + let flag = !item.checked; let has = this.data.some(msg => { return msg.checked == flag; }); @@ -191,7 +198,7 @@ export default { this.isIndeterminate = true; } else { this.isIndeterminate = false; - this.checkAll = e; + this.checkAll = item.checked; } }, //改变已读状态的操作 @@ -202,17 +209,27 @@ export default { if (!this.data[i].isRead) { ids.push(this.data[i].id); } - } - if (ids.length !== 0) { + if(this.checkedIds.length>0){ + apiMessage.updateIsRead(this.checkedIds).then(res => { + if (res.status == 200) { + this.$store.dispatch('refrashMsg'); + this.queryMessage(true) + } + }); + this.checkedIds = []; + return; + } + + if(this.checkAll){ apiMessage.updateIsRead(ids).then(res => { if (res.status == 200) { this.$store.dispatch('refrashMsg'); this.queryMessage(true) } }); + return; } - // this.queryMessage(); }, delChooseList() { let list = this.data.filter(item => item.checked).map(v => v.id);