fix(platform-admin): correct organization and contact display
This commit is contained in:
@@ -21,9 +21,13 @@ export type ResourceFieldType =
|
||||
export type ResourceField = {
|
||||
key: string;
|
||||
label: string;
|
||||
listLabel?: string;
|
||||
type?: ResourceFieldType;
|
||||
required?: boolean;
|
||||
relation?: string;
|
||||
displayRelationLabel?: boolean;
|
||||
emptyText?: string;
|
||||
placeholder?: string;
|
||||
options?: Array<{ label: string; value: string | number }>;
|
||||
};
|
||||
|
||||
@@ -316,7 +320,7 @@ const reason = [f('reason', { required: true })];
|
||||
export const resources: ResourceUiDefinition[] = [
|
||||
{ ...define('gas_basic', '气站管理', 'writable', [f('code', { required: true }), f('name', { required: true }), f('credit_code'), f('principal'), f('address'), f('longitude'), f('latitude')]), accountManagement: { resource: '/gas_account', relationKey: 'gas_basic_identity', title: '气站账户' }, walletOwnerType: 'gas' },
|
||||
define('gas_account', '气站账户', 'writable', [f('username', { required: true }), f('password', { required: true }), f('display_name'), f('role_code'), relation('gas_basic_identity', '/gas_basic', true)]),
|
||||
{ ...define('delivery_basic', '配送点管理', 'writable', [f('delivery_code', { required: true }), f('name', { required: true }), relation('gas_basic_identity', '/gas_basic'), f('principal'), f('address')]), accountManagement: { resource: '/delivery_account', relationKey: 'delivery_basic_identity', title: '配送点账户' }, walletOwnerType: 'delivery' },
|
||||
{ ...define('delivery_basic', '配送点管理', 'writable', [f('delivery_code', { required: true }), f('name', { required: true }), f('gas_basic_identity', { label: '气站', listLabel: '气站名称', type: 'identity', relation: '/gas_basic', displayRelationLabel: true, emptyText: '平台直属', placeholder: '请选择气站,留空表示平台直属' }), f('principal'), f('address')]), accountManagement: { resource: '/delivery_account', relationKey: 'delivery_basic_identity', title: '配送点账户' }, walletOwnerType: 'delivery' },
|
||||
define('delivery_account', '配送站账户', 'writable', [f('username', { required: true }), f('password', { required: true }), f('display_name'), f('role_code'), relation('delivery_basic_identity', '/delivery_basic', true)]),
|
||||
{ ...define('staff_account', '工作人员', 'writable', [f('username', { required: true }), f('password', { required: true }), f('name', { required: true }), f('phone'), f('avatar'), f('role_code', { required: true, type: 'select', options: [{ label: '安装人员', value: 'installer' }, { label: '配送人员', value: 'delivery' }, { label: '运维人员', value: 'operations' }] }), relation('gas_basic_identity', '/gas_basic'), relation('delivery_basic_identity', '/delivery_basic'), f('work_status', { type: 'select', options: [{ label: '在岗', value: 'on_duty' }, { label: '离岗', value: 'off_duty' }] })]), walletOwnerType: 'staff' },
|
||||
define('staff_credential', '工作人员资质', 'writable', [relation('staff_account_identity', '/staff_account', true), f('credential_type', { required: true }), f('credential_no'), f('expired_at')]),
|
||||
|
||||
@@ -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 ? '是' : '否';
|
||||
|
||||
Reference in New Issue
Block a user