feat: 统一账户角色展示并优化资源页面
This commit is contained in:
@@ -161,13 +161,21 @@ export function displayResourceField(
|
||||
field: ResourceField,
|
||||
row: ResourceRow,
|
||||
relationOptions: Record<string, ResourceRow[]>,
|
||||
fieldOptions: Record<string, Array<{ label: string; value: string | number }>> = {},
|
||||
) {
|
||||
const value = row[field.key] ?? row[`${field.key}_masked`];
|
||||
if (value == null || value === '') return field.emptyText ?? '-';
|
||||
const option = field.options?.find(
|
||||
const hasOptionSource =
|
||||
Object.prototype.hasOwnProperty.call(fieldOptions, field.key) ||
|
||||
Boolean(field.options);
|
||||
const options = fieldOptions[field.key] ?? field.options;
|
||||
const option = options?.find(
|
||||
(item) => String(item.value) === String(value),
|
||||
);
|
||||
if (option) return option.label;
|
||||
if (hasOptionSource && field.unknownValueLabel) {
|
||||
return `${field.unknownValueLabel}(${String(value)})`;
|
||||
}
|
||||
if (field.type === 'identity' && typeof value === 'string') {
|
||||
return relationLabel(field, value, relationOptions);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user