feat: add IM governance admin enhancements

This commit is contained in:
richjohnrambo
2026-08-21 16:06:29 +08:00
parent 543c7b624e
commit 21a5b97ac8
34 changed files with 2621 additions and 135 deletions
+148
View File
@@ -0,0 +1,148 @@
import { computed, ref } from 'vue';
import { cloneDeep } from 'lodash-es';
import { FormSchema } from '@/components/Form';
import { defRangeShortcuts } from '@/utils/dateUtil';
import { useDictStore } from '@/store/modules/dict';
import { List as TenantList } from '@/api/imTenant';
const dict = useDictStore();
export const tenantOptions = ref<any[]>([]);
export class State {
public tenantId = 0;
public tenantName = '';
public source = 'business';
public id = 0;
public eventId = '';
public targetType = '';
public target = '';
public actorUserId = 0;
public eventType = '';
public payload = '';
public status = '';
public attempts = 0;
public nextRetryAt = '';
public deliveredAt = '';
public createdAt = '';
public updatedAt = '';
constructor(state?: Partial<State>) {
if (state) Object.assign(this, state);
}
}
export function newState(state: State | Record<string, any> | null): State {
if (state !== null) {
if (state instanceof State) return cloneDeep(state);
return new State(state);
}
return new State();
}
export const schemas = ref<FormSchema[]>([
{
field: 'tenantId',
component: 'NSelect',
label: '租户',
componentProps: {
clearable: false,
options: computed(() => tenantOptions.value),
placeholder: '请选择租户',
},
},
{
field: 'source',
component: 'NSelect',
label: '来源',
defaultValue: 'business',
componentProps: {
clearable: false,
options: computed(() => dict.getOptions('ImOutboxSourceOptions')),
placeholder: '请选择来源',
},
},
{
field: 'status',
component: 'NSelect',
label: '状态',
componentProps: {
clearable: true,
options: computed(() => dict.getOptions('ImOutboxStatusOptions')),
placeholder: '请选择状态',
},
},
{
field: 'eventType',
component: 'NInput',
label: '事件类型',
componentProps: { placeholder: '请输入事件类型' },
},
{
field: 'eventId',
component: 'NInput',
label: '事件ID',
componentProps: { placeholder: '请输入事件ID' },
},
{
field: 'target',
component: 'NInput',
label: '目标',
componentProps: { placeholder: '请输入目标/Topic' },
},
{
field: 'createdAt',
component: 'NDatePicker',
label: '创建时间',
componentProps: {
type: 'datetimerange',
clearable: true,
shortcuts: defRangeShortcuts(),
},
},
]);
export const columns = [
{ title: 'ID', key: 'id', align: 'left', width: 90 },
{
title: '来源',
key: 'source',
align: 'left',
width: 110,
render(row: State) {
return dict.getLabel('ImOutboxSourceOptions', row.source);
},
},
{
title: '状态',
key: 'status',
align: 'left',
width: 110,
render(row: State) {
return dict.getLabel('ImOutboxStatusOptions', row.status);
},
},
{ title: '事件类型', key: 'eventType', align: 'left', width: 220 },
{ title: '事件ID', key: 'eventId', align: 'left', width: 240 },
{ title: '目标类型', key: 'targetType', align: 'left', width: 120 },
{ title: '目标', key: 'target', align: 'left', width: 180 },
{ title: '操作用户', key: 'actorUserId', align: 'left', width: 120 },
{ title: '尝试次数', key: 'attempts', align: 'left', width: 100 },
{ title: '下次重试', key: 'nextRetryAt', align: 'left', width: 180 },
{ title: '投递时间', key: 'deliveredAt', align: 'left', width: 180 },
{ title: '创建时间', key: 'createdAt', align: 'left', width: 180 },
{ title: '更新时间', key: 'updatedAt', align: 'left', width: 180 },
];
export function loadOptions() {
dict.loadOptions(['ImOutboxSourceOptions', 'ImOutboxStatusOptions']);
}
export async function loadTenantOptions() {
const res = await TenantList({ page: 1, perPage: 20 });
tenantOptions.value = (res?.list || []).map((item) => ({
label: `${item.name}(${item.code})`,
value: item.id,
}));
return tenantOptions.value;
}