fix(platform-admin): correct organization and contact display

This commit is contained in:
2026-08-08 14:48:07 +08:00
parent 20e3071789
commit 8e95a63503
7 changed files with 104 additions and 17 deletions

View File

@@ -34,9 +34,9 @@
<a-table-column title="唯一标识" :width="150">
<template #cell="{ record }"><IdentityText :value="String(record.identity)" /></template>
</a-table-column>
<a-table-column v-for="field in displayFields" :key="field.key" :title="field.label" :width="columnWidth(field)" ellipsis tooltip>
<a-table-column v-for="field in displayFields" :key="field.key" :title="field.listLabel ?? field.label" :width="columnWidth(field)" ellipsis tooltip>
<template #cell="{ record }">
<IdentityText v-if="field.type === 'identity' && identityFieldValue(field, record)" :value="identityFieldValue(field, record)" />
<IdentityText v-if="field.type === 'identity' && !field.displayRelationLabel && identityFieldValue(field, record)" :value="identityFieldValue(field, record)" />
<template v-else>{{ displayFieldValue(field, record) }}</template>
</template>
</a-table-column>
@@ -169,7 +169,7 @@
<a-select v-else-if="field.type === 'select'" v-model="form[field.key]" allow-clear>
<a-option v-for="option in field.options" :key="option.value" :value="option.value">{{ option.label }}</a-option>
</a-select>
<a-select v-else-if="field.type === 'identity' || field.type === 'identity-list'" v-model="form[field.key]" :multiple="field.type === 'identity-list'" allow-clear allow-search :loading="relationLoading[field.relation ?? '']" @search="(value: string) => searchRelation(field.relation, value)">
<a-select v-else-if="field.type === 'identity' || field.type === 'identity-list'" v-model="form[field.key]" :multiple="field.type === 'identity-list'" :placeholder="field.placeholder" allow-clear allow-search :loading="relationLoading[field.relation ?? '']" @search="(value: string) => searchRelation(field.relation, value)">
<a-option v-for="option in relationOptions[field.relation ?? ''] ?? []" :key="String(option.identity)" :value="String(option.identity)">
{{ optionLabel(option) }}
</a-option>
@@ -186,7 +186,7 @@
<a-descriptions :column="1" bordered>
<a-descriptions-item v-for="[key, value] in detailEntries" :key="key" :label="fieldLabel(key)">
<pre v-if="typeof value === 'object'" class="json-value">{{ formatValue(value) }}</pre>
<template v-else>{{ displayValue(key, value) }}</template>
<template v-else>{{ displayDetailValue(key, value) }}</template>
</a-descriptions-item>
</a-descriptions>
<div v-if="definition.name === 'gas_basic'" class="status-editor">
@@ -1027,11 +1027,15 @@ function relationLabel(field: ResourceField, identity: string) {
const match = (relationOptions[field.relation ?? ''] ?? []).find(
(option) => String(option.identity) === identity,
);
return match ? `${optionLabel(match)} · ${identity}` : identity;
if (!match) return identity;
return field.displayRelationLabel
? optionLabel(match)
: `${optionLabel(match)} · ${identity}`;
}
function displayFieldValue(field: ResourceField, row: Row) {
const value = row[field.key] ?? row[`${field.key}_masked`];
if (value == null || value === '') return field.emptyText ?? '-';
if (field.options) {
const option = field.options.find((item) => item.value === value);
if (option) return option.label;
@@ -1044,6 +1048,19 @@ function displayFieldValue(field: ResourceField, row: Row) {
return displayValue(field.key, value);
}
function displayDetailValue(key: string, value: unknown) {
const normalizedKey = key.endsWith('_masked')
? key.slice(0, -'_masked'.length)
: key;
const field = props.definition.fields.find(
(item) => item.key === normalizedKey,
);
if (field?.displayRelationLabel) {
return displayFieldValue(field, { [field.key]: value });
}
return displayValue(key, value);
}
function displayValue(key: string, value: unknown) {
if (value == null || value === '') return '-';
if (typeof value === 'boolean') return value ? '是' : '否';