feat: bind tenant members to role templates

This commit is contained in:
Codex
2026-06-29 14:37:09 +08:00
parent 1b01b923e8
commit da7b461702
8 changed files with 440 additions and 26 deletions

View File

@@ -297,6 +297,45 @@ export interface TenantRoleTemplateInput {
sortOrder?: number;
}
export interface TenantMemberItem {
id: string;
userId: string;
username?: string | null;
name?: string | null;
phone?: string | null;
email?: string | null;
avatarUrl?: string | null;
primaryRole?: string | null;
role: string;
status?: string;
permissions?: Record<string, boolean>;
roleTemplateId?: string | null;
roleTemplateCode?: string | null;
roleTemplateName?: string | null;
menuPermissions?: Record<string, boolean>;
modulePermissions?: Record<string, boolean>;
fieldPermissions?: Record<string, boolean>;
dataScope?: Record<string, unknown>;
legacyRole?: string | null;
lastSeenAt?: string | null;
createdAt?: string;
updatedAt?: string;
}
export interface TenantMemberInput {
membershipId?: string;
userId?: string;
username?: string | null;
name?: string | null;
phone?: string | null;
email?: string | null;
primaryRole?: string | null;
role: string;
status?: string;
permissions?: Record<string, boolean>;
roleTemplateId?: string | null;
}
export async function loadTenantDashboard(timeRange = '30d') {
return apiRequest<{ item?: TenantDashboard }>('/api/tenant-admin/dashboard', { query: { timeRange } });
}
@@ -459,6 +498,26 @@ export async function disableRoleTemplate(roleTemplateId: string) {
});
}
export async function loadTenantMembers(query: { keyword?: string; role?: string; status?: string; limit?: number } = {}) {
return apiRequest<{ items?: TenantMemberItem[] }>('/api/tenant-admin/members', {
query: { ...query, limit: query.limit || 50 },
});
}
export async function upsertTenantMember(input: TenantMemberInput) {
return apiRequest<{ item?: TenantMemberItem }>('/api/tenant-admin/members', {
method: 'PUT',
body: input,
});
}
export async function disableTenantMember(membershipId: string) {
return apiRequest<{ item?: TenantMemberItem }>('/api/tenant-admin/members/disable', {
method: 'POST',
body: { membershipId },
});
}
export async function loadCrmQueue(limit = 20) {
return apiRequest<{ items?: Record<string, unknown>[] }>('/api/crm/queue', { query: { limit } });
}