844 lines
46 KiB
TypeScript
844 lines
46 KiB
TypeScript
export type ResourceMode =
|
|
| 'writable'
|
|
| 'readonly'
|
|
| 'append_only'
|
|
| 'editable'
|
|
| 'managed';
|
|
import {
|
|
type ResourceSearchField,
|
|
resourceSearchEnumOptions,
|
|
resourceSearchFields,
|
|
} from './resource-search-contract';
|
|
|
|
export type ResourcePageKind = 'list' | 'tree';
|
|
export type ResourceFieldType =
|
|
| 'text'
|
|
| 'password'
|
|
| 'identity'
|
|
| 'identity-list'
|
|
| 'number'
|
|
| 'money'
|
|
| 'boolean'
|
|
| 'date'
|
|
| 'datetime'
|
|
| 'textarea'
|
|
| 'select'
|
|
| 'contract-file';
|
|
|
|
/** 关联下拉的父子联动配置;未配置的资源继续保持独立选择。 */
|
|
export type ResourceRelationLinkage = {
|
|
parentKey: string;
|
|
optionParentKey: string;
|
|
filterKey: string;
|
|
backfillParent?: boolean;
|
|
/** 仅使用父字段筛选候选项,不校验候选项中的父标识。 */
|
|
filterOnly?: boolean;
|
|
/** 父字段为空时不加载候选项,并禁用当前关联选择器。 */
|
|
requiresParent?: boolean;
|
|
/** 父字段变化并清空当前值时展示的中文提示。 */
|
|
parentChangeMessage?: string;
|
|
};
|
|
|
|
/** 根据父字段值选择关系资源,用于创建方等多类型业务主体。 */
|
|
export type ResourceDynamicRelation = {
|
|
parentKey: string;
|
|
parentLabel: string;
|
|
resources: Record<string, string>;
|
|
parentChangeMessage?: string;
|
|
/** 额外业务上下文,例如配送合同;上下文变化时重新限定动态候选。 */
|
|
contextParentKey?: string;
|
|
/** 按类型从上下文选项直接取得唯一主体,适用于合同用户、气站和配送点。 */
|
|
fixedIdentityKeys?: Record<string, string>;
|
|
/** 上下文缺少固定主体时展示的业务提示。 */
|
|
missingIdentityMessages?: Record<string, string>;
|
|
/** 按类型把上下文字段转换为服务端精确筛选参数。 */
|
|
scopeFilters?: Record<string, Array<{
|
|
filterKey: string;
|
|
optionKey: string;
|
|
required?: boolean;
|
|
emptyFilterKey?: string;
|
|
emptyFilterValue?: string;
|
|
}>>;
|
|
contextChangeMessage?: string;
|
|
};
|
|
|
|
export type ResourceField = {
|
|
key: string;
|
|
label: string;
|
|
listLabel?: string;
|
|
type?: ResourceFieldType;
|
|
required?: boolean;
|
|
relation?: string;
|
|
displayRelationLabel?: boolean;
|
|
listRelationNameOnly?: boolean;
|
|
displayPrecision?: number;
|
|
emptyText?: string;
|
|
placeholder?: string;
|
|
showIdentityCopy?: boolean;
|
|
readonlyRelationText?: boolean;
|
|
/** 列表中以可悬浮、可复制的紧凑文本展示普通字段。 */
|
|
listCopyable?: boolean;
|
|
/** 列表读取另一个只读响应字段展示,表单仍使用原业务字段。 */
|
|
listDisplayKey?: string;
|
|
/** 详情读取另一个只读响应字段展示,原关系唯一标识仍用于复制。 */
|
|
detailDisplayKey?: string;
|
|
/** 点击列表展示内容时进入当前记录详情。 */
|
|
listDetailLink?: boolean;
|
|
/** 列表以可读展示字段为主文案,同时保留原关系唯一标识复制入口。 */
|
|
listDisplayIdentityCopy?: boolean;
|
|
options?: Array<{ label: string; value: string | number }>;
|
|
defaultValue?: string | number | boolean;
|
|
readonlyOnCreate?: boolean;
|
|
unknownValueLabel?: string;
|
|
relationLinkage?: ResourceRelationLinkage;
|
|
/** 父字段值决定实际关系资源,未选择父字段时不加载候选。 */
|
|
dynamicRelation?: ResourceDynamicRelation;
|
|
/** 关联选项优先使用的业务展示字段。 */
|
|
relationOptionLabelKey?: string;
|
|
/** 关联选项的组合展示方式;合同气瓶使用设备名称、绑定类型快照和编码消歧。 */
|
|
relationOptionDisplay?: 'product-name-type';
|
|
/** 该字段为真时,在关联选项后追加“默认地址”。 */
|
|
relationOptionDefaultKey?: string;
|
|
/** 候选加载完成后自动选中该布尔字段为真的选项。 */
|
|
relationAutoSelectKey?: string;
|
|
/** 关联候选为空时展示的业务引导。 */
|
|
relationEmptyText?: string;
|
|
/** 关联候选为空时提供的站内处理入口。 */
|
|
relationEmptyAction?: { label: string; routeName: string };
|
|
/** 该关联字段每次加载与搜索都必须携带的精确筛选参数。 */
|
|
relationFilters?: Record<string, string>;
|
|
/** 筛选结果中不存在当前值时立即清空,禁止通过详情补载绕过候选范围。 */
|
|
relationStrictFilter?: boolean;
|
|
/** 严格筛选清空失效值时展示的提示。 */
|
|
relationInvalidMessage?: string;
|
|
staffRelation?: import('./resource-staff-relation').StaffRelationPolicy;
|
|
};
|
|
|
|
export type DetailAction = {
|
|
name: string;
|
|
resource: string;
|
|
method?: 'POST' | 'PUT' | 'PATCH';
|
|
danger?: boolean;
|
|
fields?: ResourceField[];
|
|
visibleFor?: { field: string; values: Array<string | number> };
|
|
};
|
|
|
|
export type ResourceUiDefinition = {
|
|
key: string;
|
|
name: string;
|
|
resource: `/${string}`;
|
|
title: string;
|
|
mode: ResourceMode;
|
|
pageKind: ResourcePageKind;
|
|
fields: ResourceField[];
|
|
searchFields: ResourceSearchField[];
|
|
detailActions?: DetailAction[];
|
|
canCreate: boolean;
|
|
canEdit: boolean;
|
|
canChangeStatus: boolean;
|
|
canArchive: boolean;
|
|
accountManagement?: {
|
|
resource: `/${string}`;
|
|
relationKey: string;
|
|
title: string;
|
|
};
|
|
walletOwnerType?: 'gas' | 'delivery' | 'staff' | 'user';
|
|
};
|
|
|
|
const fieldLabels: Record<string, string> = {
|
|
code: '编码',
|
|
producer_code: '生产商编码',
|
|
name: '名称',
|
|
username: '用户名',
|
|
password: '密码',
|
|
display_name: '显示名称',
|
|
role_code: '角色',
|
|
platform_role_code: '平台角色',
|
|
credit_code: '统一社会信用代码',
|
|
principal: '负责人',
|
|
manager: '库房负责人',
|
|
phone: '联系电话',
|
|
address: '地址',
|
|
longitude: '经度',
|
|
latitude: '纬度',
|
|
delivery_code: '配送站编码',
|
|
avatar: '头像',
|
|
work_status: '工作状态',
|
|
credential_type: '资质类型',
|
|
credential_no: '资质编号',
|
|
expired_at: '到期时间',
|
|
real_name: '实名姓名',
|
|
is_default: '默认地址',
|
|
params: '智能气阀参数',
|
|
produced_at: '生产时间',
|
|
enabled_at: '启用时间',
|
|
product_status: '智能气阀状态',
|
|
contract_status: '合同状态',
|
|
order_status: '订单状态',
|
|
previous_order_status: '异常前订单状态',
|
|
payment_status: '支付状态',
|
|
refund_status: '退款状态',
|
|
apply_status: '提现状态',
|
|
ticket_status: '工单状态',
|
|
reconciliation_status: '对账状态',
|
|
repair_no: '检修单号',
|
|
repair_type: '检修类型',
|
|
started_at: '开始时间',
|
|
completed_at: '完成时间',
|
|
result: '检修结果',
|
|
target_product_status: '目标产品状态',
|
|
content: '内容',
|
|
operator: '操作人员',
|
|
remark: '备注',
|
|
action: '动作',
|
|
occurred_at: '发生时间',
|
|
reason: '原因',
|
|
operator_identity: '操作人标识',
|
|
operator_name: '操作人',
|
|
owner_type: '归属类型',
|
|
owner_identity: '归属标识',
|
|
alipay_id: '支付宝账号',
|
|
alipay_name: '支付宝账户名',
|
|
wxpay_id: '微信账号',
|
|
wxpay_name: '微信账户名',
|
|
balance: '余额(元)',
|
|
withdrawal_balance: '可提现余额(元)',
|
|
card_no_last4: '银行卡末四位',
|
|
bank_name: '银行名称',
|
|
card_owner: '持卡人',
|
|
payment_no: '支付单号',
|
|
order_no: '订单号',
|
|
trade_no: '第三方流水号',
|
|
payment_type: '支付业务类型',
|
|
pay_channel: '支付渠道',
|
|
pay_type: '支付类型',
|
|
amount: '金额(元)',
|
|
fee: '手续费(元)',
|
|
args: '支付参数',
|
|
callback_msg: '回调信息',
|
|
record_no: '流水号',
|
|
request_no: '请求流水号',
|
|
direction: '收支方向',
|
|
trade_type: '交易类型',
|
|
balance_after: '变动后余额(元)',
|
|
withdrawal_balance_after: '变动后可提现余额(元)',
|
|
refund_no: '退款单号',
|
|
cash_no: '提现单号',
|
|
channel: '渠道',
|
|
review_reason: '审核原因',
|
|
reviewed_at: '审核时间',
|
|
reviewer_name: '审核人',
|
|
reviewer_identity: '审核人标识',
|
|
review_remark: '审核说明',
|
|
business_type: '业务类型',
|
|
business_identity: '业务标识',
|
|
user_identity: '用户标识',
|
|
ymd: '日期',
|
|
ym: '月份',
|
|
contract_no: '合同编号',
|
|
title: '标题',
|
|
terms: '合同条款',
|
|
file_uri: '附件地址',
|
|
default_delivery_fee: '默认配送费(元)',
|
|
signed_at: '签署时间',
|
|
effective_at: '生效时间',
|
|
bound_at: '绑定时间',
|
|
unit_price: '单价(元)',
|
|
unbound_at: '解绑时间',
|
|
revision_no: '修订号',
|
|
creator_type: '创建方类型',
|
|
creator_identity: '创建方标识',
|
|
contact_name: '联系人',
|
|
contact_phone: '联系电话',
|
|
product_amount: '商品金额(元)',
|
|
discount_amount: '优惠金额(元)',
|
|
payable_amount: '应付金额(元)',
|
|
total_amount: '总金额(元)',
|
|
delivery_fee: '配送费(元)',
|
|
assigned_at: '分配时间',
|
|
from_status: '原状态',
|
|
to_status: '新状态',
|
|
track_no: '轨迹编号',
|
|
attempt_no: '尝试次数',
|
|
point_type: '轨迹点类型',
|
|
confirmed_at: '确认时间',
|
|
sort_no: '排序',
|
|
product_code: '商品编码',
|
|
product_type_name: '产品类型名称',
|
|
product_params: '产品规格参数',
|
|
price_amount: '售价(元)',
|
|
stock_quantity: '库存',
|
|
value: '属性值',
|
|
image_uri: '图片地址',
|
|
is_cover: '封面图',
|
|
quantity: '数量',
|
|
selected: '是否选中',
|
|
product_snapshot: '商品快照',
|
|
sale_amount: '成交金额(元)',
|
|
score: '评分',
|
|
paid_at: '支付时间',
|
|
settlement_no: '结算单号',
|
|
subject_type: '结算主体类型',
|
|
period_start: '结算开始时间',
|
|
period_end: '结算结束时间',
|
|
bill_date: '账单日期',
|
|
difference_amount: '差异金额(元)',
|
|
content_type: '内容类型',
|
|
body: '正文',
|
|
version_no: '版本号',
|
|
publish_status: '发布状态',
|
|
ticket_no: '工单号',
|
|
category: '分类',
|
|
priority: '优先级',
|
|
location_scope: '坐标权限',
|
|
parent_identity: '父级',
|
|
group_code: '菜单分组编码',
|
|
icon: '图标',
|
|
path: '路由',
|
|
menu_identities: '菜单权限',
|
|
status: '状态',
|
|
confirm_type: '确认方式',
|
|
delivery_basic_identity: '配送点唯一标识',
|
|
description: '说明',
|
|
ec_category_identity: '商品分类唯一标识',
|
|
ec_product_identity: '商品唯一标识',
|
|
ec_order_identity: '商城订单唯一标识',
|
|
gas_basic_identity: '气站唯一标识',
|
|
gasorder_basic_identity: '配送订单唯一标识',
|
|
gasorder_contract_identity: '配送合同唯一标识',
|
|
gasorder_contract_product_identity: '合同气瓶唯一标识',
|
|
gasorder_contract_product_identities: '合同气瓶唯一标识',
|
|
producer_account_identity: '生产商唯一标识',
|
|
product_info_identity: '智能气阀唯一标识',
|
|
product_type_identity: '智能气阀类型唯一标识',
|
|
proof_uri: '凭证地址',
|
|
active: '是否有效',
|
|
assigner_identity: '分配人唯一标识',
|
|
assigner_name: '分配人',
|
|
source: '定位来源',
|
|
accuracy: '定位精度',
|
|
speed: '定位速度',
|
|
received_at: '接收时间',
|
|
merchant_identity: '商户唯一标识',
|
|
channel_trade_no: '渠道交易号',
|
|
subject: '支付标题',
|
|
failure_code: '失败代码',
|
|
failure_message: '失败原因',
|
|
expires_at: '支付过期时间',
|
|
closed_at: '关闭时间',
|
|
bind_id: '渠道绑定标识',
|
|
bank_type: '银行卡类型',
|
|
bank: '银行编码',
|
|
in_trade_no: '内部业务流水号',
|
|
out_trade_no: '外部渠道流水号',
|
|
logistics_no: '物流单号',
|
|
logistics_company: '物流公司',
|
|
logistics_status: '物流状态',
|
|
shipped_at: '发货时间',
|
|
gasorder_track_identity: '配送轨迹唯一标识',
|
|
payment_order_identity: '支付记录唯一标识',
|
|
related_record_identity: '关联流水唯一标识',
|
|
icon_name: '图标',
|
|
recipient_name: '签收人姓名',
|
|
recipient_phone: '签收人电话',
|
|
staff_account_identity: '工作人员唯一标识',
|
|
subject_identity: '结算主体唯一标识',
|
|
user_account_identity: '用户唯一标识',
|
|
user_address_identity: '用户地址唯一标识',
|
|
wallet_bank_identity: '银行卡唯一标识',
|
|
wallet_basic_identity: '钱包唯一标识',
|
|
warehouse_identity: '库房唯一标识',
|
|
withdrawable: '计入可提现余额',
|
|
};
|
|
|
|
/** 返回字段的全局中文名称,供未显式声明字段的只读页面统一兜底。 */
|
|
export function defaultResourceFieldLabel(key: string) {
|
|
return fieldLabels[key];
|
|
}
|
|
|
|
const numbers = new Set([
|
|
'sort_no', 'stock_quantity', 'quantity', 'score', 'version_no',
|
|
'attempt_no', 'target_product_status',
|
|
]);
|
|
const money = new Set([
|
|
'unit_price', 'amount', 'fee', 'balance', 'withdrawal_balance',
|
|
'balance_after', 'withdrawal_balance_after', 'default_delivery_fee',
|
|
'product_amount', 'discount_amount', 'total_amount', 'delivery_fee', 'price_amount',
|
|
'payable_amount', 'sale_amount', 'difference_amount',
|
|
]);
|
|
const booleans = new Set(['is_default', 'is_cover', 'selected', 'withdrawable']);
|
|
const dates = new Set(['bill_date']);
|
|
const datetimes = new Set([
|
|
'expired_at', 'produced_at', 'enabled_at', 'started_at', 'completed_at',
|
|
'occurred_at', 'reviewed_at', 'signed_at', 'effective_at', 'unbound_at',
|
|
'assigned_at', 'confirmed_at', 'paid_at', 'period_start', 'period_end',
|
|
'received_at', 'expires_at', 'closed_at', 'shipped_at',
|
|
]);
|
|
const textareas = new Set([
|
|
'params', 'content', 'remark', 'reason', 'terms', 'args', 'callback_msg',
|
|
'review_reason', 'product_snapshot', 'body',
|
|
]);
|
|
|
|
function f(key: string, options: Partial<ResourceField> = {}): ResourceField {
|
|
const label = fieldLabels[key];
|
|
if (!label) throw new Error(`资源字段缺少中文名称:${key}`);
|
|
const type: ResourceFieldType = key.endsWith('_identity')
|
|
? 'identity'
|
|
: money.has(key)
|
|
? 'money'
|
|
: numbers.has(key)
|
|
? 'number'
|
|
: booleans.has(key)
|
|
? 'boolean'
|
|
: dates.has(key)
|
|
? 'date'
|
|
: datetimes.has(key)
|
|
? 'datetime'
|
|
: textareas.has(key)
|
|
? 'textarea'
|
|
: key === 'password'
|
|
? 'password'
|
|
: 'text';
|
|
return { key, label, type, ...options };
|
|
}
|
|
|
|
function relation(
|
|
key: string,
|
|
resource: string,
|
|
required = false,
|
|
options: Partial<ResourceField> = {},
|
|
): ResourceField {
|
|
return f(key, { ...options, type: 'identity', relation: resource, required });
|
|
}
|
|
|
|
/** 创建固定管理员角色字段,页面展示中文名称,接口仍使用稳定编码。 */
|
|
function fixedAdminRole(resource: string): ResourceField {
|
|
return f('role_code', {
|
|
label: '角色',
|
|
listLabel: '角色',
|
|
type: 'select',
|
|
required: true,
|
|
options: resourceSearchEnumOptions(resource, 'role_code'),
|
|
defaultValue: 'admin',
|
|
readonlyOnCreate: true,
|
|
unknownValueLabel: '未知角色',
|
|
});
|
|
}
|
|
|
|
/** 生产商当前只有管理员角色;历史未知编码继续按原值展示。 */
|
|
function producerAdminRole(): ResourceField {
|
|
return f('role_code', {
|
|
label: '角色',
|
|
type: 'select',
|
|
required: true,
|
|
options: [{ label: '生产商管理员', value: 'admin' }],
|
|
defaultValue: 'admin',
|
|
readonlyOnCreate: true,
|
|
});
|
|
}
|
|
|
|
function define(
|
|
name: string,
|
|
title: string,
|
|
mode: ResourceMode,
|
|
fields: ResourceField[],
|
|
pageKind: ResourcePageKind = 'list',
|
|
detailActions?: DetailAction[],
|
|
capabilities: Partial<
|
|
Pick<
|
|
ResourceUiDefinition,
|
|
'canCreate' | 'canEdit' | 'canChangeStatus' | 'canArchive'
|
|
>
|
|
> = {},
|
|
): ResourceUiDefinition {
|
|
const defaults = {
|
|
canCreate: mode === 'writable' || mode === 'editable' || mode === 'append_only',
|
|
canEdit: mode === 'writable' || mode === 'editable',
|
|
canChangeStatus: mode === 'writable' || mode === 'editable',
|
|
canArchive: mode === 'writable',
|
|
};
|
|
return {
|
|
key: name.replace(/_/g, '-'),
|
|
name,
|
|
resource: `/${name}`,
|
|
title,
|
|
mode,
|
|
pageKind,
|
|
fields,
|
|
searchFields: resourceSearchFields(name),
|
|
...defaults,
|
|
...capabilities,
|
|
...(detailActions ? { detailActions } : {}),
|
|
};
|
|
}
|
|
|
|
const reason = [f('reason', { required: true })];
|
|
const productStatusOptions = [
|
|
{ label: '待处理', value: 10 },
|
|
{ label: '在库', value: 28 },
|
|
{ label: '运输中', value: 29 },
|
|
{ label: '使用中', value: 30 },
|
|
{ label: '维修中', value: 31 },
|
|
{ label: '已报废', value: 27 },
|
|
];
|
|
|
|
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'), fixedAdminRole('gas_account'), relation('gas_basic_identity', '/gas_basic', true)]),
|
|
{ ...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'), fixedAdminRole('delivery_account'), 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: resourceSearchEnumOptions('staff_account', 'role_code') }), f('gas_basic_identity', { label: '所属气站', type: 'identity', relation: '/gas_basic' }), f('delivery_basic_identity', { label: '所属配送点', type: 'identity', relation: '/delivery_basic', relationLinkage: { parentKey: 'gas_basic_identity', optionParentKey: 'gas_basic_identity', filterKey: 'gas_basic_identities', backfillParent: true } }), 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, { staffRelation: { roles: 'context', lockPrefilled: true, showIdentityCopy: true } }), f('credential_type', { required: true }), f('credential_no'), f('expired_at')]),
|
|
{ ...define('user_account', '用户账户', 'writable', [f('username', { required: true }), f('password', { required: true }), f('name', { required: true }), f('phone'), f('avatar'), f('real_name')]), walletOwnerType: 'user' },
|
|
define('user_address', '用户地址', 'writable', [relation('user_account_identity', '/user_account', true, { listLabel: '用户账户', listRelationNameOnly: true }), f('address', { required: true, emptyText: '未填写', placeholder: '未填写' }), f('longitude', { displayPrecision: 6, emptyText: '未填写', placeholder: '未填写' }), f('latitude', { displayPrecision: 6, emptyText: '未填写', placeholder: '未填写' }), f('is_default')]),
|
|
define('user_service_relation', '用户服务关系', 'writable', [
|
|
relation('user_account_identity', '/user_account', true, {
|
|
label: '用户账户',
|
|
listLabel: '用户账户',
|
|
listRelationNameOnly: true,
|
|
displayRelationLabel: true,
|
|
showIdentityCopy: true,
|
|
readonlyRelationText: true,
|
|
}),
|
|
relation('gas_basic_identity', '/gas_basic', false, {
|
|
label: '所属气站',
|
|
listLabel: '所属气站',
|
|
listRelationNameOnly: true,
|
|
displayRelationLabel: true,
|
|
emptyText: '暂未分配',
|
|
placeholder: '请选择所属气站',
|
|
showIdentityCopy: true,
|
|
}),
|
|
relation('delivery_basic_identity', '/delivery_basic', false, {
|
|
label: '所属配送点',
|
|
listLabel: '所属配送点',
|
|
listRelationNameOnly: true,
|
|
displayRelationLabel: true,
|
|
emptyText: '暂未分配',
|
|
placeholder: '请选择所属配送点',
|
|
showIdentityCopy: true,
|
|
relationLinkage: {
|
|
parentKey: 'gas_basic_identity',
|
|
optionParentKey: 'gas_basic_identity',
|
|
filterKey: 'gas_basic_identities',
|
|
backfillParent: true,
|
|
},
|
|
}),
|
|
relation('staff_account_identity', '/staff_account', false, {
|
|
label: '服务人员',
|
|
listLabel: '服务人员',
|
|
listRelationNameOnly: true,
|
|
displayRelationLabel: true,
|
|
emptyText: '暂未分配',
|
|
placeholder: '请选择服务人员',
|
|
showIdentityCopy: true,
|
|
staffRelation: {
|
|
roles: ['installer', 'delivery', 'operations'],
|
|
enabledOnly: true,
|
|
organizationScoped: true,
|
|
},
|
|
}),
|
|
]),
|
|
|
|
define('producer_account', '生产商管理', 'writable', [f('producer_code', { required: true }), f('name', { required: true }), f('credit_code'), f('principal'), f('phone'), f('address', { emptyText: '未填写', placeholder: '请输入地址' }), f('username', { required: true }), f('password', { required: true }), f('display_name'), producerAdminRole(), f('remark')]),
|
|
define('product_type', '智能气阀类型', 'editable', [f('code', { required: true }), f('name', { required: true })]),
|
|
define('product_warehouse', '智能气阀库房', 'editable', [f('code', { required: true }), f('name', { required: true }), f('address', { emptyText: '未填写', placeholder: '请输入地址' }), f('manager'), f('phone')]),
|
|
define('product_info', '智能气阀', 'editable', [f('code', { required: true }), f('name', { required: true }), f('product_status', { type: 'select', options: productStatusOptions, unknownValueLabel: '未知状态' }), relation('producer_account_identity', '/producer_account', true, { label: '生产商', listLabel: '生产商', listRelationNameOnly: true, displayRelationLabel: true, showIdentityCopy: true, emptyText: '未填写', placeholder: '请选择生产商' }), relation('product_type_identity', '/product_type', true, { label: '智能气阀类型', listLabel: '智能气阀类型', listRelationNameOnly: true, displayRelationLabel: true, showIdentityCopy: true, emptyText: '未填写', placeholder: '请选择智能气阀类型' }), f('params', { required: true }), relation('warehouse_identity', '/product_warehouse', false, { label: '库房', emptyText: '未填写', placeholder: '请选择库房' }), relation('gas_basic_identity', '/gas_basic', false, { label: '气站', emptyText: '未填写', placeholder: '请选择气站' }), relation('delivery_basic_identity', '/delivery_basic', false, { label: '配送点', emptyText: '未填写', placeholder: '请选择配送点' }), relation('user_account_identity', '/user_account', false, { label: '用户', emptyText: '未填写', placeholder: '请选择用户' }), f('produced_at', { required: true })], 'list', [
|
|
{ name: '修改智能气阀状态', resource: '/product_info/:identity/lifecycle', method: 'PATCH', fields: [f('product_status', { label: '目标状态', required: true, type: 'select', options: productStatusOptions, placeholder: '请选择目标状态' })] },
|
|
{ name: '变更智能气阀归属', resource: '/product_info/:identity', method: 'PUT', fields: [relation('warehouse_identity', '/product_warehouse'), relation('gas_basic_identity', '/gas_basic'), relation('delivery_basic_identity', '/delivery_basic'), relation('user_account_identity', '/user_account'), f('action', { required: true, type: 'select', options: [{ label: '入库', value: 'warehouse' }, { label: '分配', value: 'assigned' }, { label: '归还', value: 'returned' }, { label: '人工调整', value: 'manual' }] }), f('reason', { required: true }), f('remark')] },
|
|
]),
|
|
define('product_repair', '智能气阀检修记录', 'editable', [relation('product_info_identity', '/product_info', true), f('repair_no', { required: true }), f('repair_type', { required: true }), f('started_at', { required: true }), f('completed_at'), f('result', { type: 'select', options: resourceSearchEnumOptions('product_repair', 'result') }), f('target_product_status', { type: 'select', options: [{ label: '在库', value: 28 }, { label: '运输中', value: 29 }, { label: '使用中', value: 30 }, { label: '报废', value: 27 }] }), f('content'), f('operator'), f('remark')]),
|
|
define('product_owner', '智能气阀归属记录', 'readonly', [
|
|
relation('product_info_identity', '/product_info'),
|
|
relation('warehouse_identity', '/product_warehouse'),
|
|
relation('gas_basic_identity', '/gas_basic'),
|
|
relation('delivery_basic_identity', '/delivery_basic'),
|
|
relation('user_account_identity', '/user_account'),
|
|
f('action'), f('occurred_at'), f('operator_name'), f('operator_identity'), f('reason'), f('remark'),
|
|
]),
|
|
|
|
define('gasorder_contract', '配送合同', 'managed', [
|
|
f('contract_no', { required: true, listCopyable: true }),
|
|
relation('user_account_identity', '/user_account', true, {
|
|
label: '用户账户', listLabel: '用户账户', listRelationNameOnly: true,
|
|
displayRelationLabel: true, showIdentityCopy: true, readonlyRelationText: true,
|
|
}),
|
|
relation('gas_basic_identity', '/gas_basic', true, {
|
|
label: '所属气站', listLabel: '所属气站', listRelationNameOnly: true,
|
|
displayRelationLabel: true, showIdentityCopy: true, readonlyRelationText: true,
|
|
}),
|
|
relation('delivery_basic_identity', '/delivery_basic', false, {
|
|
label: '所属配送点', listLabel: '所属配送点', listRelationNameOnly: true,
|
|
displayRelationLabel: true, emptyText: '暂未指定', placeholder: '请选择默认配送点,可留空',
|
|
showIdentityCopy: true,
|
|
relationLinkage: {
|
|
parentKey: 'gas_basic_identity', optionParentKey: 'gas_basic_identity',
|
|
filterKey: 'gas_basic_identities', backfillParent: true,
|
|
},
|
|
}),
|
|
f('title', { required: true }), f('terms'),
|
|
f('file_uri', { label: '合同附件', type: 'contract-file' }),
|
|
f('default_delivery_fee'),
|
|
f('signed_at', { required: true }), f('effective_at', { required: true }), f('expired_at', { required: true, emptyText: '待补录' }),
|
|
], 'list', [
|
|
{ name: '启用合同', resource: '/gasorder_contract/:identity/activate', fields: reason, visibleFor: { field: 'contract_status', values: [0] } },
|
|
{ name: '续签合同', resource: '/gasorder_contract/:identity/renew', fields: [f('effective_at', { required: true }), f('expired_at', { required: true }), ...reason], visibleFor: { field: 'contract_status', values: [11, 12, 13] } },
|
|
{ name: '终止合同', resource: '/gasorder_contract/:identity/terminate', danger: true, fields: reason, visibleFor: { field: 'contract_status', values: [11] } },
|
|
], { canCreate: true, canEdit: true }),
|
|
define('gasorder_contract_product', '合同气瓶', 'append_only', [relation('gasorder_contract_identity', '/gasorder_contract', true, {
|
|
readonlyRelationText: true, displayRelationLabel: true,
|
|
placeholder: '请选择草稿合同', relationFilters: { candidate: 'binding' }, relationStrictFilter: true,
|
|
relationInvalidMessage: '所选合同已不是草稿状态,已清空,请重新选择',
|
|
relationEmptyText: '暂无可绑定气瓶的草稿合同,请先新建配送合同',
|
|
}), relation('product_info_identity', '/product_info', true, {
|
|
label: '智能气阀',
|
|
placeholder: '请先选择合同,再选择该合同用户可绑定的气瓶',
|
|
relationEmptyText: '该合同用户暂无可绑定的智能气阀。请先到“智能气阀管理”将设备归属变更为该用户,并确认设备已启用、未报废。',
|
|
relationEmptyAction: { label: '前往智能气阀管理', routeName: 'product-info' },
|
|
relationLinkage: {
|
|
parentKey: 'gasorder_contract_identity', optionParentKey: '',
|
|
filterKey: 'contract_identity', filterOnly: true,
|
|
},
|
|
}), f('unit_price')], 'list', [
|
|
{ name: '解绑气瓶', resource: '/gasorder_contract_product/:identity/unbind', danger: true, fields: reason },
|
|
]),
|
|
define('gasorder_contract_revision', '合同修订记录', 'readonly', [
|
|
relation('gasorder_contract_identity', '/gasorder_contract'),
|
|
f('action'), f('contract_status'), f('effective_at'), f('expired_at'),
|
|
f('operator_name'), f('operator_identity'), f('occurred_at'), f('reason'),
|
|
]),
|
|
define('gasorder_basic', '气体配送订单', 'append_only', [f('request_no', { required: true }), relation('gasorder_contract_identity', '/gasorder_contract', true, { label: '配送合同', listDisplayKey: 'contract_display_name', detailDisplayKey: 'contract_display_name', listDisplayIdentityCopy: true, showIdentityCopy: true, placeholder: '请选择当前可履约的生效合同', relationFilters: { candidate: 'order' }, relationStrictFilter: true, relationInvalidMessage: '所选配送合同已不可履约,已清空,请重新选择', relationEmptyText: '暂无可下单的生效合同,请先启用或续签配送合同' }), f('creator_type', { required: true, type: 'select', options: resourceSearchEnumOptions('gasorder_basic', 'creator_type') }), f('creator_identity', { label: '创建方', required: true, listDisplayKey: 'creator_display_name', listDisplayIdentityCopy: true, placeholder: '请先选择配送合同和创建方类型', readonlyRelationText: true, relationFilters: { status: '1' }, relationEmptyText: '当前合同下暂无可用的创建方', dynamicRelation: {
|
|
parentKey: 'creator_type', parentLabel: '创建方类型', contextParentKey: 'gasorder_contract_identity',
|
|
resources: { user: '/user_account', staff: '/staff_account', delivery: '/delivery_basic', gas: '/gas_basic' },
|
|
fixedIdentityKeys: { user: 'user_account_identity', gas: 'gas_basic_identity', delivery: 'delivery_basic_identity' },
|
|
missingIdentityMessages: { delivery: '所选合同未指定配送点,不能以配送点作为创建方' },
|
|
scopeFilters: { staff: [
|
|
{ filterKey: 'gas_basic_identities', optionKey: 'gas_basic_identity', required: true },
|
|
{ filterKey: 'delivery_basic_identities', optionKey: 'delivery_basic_identity', emptyFilterKey: 'delivery_basic_unassigned', emptyFilterValue: 'true' },
|
|
] },
|
|
parentChangeMessage: '创建方类型已变更,已按当前合同重新匹配创建方',
|
|
contextChangeMessage: '配送合同已变更,创建方已按新合同重新匹配',
|
|
} }), relation('user_address_identity', '/user_address', true, {
|
|
label: '收货地址', listDisplayKey: 'address', emptyText: '未填写', placeholder: '请先选择配送合同,再选择该合同用户的收货地址',
|
|
relationOptionLabelKey: 'address', relationOptionDefaultKey: 'is_default',
|
|
relationAutoSelectKey: 'is_default', relationEmptyText: '该合同用户暂无收货地址,请先维护用户地址',
|
|
relationLinkage: {
|
|
parentKey: 'gasorder_contract_identity', optionParentKey: '',
|
|
filterKey: 'gasorder_contract_identity', filterOnly: true, requiresParent: true,
|
|
parentChangeMessage: '配送合同已变更,请重新选择该合同用户的收货地址',
|
|
},
|
|
}), f('gasorder_contract_product_identities', { label: '合同气瓶', required: true, type: 'identity-list', listDisplayKey: 'contract_products_summary', listDetailLink: true, emptyText: '未填写', relation: '/gasorder_contract_product', placeholder: '请输入智能气阀名称、设备类型或设备编码搜索', relationOptionDisplay: 'product-name-type', relationEmptyText: '该合同暂无可用气瓶,请先为合同绑定气瓶', relationLinkage: { parentKey: 'gasorder_contract_identity', optionParentKey: '', filterKey: 'contract_identity', filterOnly: true, requiresParent: true, parentChangeMessage: '配送合同已变更,请重新选择该合同可用的气瓶' } }), f('contact_name', { required: true }), f('contact_phone', { required: true }), f('discount_amount'), f('remark')], 'list', [
|
|
{ name: '分配订单', resource: '/gasorder_basic/:identity/assign', fields: [relation('delivery_basic_identity', '/delivery_basic', true, { label: '配送点', placeholder: '请选择合同履约范围内的配送点', relationFilters: { status: '1' } }), relation('staff_account_identity', '/staff_account', true, { label: '配送人员', placeholder: '请选择当前配送点内的配送人员', relationEmptyText: '该配送点暂无在岗且资质有效的配送人员', staffRelation: { roles: ['delivery'], enabledOnly: true, workStatus: 'on_duty', validCredentialOnly: true } }), ...reason], visibleFor: { field: 'order_status', values: [16, 18] } },
|
|
{ name: '开始罐装', resource: '/gasorder_basic/:identity/filling', fields: reason, visibleFor: { field: 'order_status', values: [18] } },
|
|
{ name: '待配送', resource: '/gasorder_basic/:identity/ready', fields: reason, visibleFor: { field: 'order_status', values: [19] } },
|
|
{ name: '开始配送', resource: '/gasorder_basic/:identity/delivering', fields: reason, visibleFor: { field: 'order_status', values: [20] } },
|
|
{ name: '等待签收', resource: '/gasorder_basic/:identity/awaiting-confirmation', fields: reason, visibleFor: { field: 'order_status', values: [33] } },
|
|
{ name: '完成订单', resource: '/gasorder_basic/:identity/complete', fields: [...reason, f('confirm_type', { required: true }), f('recipient_name', { required: true }), f('recipient_phone'), f('proof_uri'), f('remark')], visibleFor: { field: 'order_status', values: [34] } },
|
|
{ name: '标记异常', resource: '/gasorder_basic/:identity/exception', fields: reason, visibleFor: { field: 'order_status', values: [19, 20, 33, 34] } },
|
|
{ name: '恢复订单', resource: '/gasorder_basic/:identity/recover', fields: reason, visibleFor: { field: 'order_status', values: [21] } },
|
|
{ name: '取消订单', resource: '/gasorder_basic/:identity/cancel', danger: true, fields: reason, visibleFor: { field: 'order_status', values: [16, 18] } },
|
|
]),
|
|
define('gasorder_item', '订单明细', 'readonly', [
|
|
relation('gasorder_basic_identity', '/gasorder_basic'),
|
|
relation('gasorder_contract_product_identity', '/gasorder_contract_product'),
|
|
relation('product_info_identity', '/product_info'),
|
|
f('product_code'), f('product_type_name'), f('product_params'), f('unit_price'), f('active'),
|
|
]),
|
|
define('gasorder_assign', '分配记录', 'readonly', [
|
|
relation('gasorder_basic_identity', '/gasorder_basic'),
|
|
relation('gas_basic_identity', '/gas_basic'),
|
|
relation('delivery_basic_identity', '/delivery_basic'),
|
|
relation('staff_account_identity', '/staff_account'),
|
|
f('assigner_name'), f('assigner_identity'), f('assigned_at'), f('reason'),
|
|
]),
|
|
define('gasorder_status', '状态记录', 'readonly', [
|
|
relation('gasorder_basic_identity', '/gasorder_basic'),
|
|
f('from_status'), f('to_status'), f('operator_name'), f('operator_identity'), f('occurred_at'), f('reason'),
|
|
]),
|
|
define('gasorder_track', '运行轨迹', 'readonly', [
|
|
relation('gasorder_basic_identity', '/gasorder_basic', false, {
|
|
label: '配送订单',
|
|
listLabel: '配送订单',
|
|
listRelationNameOnly: true,
|
|
displayRelationLabel: true,
|
|
showIdentityCopy: true,
|
|
}),
|
|
relation('staff_account_identity', '/staff_account', false, {
|
|
label: '配送人员',
|
|
listLabel: '配送人员',
|
|
listRelationNameOnly: true,
|
|
displayRelationLabel: true,
|
|
showIdentityCopy: true,
|
|
// 历史轨迹只限定岗位,不按当前启用、在岗或资质状态过滤。
|
|
staffRelation: { roles: ['delivery'] },
|
|
}),
|
|
f('attempt_no'), f('started_at'), f('completed_at'),
|
|
]),
|
|
define('gasorder_track_point', '轨迹点', 'readonly', [
|
|
relation('gasorder_track_identity', '/gasorder_track'),
|
|
f('request_no'), f('longitude'), f('latitude'), f('occurred_at'), f('received_at'),
|
|
f('source'), f('accuracy'), f('speed'), f('direction'),
|
|
]),
|
|
define('gasorder_confirm', '确认记录', 'readonly', [
|
|
relation('gasorder_basic_identity', '/gasorder_basic'),
|
|
f('request_no'), f('confirm_type'), f('recipient_name'), f('recipient_phone'),
|
|
f('proof_uri'), f('confirmed_at'), f('remark'),
|
|
]),
|
|
define('gasorder_payment', '支付记录', 'readonly', [
|
|
relation('gasorder_basic_identity', '/gasorder_basic'),
|
|
relation('payment_order_identity', '/payment_order'),
|
|
f('attempt_no'), f('amount'),
|
|
]),
|
|
|
|
define('ec_category', '商品分类', 'writable', [relation('parent_identity', '/ec_category'), f('name', { required: true }), f('sort_no')], 'tree'),
|
|
define('ec_product', '商品', 'writable', [relation('ec_category_identity', '/ec_category', true), f('product_code', { required: true }), f('name', { required: true }), f('price_amount', { required: true }), f('stock_quantity')]),
|
|
define('ec_product_attribute', '商品属性', 'writable', [relation('ec_product_identity', '/ec_product', true), f('name', { required: true }), f('value', { required: true }), f('sort_no')]),
|
|
define('ec_product_image', '商品图片', 'writable', [relation('ec_product_identity', '/ec_product', true), f('image_uri', { required: true }), f('sort_no'), f('is_cover')]),
|
|
define('ec_cart', '购物车', 'readonly', [
|
|
relation('user_account_identity', '/user_account', false, {
|
|
label: '用户', listLabel: '用户', listRelationNameOnly: true,
|
|
displayRelationLabel: true, showIdentityCopy: true,
|
|
}),
|
|
relation('ec_product_identity', '/ec_product', false, {
|
|
label: '商品', listLabel: '商品', listRelationNameOnly: true,
|
|
displayRelationLabel: true, showIdentityCopy: true,
|
|
}),
|
|
f('quantity'), f('selected'),
|
|
]),
|
|
define('ec_order', '商城订单', 'readonly', [
|
|
f('order_no'), f('request_no', { emptyText: '未记录' }), f('order_status', { type: 'select', options: [
|
|
{ label: '待支付', value: 16 },
|
|
{ label: '已支付', value: 18 },
|
|
{ label: '已取消', value: 22 },
|
|
], unknownValueLabel: '未知订单状态' }),
|
|
relation('user_account_identity', '/user_account', false, {
|
|
label: '用户', listLabel: '用户', listRelationNameOnly: true,
|
|
displayRelationLabel: true, showIdentityCopy: true,
|
|
}), relation('gas_basic_identity', '/gas_basic'),
|
|
relation('delivery_basic_identity', '/delivery_basic'), relation('user_address_identity', '/user_address'),
|
|
f('contact_name', { emptyText: '未记录' }), f('contact_phone', { emptyText: '未记录' }),
|
|
f('product_amount'), f('discount_amount'), f('payable_amount'),
|
|
f('total_amount'), f('paid_at', { emptyText: '未支付' }),
|
|
f('logistics_no', { emptyText: '未发货' }), f('logistics_company', { emptyText: '未发货' }),
|
|
f('logistics_status'), f('shipped_at', { emptyText: '未发货' }),
|
|
f('received_at', { emptyText: '未收货' }), f('remark', { emptyText: '无备注' }),
|
|
]),
|
|
define('ec_order_item', '商城订单明细', 'readonly', [
|
|
relation('ec_order_identity', '/ec_order'), relation('ec_product_identity', '/ec_product'),
|
|
f('product_snapshot'), f('quantity'), f('sale_amount'),
|
|
]),
|
|
define('ec_review', '商品评价', 'readonly', [
|
|
relation('ec_order_identity', '/ec_order'), relation('ec_product_identity', '/ec_product'),
|
|
relation('user_account_identity', '/user_account'), f('score'), f('content'),
|
|
]),
|
|
|
|
define('wallet_basic', '钱包', 'readonly', [f('owner_type'), f('owner_identity', {
|
|
type: 'identity', label: '归属主体', listRelationNameOnly: true,
|
|
displayRelationLabel: true, showIdentityCopy: true,
|
|
dynamicRelation: {
|
|
parentKey: 'owner_type', parentLabel: '归属类型',
|
|
resources: { user: '/user_account', staff: '/staff_account', gas: '/gas_basic', delivery: '/delivery_basic' },
|
|
},
|
|
}), f('alipay_id'), f('alipay_name'), f('wxpay_id'), f('wxpay_name'), f('balance'), f('withdrawal_balance')], 'list', [
|
|
{ name: '后台充值', resource: '/wallet_basic/:identity/recharge', fields: [f('request_no', { required: true }), f('amount', { required: true }), f('withdrawable'), ...reason, f('remark')] },
|
|
{ name: '修改钱包状态', resource: '/wallet_basic/:identity/status', method: 'PATCH', fields: [f('status', { required: true, type: 'select', options: [{ label: '启用', value: 1 }, { label: '停用', value: 2 }, { label: '冻结', value: 4 }] })] },
|
|
]),
|
|
define('wallet_bank', '银行卡', 'readonly', [
|
|
relation('wallet_basic_identity', '/wallet_basic'), f('bank_name'), f('card_owner'),
|
|
f('card_no_last4'), f('bind_id'), f('bank_type'), f('bank'),
|
|
]),
|
|
define('payment_order', '钱包支付记录', 'readonly', [
|
|
f('payment_no'), f('request_no'), f('payment_status'), f('business_type'),
|
|
f('business_identity', { type: 'identity', label: '业务对象', listRelationNameOnly: true, displayRelationLabel: true, showIdentityCopy: true, dynamicRelation: {
|
|
parentKey: 'business_type', parentLabel: '业务类型', resources: { gasorder: '/gasorder_basic', ec_order: '/ec_order' },
|
|
} }), relation('user_identity', '/user_account'), f('merchant_identity'), f('channel'), f('pay_type'),
|
|
f('channel_trade_no'), f('amount'), f('subject'), f('failure_code'), f('failure_message'),
|
|
f('expires_at'), f('paid_at'), f('closed_at'),
|
|
]),
|
|
define('wallet_record', '钱包流水', 'readonly', [
|
|
relation('wallet_basic_identity', '/wallet_basic'), f('record_no'), f('request_no'),
|
|
f('direction'), f('trade_type'), f('amount'), f('fee'), f('balance_after'),
|
|
f('withdrawal_balance_after'), f('in_trade_no'), f('out_trade_no'), f('pay_channel'),
|
|
f('pay_type'), relation('related_record_identity', '/wallet_record'), f('operator_name'),
|
|
f('operator_identity'), f('ymd'), f('ym'), f('remark'),
|
|
]),
|
|
define('payment_refund', '退款审核', 'readonly', [
|
|
f('refund_no'), f('business_type'), f('business_identity', { type: 'identity', label: '业务对象', listRelationNameOnly: true, displayRelationLabel: true, showIdentityCopy: true, dynamicRelation: {
|
|
parentKey: 'business_type', parentLabel: '业务类型', resources: { gasorder: '/gasorder_basic', ec_order: '/ec_order' },
|
|
} }), relation('user_identity', '/user_account'),
|
|
f('amount'), f('reason'), f('description'), f('refund_status'),
|
|
relation('reviewer_identity', '/platform_account'), f('review_remark'), f('reviewed_at'), f('completed_at'),
|
|
], 'list', [
|
|
{ name: '审核通过并退入钱包', resource: '/payment_refund/:identity/approve', fields: [f('remark')], visibleFor: { field: 'refund_status', values: [10] } },
|
|
{ name: '驳回退款', resource: '/payment_refund/:identity/reject', danger: true, fields: [f('remark', { required: true })], visibleFor: { field: 'refund_status', values: [10] } },
|
|
], { canCreate: false, canEdit: false, canChangeStatus: false, canArchive: false }),
|
|
define('wallet_apply_cash', '提现记录', 'readonly', [
|
|
f('cash_no'),
|
|
f('wallet_basic_identity', { type: 'identity' }),
|
|
f('amount'),
|
|
f('apply_status', { type: 'select', options: [
|
|
{ label: '待处理', value: 10 },
|
|
{ label: '已通过', value: 25 },
|
|
{ label: '已驳回', value: 26 },
|
|
{ label: '已完成', value: 23 },
|
|
] }),
|
|
f('reviewer_name'),
|
|
f('review_reason'),
|
|
f('reviewed_at'),
|
|
f('completed_at'),
|
|
f('channel'),
|
|
f('trade_no'),
|
|
f('remark'),
|
|
], 'list', [
|
|
{ name: '审核通过', resource: '/wallet_apply_cash/:identity/approve', fields: reason, visibleFor: { field: 'apply_status', values: [10] } },
|
|
{ name: '审核驳回', resource: '/wallet_apply_cash/:identity/reject', danger: true, fields: reason, visibleFor: { field: 'apply_status', values: [10] } },
|
|
{ name: '标记处理完成', resource: '/wallet_apply_cash/:identity/complete', fields: [f('trade_no', { required: true }), f('callback_msg')], visibleFor: { field: 'apply_status', values: [25] } },
|
|
]),
|
|
|
|
define('fin_payment', '财务支付记录', 'readonly', [
|
|
relation('ec_order_identity', '/ec_order'), f('payment_status'), f('channel'), f('amount'), f('paid_at'),
|
|
]),
|
|
define('fin_settlement', '财务结算', 'writable', [f('settlement_no', { required: true }), f('subject_type', { required: true }), f('subject_identity', {
|
|
required: true, type: 'identity', label: '结算主体', listRelationNameOnly: true,
|
|
displayRelationLabel: true, showIdentityCopy: true,
|
|
dynamicRelation: {
|
|
parentKey: 'subject_type', parentLabel: '结算主体类型',
|
|
resources: { gas: '/gas_basic', delivery: '/delivery_basic' },
|
|
},
|
|
}), f('period_start', { required: true }), f('period_end', { required: true })]),
|
|
define('fin_reconciliation', '财务对账', 'readonly', [
|
|
f('reconciliation_status'), f('channel'), f('bill_date'), f('difference_amount'),
|
|
]),
|
|
define('cms_content', '内容', 'writable', [f('content_type', { required: true }), f('title', { required: true }), f('body', { required: true }), f('version_no'), f('publish_status')]),
|
|
define('cs_ticket', '客服工单', 'writable', [relation('user_account_identity', '/user_account', true), f('ticket_no', { required: true }), f('category', { required: true }), f('priority', { required: true })]),
|
|
define('platform_account', '平台账户', 'writable', [f('username', { required: true }), f('password', { required: true }), f('display_name'), f('avatar'), f('platform_role_code', { required: true, unknownValueLabel: '未知角色' }), f('phone')]),
|
|
define('platform_role', '平台角色', 'writable', [f('role_code', { required: true }), f('name', { required: true }), f('location_scope', { required: true, type: 'select', options: resourceSearchEnumOptions('platform_role', 'location_scope') })], 'list', [
|
|
{ name: '分配菜单', resource: '/platform_role/:identity/menu', method: 'PUT', fields: [f('menu_identities', { type: 'identity-list', relation: '/platform_menu' })] },
|
|
]),
|
|
define('platform_menu', '平台菜单', 'readonly', [
|
|
relation('parent_identity', '/platform_menu'), f('group_code'), f('name'), f('icon'),
|
|
f('path'), f('sort_no'),
|
|
], 'tree'),
|
|
];
|
|
|
|
export const resourceByPath = Object.fromEntries(
|
|
resources.map((definition) => [definition.resource, definition]),
|
|
) as Record<string, ResourceUiDefinition>;
|
|
|
|
export function getResource(resourcePath: string): ResourceUiDefinition {
|
|
const definition = resourceByPath[resourcePath];
|
|
if (!definition) throw new Error(`未知资源:${resourcePath}`);
|
|
return definition;
|
|
}
|
|
|
|
/** 返回动态关系字段当前应使用的资源;父值为空或未知时返回空字符串。 */
|
|
export function dynamicRelationResource(
|
|
field: ResourceField,
|
|
values: Record<string, unknown>,
|
|
) {
|
|
const dynamic = field.dynamicRelation;
|
|
if (!dynamic) return field.relation ?? '';
|
|
const parentValue = String(values[dynamic.parentKey] ?? '').trim();
|
|
return dynamic.resources[parentValue] ?? '';
|
|
}
|