From e761820df1fd2861f9cfff3fd4197ed3eca4b899 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Wed, 23 Jun 2021 01:10:49 +0800 Subject: [PATCH] no message --- .../pages/manage/components/DialogWrapper.vue | 22 +++++++++++-------- resources/assets/js/store/actions.js | 13 +++++++++-- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/resources/assets/js/pages/manage/components/DialogWrapper.vue b/resources/assets/js/pages/manage/components/DialogWrapper.vue index e5a812980..2d7399bf0 100644 --- a/resources/assets/js/pages/manage/components/DialogWrapper.vue +++ b/resources/assets/js/pages/manage/components/DialogWrapper.vue @@ -225,19 +225,13 @@ export default { }, }).then(({data}) => { this.tempMsgs = this.tempMsgs.filter(({id}) => id != tempId) - this.$store.dispatch("saveDialog", { - id: this.dialogId, - last_msg: data, - last_at: $A.formatDate("Y-m-d H:i:s") - }); - this.$store.dispatch("saveDialogMsg", data); + this.sendSuccess(data); }).catch(({msg}) => { $A.modalError(msg); this.tempMsgs = this.tempMsgs.filter(({id}) => id != tempId) }); // this.msgText = ''; - this.$store.dispatch("dialogMoveTop", this.dialogId); }, chatKeydown(e) { @@ -300,7 +294,6 @@ export default { msg: { }, }); this.autoBottom = true; - this.$store.dispatch("dialogMoveTop", this.dialogId); this.onActive(); break; @@ -310,11 +303,22 @@ export default { case 'success': this.tempMsgs = this.tempMsgs.filter(({id}) => id != tempId) - this.$store.dispatch("saveDialogMsg", file.data); + this.sendSuccess(file.data) break; } }, + sendSuccess(data) { + this.$store.dispatch("saveDialog", { + id: this.dialogId, + last_msg: data, + last_at: $A.formatDate("Y-m-d H:i:s") + }); + this.$store.dispatch("saveDialogMsg", data); + this.$store.dispatch("dialogMoveTop", this.dialogId); + this.$store.dispatch("increaseTaskMsgNum", this.dialogId); + }, + chatScroll(res) { switch (res.directionreal) { case 'up': diff --git a/resources/assets/js/store/actions.js b/resources/assets/js/store/actions.js index 58121436e..4828601da 100644 --- a/resources/assets/js/store/actions.js +++ b/resources/assets/js/store/actions.js @@ -598,6 +598,16 @@ export default { }) }, + /** + * 增加任务消息数量 + * @param state + * @param dialog_id + */ + increaseTaskMsgNum({state}, dialog_id) { + const task = state.tasks.find((task) => task.dialog_id === dialog_id); + if (task) task.msg_num++; + }, + /** * 获取任务 * @param state @@ -1284,8 +1294,7 @@ export default { dispatch("dialogMoveTop", dialog_id); } // 新增任务消息数量 - const task = state.tasks.find(({dialog_id}) => dialog_id === dialog_id); - if (task) task.msg_num++; + dispatch("increaseTaskMsgNum", dialog_id); } })(msgDetail); break;