gaoluyang
2026-06-24 bfdc0e0e6d5e47aa501f9b6fadd143d9c97cf00a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { ImManagerGroupMessageApi } from '#/api/im/manager/message/group';
 
import { ref } from 'vue';
import { useRoute } from 'vue-router';
 
import { Page } from '../../../../../packages/effects/common-ui/src';
 
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { getManagerGroupMessagePage } from '#/api/im/manager/message/group';
import {
  formatGroupLabel,
  formatUserLabel,
} from '#/views/im/manager/utils/format';
import { MESSAGE_GROUP_READ_ENABLED } from '#/views/im/utils/config';
import {
  IM_AT_ALL_NICKNAME,
  IM_AT_ALL_USER_ID,
} from '#/views/im/utils/constants';
 
import { MessageContentPreview } from '..';
import { useGroupGridColumns, useGroupGridFormSchema } from '../data';
import Detail from './modules/detail.vue';
 
defineOptions({ name: 'ImGroupMessage' });
 
const route = useRoute();
const detailRef = ref<InstanceType<typeof Detail>>();
 
/** 打开详情 */
function handleDetail(row: ImManagerGroupMessageApi.GroupMessage) {
  detailRef.value?.open(row);
}
 
const [Grid] = useVbenVxeGrid({
  formOptions: {
    schema: useGroupGridFormSchema(),
  },
  gridOptions: {
    columns: useGroupGridColumns(MESSAGE_GROUP_READ_ENABLED),
    height: 'auto',
    keepSource: true,
    proxyConfig: {
      ajax: {
        query: async ({ page }, formValues) => {
          return await getManagerGroupMessagePage({
            pageNo: page.currentPage,
            pageSize: page.pageSize,
            groupId: route.query.groupId ? Number(route.query.groupId) : undefined,
            ...formValues,
          });
        },
      },
    },
    rowConfig: {
      keyField: 'id',
      isHover: true,
    },
    toolbarConfig: {
      refresh: true,
      search: true,
    },
  } as VxeTableGridOptions<ImManagerGroupMessageApi.GroupMessage>,
});
</script>
 
<template>
  <Page auto-content-height>
    <Detail ref="detailRef" />
    <Grid table-title="群聊消息列表">
      <template #group="{ row }">
        {{ formatGroupLabel(row.groupName, row.groupId) }}
      </template>
      <template #sender="{ row }">
        {{ formatUserLabel(row.senderNickname, row.senderId) }}
      </template>
      <template #atUsers="{ row }">
        <template v-if="row.atUserIds?.length">
          <span v-for="(userId, index) in row.atUserIds" :key="userId">
            <span v-if="Number(index) > 0">、</span>
            <template v-if="userId === IM_AT_ALL_USER_ID">@{{ IM_AT_ALL_NICKNAME }}</template>
            <template v-else>@{{ row.atUserNicknames?.[index] || userId }}</template>
          </span>
        </template>
        <span v-else>-</span>
      </template>
      <template #content="{ row }">
        <MessageContentPreview
          :content="row.content"
          :sender-nickname="row.senderNickname"
          :type="row.type"
        />
      </template>
      <template #actions="{ row }">
        <TableAction
          :actions="[
            {
              label: '详情',
              type: 'link',
              icon: ACTION_ICON.VIEW,
              auth: ['im:manager:message:query'],
              onClick: handleDetail.bind(null, row),
            },
          ]"
        />
      </template>
    </Grid>
  </Page>
</template>