修复提现详情关联名称展示

This commit is contained in:
czl231
2026-08-16 23:33:38 +08:00
parent 043ba8df77
commit 27a4e62a43
6 changed files with 131 additions and 15 deletions

View File

@@ -1,6 +1,6 @@
/**
* 功能描述校验平台48类资源均具备中文展示字段并防止列表、详情退回数据库ID或动态英文列。
* 版本v1.2.1
* 版本v1.3.0
*/
import fs from 'node:fs';
import path from 'node:path';
@@ -79,6 +79,39 @@ for (const [key, label] of [
}
}
// 提现详情必须展示可读钱包摘要和审核人姓名UUID仅作为复制信息保留。
const withdrawalDefinition = resources.match(
/define\('wallet_apply_cash',[\s\S]*?\n\s*\], 'list',/,
)?.[0];
if (!withdrawalDefinition) throw new Error('无法读取提现记录资源定义');
for (const contract of [
"relation('wallet_basic_identity', '/wallet_basic'",
"relationOptionDisplay: 'wallet-owner'",
"relation('reviewer_identity', '/platform_account'",
"listDisplayKey: 'reviewer_name'",
'listDisplayIdentityCopy: true',
"detailDisplayKey: 'reviewer_name'",
]) {
if (!withdrawalDefinition.includes(contract)) {
throw new Error(`提现详情缺少可读关系展示契约:${contract}`);
}
}
assertIncludes(
detailContract,
"wallet_apply_cash: {",
'提现详情必须声明专属字段顺序与审核姓名快照隐藏规则',
);
assertIncludes(
detailContract,
"hiddenKeys: ['reviewer_name']",
'提现详情不得重复展示审核人姓名快照和审核人唯一标识',
);
assertIncludes(
display,
"field.relationOptionDisplay === 'wallet-owner'",
'钱包关系必须提供按归属类型生成的可读摘要',
);
// 购物车关联列必须展示用户和商品名称UUID仅作为复制与排障信息保留。
const cartDefinition = resources.match(
/define\('ec_cart',[\s\S]*?\n\s*\]\),/,

View File

@@ -1,6 +1,6 @@
/**
* 功能描述:声明平台资源详情的字段顺序、固定关联表列和 JSON 展示规则。
* 版本v1.0.0
* 版本v1.1.0
*/
export type ResourceCollectionContract = {
@@ -132,6 +132,14 @@ const contracts: Record<string, ResourceDetailContract> = {
'wallet_basic_identity', 'identity',
],
},
wallet_apply_cash: {
leadingKeys: [
'cash_no', 'apply_status', 'wallet_basic_identity', 'amount',
'reviewer_identity', 'review_reason', 'reviewed_at', 'identity',
],
// 审核姓名作为审核人关系的可读快照使用,不再重复渲染独立字段。
hiddenKeys: ['reviewer_name'],
},
ec_order: {
leadingKeys: [
'order_no', 'order_status', 'request_no', 'user_account_identity',

View File

@@ -1,6 +1,6 @@
/**
* 功能:统一资源列表与详情页面的字段名称、关系、金额、状态和时间展示。
* 版本v1.6.0
* 版本v1.7.0
*/
import dayjs from 'dayjs';
import type { RecordPageMode, ResourceRow } from './resource-page-rules';
@@ -277,6 +277,9 @@ export function relationOptionLabel(
if (field.relationOptionDisplay === 'product-name-type') {
return productNameTypeLabel(option, options);
}
if (field.relationOptionDisplay === 'wallet-owner') {
return walletOwnerLabel(option);
}
const configuredLabel = field.relationOptionLabelKey
? option[field.relationOptionLabelKey]
: undefined;
@@ -295,6 +298,20 @@ export function relationOptionLabel(
: label;
}
/** 钱包没有独立业务名称时,按归属主体类型提供稳定可读摘要。 */
function walletOwnerLabel(option: ResourceRow) {
const ownerType = String(option.owner_type ?? '');
return (
{
user: '用户钱包',
staff: '工作人员钱包',
gas: '气站钱包',
delivery: '配送点钱包',
platform: '平台钱包',
}[ownerType] ?? '钱包账户'
);
}
/** 合同气瓶优先显示具体设备名称和绑定时类型;同名同类型时追加编码以便区分。 */
function productNameTypeLabel(option: ResourceRow, options: ResourceRow[]) {
const name = String(option.product_name ?? '').trim();
@@ -326,14 +343,7 @@ function relationLabel(
(option) => String(option.identity) === identity,
);
if (!match) return '名称加载失败';
if (field.relation === '/staff_account') {
return relationOptionLabel(
field,
match,
relationOptions[field.relation ?? ''] ?? [],
);
}
return optionLabel(match);
return relationOptionLabel(field, match, relationOptions[resource] ?? []);
}
/** 根据当前记录的主体类型解析静态或动态关系资源。 */

View File

@@ -95,8 +95,8 @@ export type ResourceField = {
dynamicRelation?: ResourceDynamicRelation;
/** 关联选项优先使用的业务展示字段。 */
relationOptionLabelKey?: string;
/** 关联选项的组合展示方式;合同气瓶使用设备名称、绑定类型快照和编码消歧。 */
relationOptionDisplay?: 'product-name-type';
/** 关联选项的组合展示方式;合同气瓶和钱包分别使用对应的可读业务摘要。 */
relationOptionDisplay?: 'product-name-type' | 'wallet-owner';
/** 该字段为真时,在关联选项后追加“默认地址”。 */
relationOptionDefaultKey?: string;
/** 候选加载完成后自动选中该布尔字段为真的选项。 */
@@ -784,7 +784,12 @@ export const resources: ResourceUiDefinition[] = [
], { canCreate: false, canEdit: false, canChangeStatus: false, canArchive: false }),
define('wallet_apply_cash', '提现记录', 'readonly', [
f('cash_no'),
f('wallet_basic_identity', { type: 'identity' }),
relation('wallet_basic_identity', '/wallet_basic', false, {
label: '钱包',
relationOptionDisplay: 'wallet-owner',
displayRelationLabel: true,
showIdentityCopy: true,
}),
f('amount'),
f('apply_status', { type: 'select', options: [
{ label: '待处理', value: 10 },
@@ -792,7 +797,14 @@ export const resources: ResourceUiDefinition[] = [
{ label: '已驳回', value: 26 },
{ label: '已完成', value: 23 },
] }),
f('reviewer_name'),
relation('reviewer_identity', '/platform_account', false, {
label: '审核人',
listDisplayKey: 'reviewer_name',
listDisplayIdentityCopy: true,
detailDisplayKey: 'reviewer_name',
displayRelationLabel: true,
showIdentityCopy: true,
}),
f('review_reason'),
f('reviewed_at'),
f('completed_at'),