159 lines
4.3 KiB
TypeScript
159 lines
4.3 KiB
TypeScript
import { computed, ref } from 'vue';
|
|
import { FormSchema } from '@/components/Form';
|
|
import { defRangeShortcuts } from '@/utils/dateUtil';
|
|
import { useDictStore } from '@/store/modules/dict';
|
|
import { imQueryTenantOptions } from '@/views/imAdminQueryShared';
|
|
|
|
const dict = useDictStore();
|
|
|
|
export function createMessageSchemas(group: boolean) {
|
|
const items: FormSchema[] = [
|
|
{
|
|
field: 'tenantId',
|
|
component: 'NSelect',
|
|
label: '租户',
|
|
componentProps: {
|
|
clearable: false,
|
|
options: computed(() => imQueryTenantOptions.value),
|
|
placeholder: '请选择租户',
|
|
},
|
|
},
|
|
{
|
|
field: 'topic',
|
|
component: 'NInput',
|
|
label: group ? '群号/Topic' : '会话Topic',
|
|
componentProps: { placeholder: group ? '请输入群号或Topic' : '请输入Topic' },
|
|
},
|
|
{
|
|
field: group ? 'senderUserId' : 'fromUserId',
|
|
component: 'NInput',
|
|
label: '发送用户',
|
|
componentProps: { placeholder: '请输入用户ID' },
|
|
},
|
|
];
|
|
if (group)
|
|
items.push(
|
|
{
|
|
field: 'seqId',
|
|
component: 'NInputNumber',
|
|
label: '消息序号',
|
|
componentProps: { min: 1, showButton: false, placeholder: '请输入消息序号' },
|
|
},
|
|
{
|
|
field: 'senderUsername',
|
|
component: 'NInput',
|
|
label: '发送人用户名',
|
|
componentProps: { placeholder: '请输入发送人用户名' },
|
|
},
|
|
{
|
|
field: 'senderNickname',
|
|
component: 'NInput',
|
|
label: '发送人昵称',
|
|
componentProps: { placeholder: '请输入发送人昵称' },
|
|
},
|
|
{
|
|
field: 'groupName',
|
|
component: 'NInput',
|
|
label: '群名称',
|
|
componentProps: { placeholder: '请输入群名称' },
|
|
}
|
|
);
|
|
if (!group)
|
|
items.push({
|
|
field: 'toUserId',
|
|
component: 'NInput',
|
|
label: '接收用户',
|
|
componentProps: { placeholder: '请输入用户ID' },
|
|
});
|
|
items.push(
|
|
{
|
|
field: 'contentType',
|
|
component: 'NSelect',
|
|
label: '消息类型',
|
|
componentProps: {
|
|
clearable: true,
|
|
options: dict.getOption('ImMessageContentTypeOptions'),
|
|
placeholder: '全部类型',
|
|
},
|
|
},
|
|
{
|
|
field: 'status',
|
|
component: 'NSelect',
|
|
label: '消息状态',
|
|
componentProps: {
|
|
clearable: true,
|
|
options: dict.getOption('ImMessageStatusOptions'),
|
|
placeholder: '全部状态',
|
|
},
|
|
},
|
|
{
|
|
field: 'keyword',
|
|
component: 'NInput',
|
|
label: '关键词',
|
|
componentProps: { placeholder: '请输入内容关键词' },
|
|
},
|
|
{
|
|
field: 'createdAt',
|
|
component: 'NDatePicker',
|
|
label: '发送时间',
|
|
componentProps: { type: 'datetimerange', clearable: true, shortcuts: defRangeShortcuts() },
|
|
}
|
|
);
|
|
return ref(items);
|
|
}
|
|
|
|
export function createMessageColumns(group: boolean) {
|
|
const columns: any[] = [
|
|
{ title: '消息序号', key: 'seqId', width: 110 },
|
|
{
|
|
title: '发送人',
|
|
key: 'fromUserId',
|
|
width: 190,
|
|
render: (row) =>
|
|
row.senderNickname
|
|
? `${row.senderNickname} / ${row.senderUsername || row.fromUserId}`
|
|
: row.senderUsername || row.fromUserId,
|
|
},
|
|
];
|
|
if (group)
|
|
columns.push({
|
|
title: '群名称',
|
|
key: 'groupName',
|
|
width: 190,
|
|
render: (row) =>
|
|
row.groupName ? `${row.groupName} / ${row.groupNo || row.topic}` : row.topic,
|
|
});
|
|
else
|
|
columns.push({
|
|
title: '接收人',
|
|
key: 'toUserId',
|
|
width: 190,
|
|
render: (row) =>
|
|
row.receiverNickname
|
|
? `${row.receiverNickname} / ${row.receiverUsername || row.toUserId}`
|
|
: row.receiverUsername || row.toUserId,
|
|
});
|
|
columns.push(
|
|
{
|
|
title: '类型',
|
|
key: 'contentType',
|
|
width: 100,
|
|
render: (row) =>
|
|
dict.getLabel('ImMessageContentTypeOptions', row.contentType) || row.contentType,
|
|
},
|
|
{ title: '内容', key: 'contentExcerpt', width: 300, ellipsis: { tooltip: true } },
|
|
{
|
|
title: '状态',
|
|
key: 'status',
|
|
width: 110,
|
|
render: (row) => dict.getLabel('ImMessageStatusOptions', row.status) || row.status,
|
|
},
|
|
{ title: '发送时间', key: 'createdAt', width: 180 }
|
|
);
|
|
return columns;
|
|
}
|
|
|
|
export function loadMessageOptions() {
|
|
dict.loadOptions(['ImMessageContentTypeOptions', 'ImMessageStatusOptions']);
|
|
}
|