优化配送订单详情关联与参数展示

This commit is contained in:
czl231
2026-08-15 20:32:43 +08:00
parent 42a4fc2f41
commit a20e228296
14 changed files with 584 additions and 55 deletions

View File

@@ -1,15 +1,15 @@
/**
* 功能:统一资源列表与详情页面的字段名称、关系、金额、状态和时间展示。
* 版本v1.4.0
* 版本v1.5.0
*/
import dayjs from 'dayjs';
import type { RecordPageMode, ResourceRow } from './resource-page-rules';
import { staffRoleLabel } from './resource-staff-relation';
import {
defaultResourceFieldLabel,
type ResourceField,
type ResourceUiDefinition,
} from './resources';
import type { RecordPageMode, ResourceRow } from './resource-page-rules';
const aliases: Record<string, string> = {
identity: '唯一标识',
@@ -54,6 +54,35 @@ const collectionFieldAliases: Record<string, Record<string, string>> = {
product_type_name: '设备类型',
product_params: '设备参数',
unit_price: '成交单价(元)',
active: '是否有效',
},
'gasorder_basic.assignments': {
assigned_at: '分配时间',
gas_basic_display_name: '气站',
delivery_basic_display_name: '配送点',
staff_account_display_name: '配送人员',
assigner_name: '分配人',
reason: '分配原因',
},
'gasorder_basic.statuses': {
occurred_at: '发生时间',
from_status: '原状态',
to_status: '新状态',
operator_name: '操作人',
reason: '原因',
},
};
/** 主资源详情中的关联标识使用业务名称,技术标识仅作为辅助复制信息。 */
const resourceFieldAliases: Record<string, Record<string, string>> = {
gasorder_basic: {
identity: '系统唯一标识',
gas_basic_identity: '履约气站',
delivery_basic_identity: '当前配送点',
staff_account_identity: '当前配送人员',
user_account_identity: '服务用户',
creator_identity: '创建方',
operator_identity: '建单操作人',
},
};
@@ -107,6 +136,9 @@ export function resourceFieldLabel(
return (
collectionAliases?.[normalized] ??
definition.fields.find((field) => field.key === normalized)?.label ??
(collectionKey
? undefined
: resourceFieldAliases[definition.name]?.[normalized]) ??
defaultResourceFieldLabel(normalized) ??
aliases[normalized] ??
key
@@ -186,9 +218,10 @@ export function relationOptionLabel(
const configuredLabel = field.relationOptionLabelKey
? option[field.relationOptionLabelKey]
: undefined;
const label = configuredLabel == null || configuredLabel === ''
? optionLabel(option)
: String(configuredLabel);
const label =
configuredLabel == null || configuredLabel === ''
? optionLabel(option)
: String(configuredLabel);
if (
field.relationOptionDefaultKey &&
option[field.relationOptionDefaultKey]
@@ -253,7 +286,15 @@ export function displayRawValue(key: string, value: unknown) {
if (key === 'status') return recordStatusLabel(Number(value));
if (key === 'contract_status') return contractStatusLabel(Number(value));
if (key === 'previous_order_status' && Number(value) === 0) return '无';
if (['order_status', 'previous_order_status', 'from_status', 'to_status'].includes(key))
if (key === 'reason' && String(value) === 'order created') return '订单创建';
if (
[
'order_status',
'previous_order_status',
'from_status',
'to_status',
].includes(key)
)
return gasorderStatusLabel(Number(value));
if (key === 'action') {
return (
@@ -301,7 +342,9 @@ export function displayResourceField(
Array<{ label: string; value: string | number }>
> = {},
) {
const displayValue = field.detailDisplayKey ? row[field.detailDisplayKey] : undefined;
const displayValue = field.detailDisplayKey
? row[field.detailDisplayKey]
: undefined;
const value = displayValue ?? row[field.key] ?? row[`${field.key}_masked`];
if (value == null || value === '') return field.emptyText ?? '-';
const hasOptionSource =