From 22814cb1a779b1a230c8805448e09e1657aa9f61 Mon Sep 17 00:00:00 2001 From: geht <2947093423@qq.com> Date: Fri, 29 May 2026 10:28:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=BC=BAIM=E8=81=8A=E5=A4=A9=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=8C=E6=94=AF=E6=8C=81=E7=BE=A4=E8=81=8A=E4=BC=9A?= =?UTF-8?q?=E8=AF=9D=E7=9A=84=E6=89=93=E5=BC=80=E4=B8=8E=E5=A4=84=E7=90=86?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E6=B6=88=E6=81=AF=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E6=8F=90=E5=8D=87=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BD=93=E9=AA=8C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../message/components/SysMessageList.vue | 15 +++- .../message/components/imChatNoticeAdapter.ts | 71 +++++++++++++++++-- 2 files changed, 76 insertions(+), 10 deletions(-) diff --git a/jeecgboot-vue3/src/views/system/message/components/SysMessageList.vue b/jeecgboot-vue3/src/views/system/message/components/SysMessageList.vue index b8d3bc0..445af0b 100644 --- a/jeecgboot-vue3/src/views/system/message/components/SysMessageList.vue +++ b/jeecgboot-vue3/src/views/system/message/components/SysMessageList.vue @@ -223,10 +223,19 @@ async function showMessageDetail(record){ if (isImChatNotice(record)) { //update-begin---author:xsl ---date:20260528 for:【IM聊天-OA】统一 IM 打开入口,全页优先----------- - const mode = await openImChat({ targetUserId: record.imTargetUserId, pageContext: null }); - if (mode === 'modal') { - openImChatModal(true, { targetUserId: record.imTargetUserId, pageContext: null }); + //update-begin---author:cursor ---date:20260529 for:【IM聊天-OA】全部消息支持打开群聊会话----------- + if (record.imConvType === 'group') { + const mode = await openImChat({ conversationId: record.imConversationId }); + if (mode === 'modal') { + openImChatModal(true, { conversationId: record.imConversationId }); + } + } else { + const mode = await openImChat({ targetUserId: record.imTargetUserId, pageContext: null }); + if (mode === 'modal') { + openImChatModal(true, { targetUserId: record.imTargetUserId, pageContext: null }); + } } + //update-end---author:cursor ---date:20260529 for:【IM聊天-OA】全部消息支持打开群聊会话----------- //update-end---author:xsl ---date:20260528 for:【IM聊天-OA】统一 IM 打开入口,全页优先----------- emit('close-modal'); return; diff --git a/jeecgboot-vue3/src/views/system/message/components/imChatNoticeAdapter.ts b/jeecgboot-vue3/src/views/system/message/components/imChatNoticeAdapter.ts index aef704c..084cb72 100644 --- a/jeecgboot-vue3/src/views/system/message/components/imChatNoticeAdapter.ts +++ b/jeecgboot-vue3/src/views/system/message/components/imChatNoticeAdapter.ts @@ -1,5 +1,7 @@ import dayjs, { Dayjs } from 'dayjs'; -import { fetchDeptMembers } from '/@/views/system/im/im.api'; +//update-begin---author:cursor ---date:20260529 for:【IM聊天-OA】全部消息补充群聊提醒----------- +import { fetchDeptMembers, fetchGroups } from '/@/views/system/im/im.api'; +//update-end---author:cursor ---date:20260529 for:【IM聊天-OA】全部消息补充群聊提醒----------- import { formatImMessagePreview } from '/@/views/system/im/imMessageUtil'; export const IM_CHAT_BUS_TYPE = 'im_chat'; @@ -27,6 +29,12 @@ export interface ImChatNoticeRecord { imTargetUsername?: string; imAvatar?: string; imUnreadCount?: number; + //update-begin---author:cursor ---date:20260529 for:【IM聊天-OA】全部消息补充群聊提醒----------- + /** 会话类型:single 单聊 / group 群聊 */ + imConvType?: 'single' | 'group'; + /** 群聊会话 ID(群聊提醒打开会话时使用) */ + imConversationId?: string; + //update-end---author:cursor ---date:20260529 for:【IM聊天-OA】全部消息补充群聊提醒----------- } interface ImContactLike { @@ -40,6 +48,16 @@ interface ImContactLike { unreadCount?: number; } +//update-begin---author:cursor ---date:20260529 for:【IM聊天-OA】全部消息补充群聊提醒----------- +interface ImGroupLike { + conversationId: string; + groupName?: string; + lastContent?: string; + lastTime?: string; + unreadCount?: number; +} +//update-end---author:cursor ---date:20260529 for:【IM聊天-OA】全部消息补充群聊提醒----------- + /** 标星列表不包含 IM;全部消息或未指定类型、聊天类型时合并 IM */ export function shouldIncludeImChatInList(params: ImChatSearchParams) { if (params.starFlag === '1') { @@ -142,14 +160,49 @@ export function mapImContactToNotice(contact: ImContactLike): ImChatNoticeRecord imTargetUsername: contact.username, imAvatar: contact.avatar, imUnreadCount: contact.unreadCount || 0, + //update-begin---author:cursor ---date:20260529 for:【IM聊天-OA】全部消息补充群聊提醒----------- + imConvType: 'single', + //update-end---author:cursor ---date:20260529 for:【IM聊天-OA】全部消息补充群聊提醒----------- }; } -export function filterImChatNotices(contacts: ImContactLike[], params: ImChatSearchParams) { - let list = (contacts || []) +//update-begin---author:cursor ---date:20260529 for:【IM聊天-OA】全部消息补充群聊提醒----------- +/** 将群聊会话映射为聊天提醒记录 */ +export function mapImGroupToNotice(group: ImGroupLike): ImChatNoticeRecord | null { + if (!group?.conversationId || !group?.lastTime) { + return null; + } + const name = group.groupName || '群聊'; + const preview = formatImMessagePreview(group.lastContent) || '发来一条新消息'; + const timeText = dayjs(group.lastTime).isValid() ? dayjs(group.lastTime).format('YYYY-MM-DD HH:mm:ss') : String(group.lastTime); + return { + id: `im_chat_group_${group.conversationId}`, + busType: IM_CHAT_BUS_TYPE, + titile: `${name}:${preview}`, + msgContent: preview, + sendTime: timeText, + createTime: timeText, + readFlag: (group.unreadCount || 0) > 0 ? '0' : '1', + noticeType: IM_CHAT_NOTICE_TYPE, + starFlag: '0', + imTargetUserId: '', + imUnreadCount: group.unreadCount || 0, + imConvType: 'group', + imConversationId: group.conversationId, + }; +} + +export function filterImChatNotices(contacts: ImContactLike[], groups: ImGroupLike[], params: ImChatSearchParams) { + const singleList = (contacts || []) .map(mapImContactToNotice) - .filter((item): item is ImChatNoticeRecord => !!item) - .filter((item) => isInRange(item.sendTime, params.rangeDateKey, params.rangeDate)); + .filter((item): item is ImChatNoticeRecord => !!item); + + // 指定发件人筛选时,仅匹配单聊(群聊不属于单个发件人) + const groupList = params.fromUser + ? [] + : (groups || []).map(mapImGroupToNotice).filter((item): item is ImChatNoticeRecord => !!item); + + let list = [...singleList, ...groupList].filter((item) => isInRange(item.sendTime, params.rangeDateKey, params.rangeDate)); if (params.fromUser) { list = list.filter((item) => item.imTargetUsername === params.fromUser || item.imTargetUserId === params.fromUser); @@ -159,9 +212,13 @@ export function filterImChatNotices(contacts: ImContactLike[], params: ImChatSea } export async function fetchImChatNoticeList(params: ImChatSearchParams) { - const contacts = ((await fetchDeptMembers()) || []) as ImContactLike[]; - return filterImChatNotices(contacts, params); + const [contacts, groups] = (await Promise.all([ + Promise.resolve(fetchDeptMembers()).catch(() => []), + Promise.resolve(fetchGroups()).catch(() => []), + ])) as [ImContactLike[], ImGroupLike[]]; + return filterImChatNotices(contacts || [], groups || [], params); } +//update-end---author:cursor ---date:20260529 for:【IM聊天-OA】全部消息补充群聊提醒----------- export function mergeMessageList(systemList: any[] = [], imList: ImChatNoticeRecord[] = []) { if (!imList.length) {