feat: 统一IM后台商户文案和默认选择
This commit is contained in:
@@ -3,11 +3,19 @@ import { List as TenantList } from '@/api/imTenant';
|
||||
|
||||
export const policyTenantOptions = ref<any[]>([{ label: '全局默认', value: 0 }]);
|
||||
|
||||
export function getDefaultTenantValue(options: any[]) {
|
||||
const defaultTenant = options.find(
|
||||
(item) => item.code === 'default' || String(item.label || '').includes('(default)')
|
||||
);
|
||||
return defaultTenant?.value || options.find((item) => Number(item.value) > 0)?.value || 0;
|
||||
}
|
||||
|
||||
export async function loadPolicyTenantOptions(includeGlobal = true) {
|
||||
const res = await TenantList({ page: 1, perPage: 100 });
|
||||
const tenants = (res?.list || []).map((item) => ({
|
||||
label: `${item.name}(${item.code})`,
|
||||
value: item.id,
|
||||
code: item.code,
|
||||
}));
|
||||
policyTenantOptions.value = includeGlobal
|
||||
? [{ label: '全局默认', value: 0 }, ...tenants]
|
||||
|
||||
Reference in New Issue
Block a user