diff --git a/app/Http/Controllers/Api/DialogController.php b/app/Http/Controllers/Api/DialogController.php index ed1e2421d..fcdb870cd 100755 --- a/app/Http/Controllers/Api/DialogController.php +++ b/app/Http/Controllers/Api/DialogController.php @@ -222,6 +222,36 @@ class DialogController extends AbstractController return Base::retSuccess('success', $data); } + /** + * @api {get} api/dialog/msg/one 05. 获取单个消息 + * + * @apiDescription 主要用于获取回复消息的详情,需要token身份 + * @apiVersion 1.0.0 + * @apiGroup dialog + * @apiName msg__one + * + * @apiParam {Number} msg_id 消息ID + * + * @apiSuccess {Number} ret 返回状态码(1正确、0错误) + * @apiSuccess {String} msg 返回信息(错误描述) + * @apiSuccess {Object} data 返回数据 + */ + public function msg__one() + { + User::auth(); + // + $msg_id = intval(Request::input('msg_id')); + // + $dialogMsg = WebSocketDialogMsg::find($msg_id); + if (empty($dialogMsg)) { + return Base::retError('消息不存在或已被删除'); + } + // + WebSocketDialog::checkDialog($dialogMsg->dialog_id); + // + return Base::retSuccess('success', $dialogMsg); + } + /** * @api {get} api/dialog/msg/unread 06. 获取未读消息数量 * diff --git a/resources/assets/js/pages/manage/components/ChatInput/index.vue b/resources/assets/js/pages/manage/components/ChatInput/index.vue index f137811c5..991005620 100755 --- a/resources/assets/js/pages/manage/components/ChatInput/index.vue +++ b/resources/assets/js/pages/manage/components/ChatInput/index.vue @@ -2,9 +2,9 @@
-
- -
{{formatMsgDesc(replyItem)}}
+
+ +
{{formatMsgDesc(replyData)}}
@@ -186,9 +186,9 @@ export default { type: String, default: "top" }, - replyItem: { - type: Object, - default: () => ({}) + replyId: { + type: Number, + default: 0 }, }, data() { @@ -277,7 +277,7 @@ export default { } }, computed: { - ...mapState(['dialogInputCache', 'cacheProjects', 'cacheTasks', 'cacheUserBasic']), + ...mapState(['dialogInputCache', 'cacheProjects', 'cacheTasks', 'cacheUserBasic', 'dialogMsgs', 'dialogReplys']), isEnterSend() { if (typeof this.enterSend === "boolean") { @@ -346,6 +346,22 @@ export default { if (minute < 10) minute = `0${minute}` if (seconds < 10) seconds = `0${seconds}` return `${minute}:${seconds}″${millisecond}` + }, + + replyData() { + const {replyId} = this; + if (replyId > 0) { + let data = this.dialogMsgs.find(item => item.id === replyId) + if (data) { + return data; + } + data = this.dialogReplys.find(item => item.id === replyId) + if (data) { + return data; + } + this.$store.dispatch("getDialogReply", replyId) + } + return null; } }, watch: { diff --git a/resources/assets/js/pages/manage/components/DialogUpload.vue b/resources/assets/js/pages/manage/components/DialogUpload.vue index 03035868e..d07711f72 100644 --- a/resources/assets/js/pages/manage/components/DialogUpload.vue +++ b/resources/assets/js/pages/manage/components/DialogUpload.vue @@ -25,7 +25,7 @@ export default { default: 0 }, replyId: { - type: [Number, String], + type: Number, default: 0 }, maxSize: { diff --git a/resources/assets/js/pages/manage/components/DialogView.vue b/resources/assets/js/pages/manage/components/DialogView.vue index e2d7e3027..e777b0a1e 100644 --- a/resources/assets/js/pages/manage/components/DialogView.vue +++ b/resources/assets/js/pages/manage/components/DialogView.vue @@ -172,7 +172,7 @@ export default { }, computed: { - ...mapState(['dialogMsgs', 'audioPlaying', 'windowActive']), + ...mapState(['dialogMsgs', 'dialogReplys', 'audioPlaying', 'windowActive']), viewClass() { const {msgData, replyData, operateAction, operateEnter} = this; @@ -234,7 +234,15 @@ export default { replyData() { const {reply_id} = this.msgData; if (reply_id > 0) { - return this.dialogMsgs.find(item => item.id === reply_id) || null; + let data = this.dialogMsgs.find(item => item.id === reply_id) + if (data) { + return data; + } + data = this.dialogReplys.find(item => item.id === reply_id) + if (data) { + return data; + } + this.$store.dispatch("getDialogReply", reply_id) } return null; } diff --git a/resources/assets/js/pages/manage/components/DialogWrapper.vue b/resources/assets/js/pages/manage/components/DialogWrapper.vue index fb8452040..c185f53ea 100644 --- a/resources/assets/js/pages/manage/components/DialogWrapper.vue +++ b/resources/assets/js/pages/manage/components/DialogWrapper.vue @@ -100,7 +100,7 @@ ref="chatUpload" class="chat-upload" :dialog-id="dialogId" - :reply-id="replyItem.id" + :reply-id="replyId" @on-progress="chatFile('progress', $event)" @on-success="chatFile('success', $event)" @on-error="chatFile('error', $event)"/> @@ -108,7 +108,7 @@ ref="input" v-model="msgText" :dialog-id="dialogId" - :reply-item="replyItem" + :reply-id="replyId" :emoji-bottom="windowSmall" :maxlength="200000" @on-focus="onEventFocus" @@ -325,7 +325,7 @@ export default { recordState: '', wrapperStart: 0, - replyItem: {}, + replyId: 0, } }, @@ -539,7 +539,7 @@ export default { let tempMsg = { id: tempId, dialog_id: this.dialogData.id, - reply_id: this.replyItem.id, + reply_id: this.replyId, type: 'text', userid: this.userId, msg: { @@ -556,7 +556,7 @@ export default { url: 'dialog/msg/sendtext', data: { dialog_id: this.dialogId, - reply_id: this.replyItem.id, + reply_id: this.replyId, text: msgText, }, method: 'post' @@ -581,7 +581,7 @@ export default { this.tempMsgs.push({ id: tempId, dialog_id: this.dialogData.id, - reply_id: this.replyItem.id, + reply_id: this.replyId, type: 'loading', userid: this.userId, msg, @@ -591,7 +591,7 @@ export default { url: 'dialog/msg/sendrecord', data: Object.assign(msg, { dialog_id: this.dialogId, - reply_id: this.replyItem.id, + reply_id: this.replyId, }), method: 'post' }).then(({data}) => { @@ -707,7 +707,7 @@ export default { this.tempMsgs.push({ id: file.tempId, dialog_id: this.dialogData.id, - reply_id: this.replyItem.id, + reply_id: this.replyId, type: 'loading', userid: this.userId, msg: { }, @@ -983,12 +983,12 @@ export default { }, onReply() { - this.replyItem = this.operateItem; + this.replyId = this.operateItem.id; this.inputFocus() }, onCancelReply() { - this.replyItem = {}; + this.replyId = 0; }, onWithdraw() { diff --git a/resources/assets/js/store/actions.js b/resources/assets/js/store/actions.js index 95a2b094d..99f211467 100644 --- a/resources/assets/js/store/actions.js +++ b/resources/assets/js/store/actions.js @@ -403,7 +403,7 @@ export default { saveUserBasic({state}, data) { $A.execMainDispatch("saveUserBasic", data) // - let index = state.cacheUserBasic.findIndex(({userid}) => userid == data.userid); + const index = state.cacheUserBasic.findIndex(({userid}) => userid == data.userid); if (index > -1) { data = Object.assign({}, state.cacheUserBasic[index], data) state.cacheUserBasic.splice(index, 1, data); @@ -544,7 +544,7 @@ export default { }); } else if ($A.isJson(data)) { let base = {_load: false, _edit: false}; - let index = state.files.findIndex(({id}) => id == data.id); + const index = state.files.findIndex(({id}) => id == data.id); if (index > -1) { state.files.splice(index, 1, Object.assign(base, state.files[index], data)); } else { @@ -646,7 +646,7 @@ export default { dispatch("saveColumn", data.project_column) delete data.project_column; } - let index = state.cacheProjects.findIndex(({id}) => id == data.id); + const index = state.cacheProjects.findIndex(({id}) => id == data.id); if (index > -1) { state.cacheProjects.splice(index, 1, Object.assign({}, state.cacheProjects[index], data)); } else { @@ -684,7 +684,7 @@ export default { // let ids = $A.isArray(project_id) ? project_id : [project_id]; ids.some(id => { - let index = state.cacheProjects.findIndex(project => project.id == id); + const index = state.cacheProjects.findIndex(project => project.id == id); if (index > -1) { state.cacheProjects.splice(index, 1); } @@ -874,7 +874,7 @@ export default { dispatch("saveColumn", column) }); } else if ($A.isJson(data)) { - let index = state.cacheColumns.findIndex(({id}) => id == data.id); + const index = state.cacheColumns.findIndex(({id}) => id == data.id); if (index > -1) { state.cacheColumns.splice(index, 1, Object.assign({}, state.cacheColumns[index], data)); } else { @@ -898,7 +898,7 @@ export default { let ids = $A.isArray(column_id) ? column_id : [column_id]; let project_ids = []; ids.some(id => { - let index = state.cacheColumns.findIndex(column => column.id == id); + const index = state.cacheColumns.findIndex(column => column.id == id); if (index > -1) { project_ids.push(state.cacheColumns[index].project_id) dispatch('getProjectOne', state.cacheColumns[index].project_id).catch(() => {}) @@ -1026,7 +1026,7 @@ export default { delete data.update_marking; } // - let index = state.cacheTasks.findIndex(({id}) => id == data.id); + const index = state.cacheTasks.findIndex(({id}) => id == data.id); if (index > -1) { state.cacheTasks.splice(index, 1, Object.assign({}, state.cacheTasks[index], data)); } else { @@ -1077,7 +1077,7 @@ export default { let parent_ids = []; let project_ids = []; ids.some(id => { - let index = state.cacheTasks.findIndex(task => task.id == id); + const index = state.cacheTasks.findIndex(task => task.id == id); if (index > -1) { if (state.cacheTasks[index].parent_id) { parent_ids.push(state.cacheTasks[index].parent_id) @@ -1448,7 +1448,7 @@ export default { dispatch("saveTaskContent", item) }); } else if ($A.isJson(data)) { - let index = state.taskContents.findIndex(({task_id}) => task_id == data.task_id); + const index = state.taskContents.findIndex(({task_id}) => task_id == data.task_id); if (index > -1) { state.taskContents.splice(index, 1, Object.assign({}, state.taskContents[index], data)); } else { @@ -1474,7 +1474,7 @@ export default { }, }).then(result => { result.data.forEach((data) => { - let index = state.taskFiles.findIndex(({id}) => id == data.id) + const index = state.taskFiles.findIndex(({id}) => id == data.id) if (index > -1) { state.taskFiles.splice(index, 1, data) } else { @@ -1499,7 +1499,7 @@ export default { forgetTaskFile({state, dispatch}, file_id) { let ids = $A.isArray(file_id) ? file_id : [file_id]; ids.some(id => { - let index = state.taskFiles.findIndex(file => file.id == id) + const index = state.taskFiles.findIndex(file => file.id == id) if (index > -1) { state.taskFiles.splice(index, 1) } @@ -1789,7 +1789,7 @@ export default { let task = state.cacheTasks.find(({id}) => id == task_id) let {data} = result data.turns.some(item => { - let index = state.taskFlowItems.findIndex(({id}) => id == item.id); + const index = state.taskFlowItems.findIndex(({id}) => id == item.id); if (index > -1) { state.taskFlowItems.splice(index, 1, item); } else { @@ -1808,7 +1808,7 @@ export default { }) // delete data.turns; - let index = state.taskFlows.findIndex(({task_id}) => task_id == data.task_id); + const index = state.taskFlows.findIndex(({task_id}) => task_id == data.task_id); if (index > -1) { state.taskFlows.splice(index, 1, data); } else { @@ -1892,7 +1892,7 @@ export default { * @param task_id */ saveTaskBrowse({state}, task_id) { - let index = state.cacheTaskBrowse.findIndex(({id}) => id == task_id) + const index = state.cacheTaskBrowse.findIndex(({id}) => id == task_id) if (index > -1) { state.cacheTaskBrowse.splice(index, 1) } @@ -2088,7 +2088,7 @@ export default { // let ids = $A.isArray(dialog_id) ? dialog_id : [dialog_id]; ids.some(id => { - let index = state.cacheDialogs.findIndex(dialog => dialog.id == id); + const index = state.cacheDialogs.findIndex(dialog => dialog.id == id); if (index > -1) { state.cacheDialogs.splice(index, 1); } @@ -2152,7 +2152,7 @@ export default { dispatch("saveDialogMsg", msg) }); } else if ($A.isJson(data)) { - let index = state.dialogMsgs.findIndex(({id}) => id == data.id); + const index = state.dialogMsgs.findIndex(({id}) => id == data.id); if (index > -1) { state.dialogMsgs.splice(index, 1, Object.assign({}, state.dialogMsgs[index], data)); } else { @@ -2171,7 +2171,7 @@ export default { // let ids = $A.isArray(msg_id) ? msg_id : [msg_id]; ids.some(id => { - let index = state.dialogMsgs.findIndex(item => item.id == id); + const index = state.dialogMsgs.findIndex(item => item.id == id); if (index > -1) { Store.set('audioSubscribe', id); state.dialogMsgs.splice(index, 1); @@ -2179,6 +2179,25 @@ export default { }) }, + /** + * 获取回复消息 + * @param state + * @param dispatch + * @param msg_id + */ + getDialogReply({state, dispatch}, msg_id) { + dispatch("call", { + url: 'dialog/msg/one', + data: { + msg_id: msg_id, + }, + }).then(({data}) => { + state.dialogReplys.push(data) + }).catch(e => { + console.warn(e); + }); + }, + /** * 获取会话消息 * @param state diff --git a/resources/assets/js/store/state.js b/resources/assets/js/store/state.js index 4f37306ca..65e4a44a7 100644 --- a/resources/assets/js/store/state.js +++ b/resources/assets/js/store/state.js @@ -71,6 +71,7 @@ const stateData = { dialogId: 0, dialogIns: [], dialogMsgs: [], + dialogReplys: [], dialogInputCache: $A.getStorageArray("cacheDialogInput"), dialogMsgTransfer: {time: 0},