fix:转移会话不更新问题

feat-im-0607-ch
ch 2 years ago
parent 97639e7964
commit c755ff3eb0

@ -2,7 +2,7 @@
* @Author: ch * @Author: ch
* @Date: 2022-06-07 15:41:05 * @Date: 2022-06-07 15:41:05
* @LastEditors: ch * @LastEditors: ch
* @LastEditTime: 2022-06-13 16:30:57 * @LastEditTime: 2022-06-13 17:16:27
* @Description: file content * @Description: file content
*/ */
import * as api from '@/api/chat'; import * as api from '@/api/chat';
@ -65,7 +65,7 @@ const getters = {
payload = '[解析异常]'; payload = '[解析异常]';
} }
} else if (type === 7) { } else if (type === 7) {
payload = '[撤回消息]'; payload = payload.text;
} else { } else {
payload = '[未知类型]'; payload = '[未知类型]';
} }
@ -155,12 +155,14 @@ const actions = {
* 提交转移会话 * 提交转移会话
*/ */
submitTransferSession: ({}, data) => { submitTransferSession: ({}, data) => {
api.transferCustomerService({ return api
storeId: 1, .transferCustomerService({
...data, storeId: 1,
}).then((res) => { ...data,
console.log(res, 'resresres'); })
}); .then((res) => {
console.log(res, 'resresres');
});
}, },
}; };
export default { export default {

@ -2,7 +2,7 @@
* @Author: ch * @Author: ch
* @Date: 2022-06-07 15:52:37 * @Date: 2022-06-07 15:52:37
* @LastEditors: ch * @LastEditors: ch
* @LastEditTime: 2022-06-13 16:18:45 * @LastEditTime: 2022-06-13 17:32:19
* @Description: file content * @Description: file content
*/ */
import * as api from '@/api/chat'; import * as api from '@/api/chat';

@ -2,7 +2,7 @@
* @Author: ch * @Author: ch
* @Date: 2022-05-18 14:54:47 * @Date: 2022-05-18 14:54:47
* @LastEditors: ch * @LastEditors: ch
* @LastEditTime: 2022-06-13 15:16:50 * @LastEditTime: 2022-06-13 18:54:30
* @Description: file content * @Description: file content
*/ */
import '@/utils/poto-req'; import '@/utils/poto-req';
@ -193,9 +193,9 @@ class MsbIm {
newData = [ newData = [
...historyData, ...historyData,
{ {
fromAvatar: ctx.fromAvatar, fromAvatar: ctx.session.fromAvatar,
fromId: ctx.fromId, fromId: ctx.fromId,
fromNickname: ctx.fromNickname, fromNickname: ctx.session.fromNickname,
id: ctx.sessionId, id: ctx.sessionId,
lastMessage: ctx, lastMessage: ctx,
messageList: [ctx], messageList: [ctx],
@ -270,6 +270,7 @@ class MsbIm {
return Promise.reject(error); return Promise.reject(error);
} }
const { content } = result; const { content } = result;
let newData = [];
content.sessionVOS.forEach((item) => { content.sessionVOS.forEach((item) => {
if (item.lastMessage) { if (item.lastMessage) {
@ -280,13 +281,14 @@ class MsbIm {
if (hisIndex >= 0) { if (hisIndex >= 0) {
historyData[hisIndex].lastMessage = item.lastMessage; historyData[hisIndex].lastMessage = item.lastMessage;
historyData[hisIndex].unreadCount++; historyData[hisIndex].unreadCount++;
this.setSessionData(historyData); newData.push(historyData);
} else { } else {
item.messageList = []; item.messageList = [];
const newData = [...historyData, item]; newData = [...newData, item];
this.setSessionData(newData);
} }
}); });
this.setSessionData(newData);
return Promise.resolve(result); return Promise.resolve(result);
} }
/** /**

@ -49,7 +49,7 @@
</li> </li>
</el-scrollbar> </el-scrollbar>
</div> </div>
<div v-if="currentSession" class="content"> <div v-if="currentSession.id" class="content">
<div class="content-header"> <div class="content-header">
<div class="content-header-left"> <div class="content-header-left">
<div class="name" :class="{ [`sex-` + currentSession?.fromSex]: true }"> <div class="name" :class="{ [`sex-` + currentSession?.fromSex]: true }">
@ -178,7 +178,7 @@
message: '', message: '',
}); });
const sessionList = computed(() => store.state.chat.sessionData); const sessionList = computed(() => store.state.chat.sessionData);
const currentSession = computed(() => sessionList.value.find((item) => item.id === currentSessionId.value)); const currentSession = computed(() => sessionList.value.find((item) => item.id === currentSessionId.value) || {});
const handleChangeSession = (id) => { const handleChangeSession = (id) => {
currentSessionId.value = id; currentSessionId.value = id;
// ID // ID
@ -209,7 +209,7 @@
: 0; : 0;
nextTick(() => { nextTick(() => {
// if (!old?.length || value.indexOf(old[0]) === 0) { // if (!old?.length || value.indexOf(old[0]) === 0) {
refsMessageList.value.setScrollTop(refsMessageList.value.resize$.scrollHeight); refsMessageList.value && refsMessageList.value.setScrollTop(refsMessageList.value.resize$.scrollHeight);
// } else { // } else {
// refsMessageList.value.setScrollTop(refsMessageList.value.resize$.scrollHeight - offset); // refsMessageList.value.setScrollTop(refsMessageList.value.resize$.scrollHeight - offset);
// } // }
@ -293,11 +293,16 @@
confirmButtonText: '确定', confirmButtonText: '确定',
}); });
if (res.action === 'confirm') { if (res.action === 'confirm') {
store.dispatch('chat/submitTransferSession', { store
toWaiterId: row.waiterId, .dispatch('chat/submitTransferSession', {
sessionId: unref(currentSessionId), toWaiterId: row.waiterId,
reason: res.value, sessionId: unref(currentSessionId),
}); reason: res.value,
})
.then((res) => {
Im.setCurSessionId(null);
Im.getSessionList();
});
transferVisible.value = false; transferVisible.value = false;
} }
} catch (e) { } catch (e) {

Loading…
Cancel
Save