完善订单金额调整上下文

This commit is contained in:
czl231
2026-08-29 22:29:15 +08:00
parent 965e12cbcc
commit 9bbe25fa79
7 changed files with 97 additions and 4 deletions

View File

@@ -67,6 +67,7 @@ assert(routeKeys.has('POST /gasorder_contract/attachment/upload'), '配送合同
assert(routeKeys.has('POST /gasorder_contract/attachment/cleanup'), '配送合同缺少临时附件清理接口');
assert(routeKeys.has('GET /gasorder_contract/:identity/attachment'), '配送合同缺少受控附件读取接口');
const recordPage = read('src/views/resource/ResourceRecordPage.vue');
const actionDialog = read('src/views/resource/ResourceActionDialog.vue');
assert(recordPage.includes('ResourceAccountSummary'), '账户资源页尚未接入 5173 头像摘要卡片');
assert(recordPage.includes("field.key !== 'avatar'"), '头像字段仍可能显示为普通文本框');
const listPage = read('src/views/shared/ResourceListPage.vue');
@@ -142,5 +143,9 @@ assert(definitions.includes("listDisplayKey: 'address'"), '订单列表收货地
assert(definitions.includes("listDisplayKey: 'contract_products_summary'"), '订单列表合同气瓶未使用可读摘要');
assert(listPage.includes('function displayListField'), '资源列表未支持后端派生展示字段');
assert(listPage.includes('field.listDetailLink'), '订单气瓶摘要缺少详情入口');
assert(definitions.includes("actionContextKey: 'delivery_fee'"), '调整金额未读取当前配送费上下文');
assert(definitions.includes("actionContextKey: 'discount_amount'"), '调整金额未读取当前优惠金额上下文');
assert(recordPage.includes(':context-record="record"'), '业务动作弹窗未接收当前详情记录');
assert(actionDialog.includes("field.type !== 'money'"), '金额动作上下文缺少分转元处理');
console.log(`独立资源页面契约通过:详情 ${listResources.length},新建 ${creatable.size},编辑 ${editable.size}`);

View File

@@ -1,6 +1,6 @@
/**
* 功能描述:定义配送点后台资源能力、字段契约和受控业务动作。
* 版本v1.1.0。
* 版本v1.2.0。
*/
import { resourceSearchFields, type ResourceSearchField } from './resource-search-contract';
@@ -67,6 +67,8 @@ export type ResourceField = {
min?: number;
options?: Array<{ label: string; value: string | number; disabled?: boolean }>;
defaultValue?: string | number | boolean;
/** 业务动作弹窗从当前详情记录读取初始值的字段键。 */
actionContextKey?: string;
readonly?: boolean;
unknownValueLabel?: string;
};
@@ -608,7 +610,7 @@ const deliveryOverrides: ResourceUiDefinition[] = [
], 'list', [
{ name: '分配/改派', resource: '/gasorder_basic/:identity/assign', fields: [relation('staff_account_identity', '/staff_account', true), ...reason], visibleFor: { field: 'order_status', values: [16, 18] } },
{ name: '回收任务', resource: '/gasorder_basic/:identity/reclaim', danger: true, fields: reason, visibleFor: { field: 'order_status', values: [18] } },
{ name: '调整金额', resource: '/gasorder_basic/:identity/adjust-amount', fields: [f('delivery_fee', { required: true }), f('discount_amount', { required: true }), ...reason], visibleFor: { field: 'order_status', values: [16, 18] } },
{ name: '调整金额', resource: '/gasorder_basic/:identity/adjust-amount', fields: [f('delivery_fee', { required: true, actionContextKey: 'delivery_fee' }), f('discount_amount', { required: true, actionContextKey: 'discount_amount' }), ...reason], visibleFor: { field: 'order_status', values: [16, 18] } },
{ name: '标记异常', resource: '/gasorder_basic/:identity/exception', fields: reason, visibleFor: { field: 'order_status', values: [18, 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] } },

View File

@@ -1,4 +1,4 @@
<!-- 功能描述承载独立详情页的状态审核和专用业务动作版本v1.0.0 -->
<!-- 功能描述承载独立详情页的状态审核和专用业务动作版本v1.1.0 -->
<template>
<a-modal
:visible="visible"
@@ -37,6 +37,7 @@ const props = defineProps<{
action?: DetailAction;
identity: string;
currentStatus?: number;
contextRecord?: ResourceRow;
relationOptions: Record<string, ResourceRow[]>;
relationLoading: Record<string, boolean>;
}>();
@@ -54,7 +55,7 @@ watch(
if (!visible || !action) return;
for (const key of Object.keys(form)) delete form[key];
for (const field of action.fields ?? [])
form[field.key] = field.defaultValue;
form[field.key] = actionInitialValue(field);
if (
action.resource.endsWith('/:identity/status') &&
[1, 2].includes(Number(props.currentStatus))
@@ -64,6 +65,17 @@ watch(
{ immediate: true },
);
/** 从当前详情记录读取动作初始值;金额由服务端“分”转换为输入框使用的“元”。 */
function actionInitialValue(field: ResourceField) {
if (field.defaultValue !== undefined) return field.defaultValue;
if (!field.actionContextKey) return undefined;
const value = props.contextRecord?.[field.actionContextKey];
if (value == null || value === '') return undefined;
if (field.type !== 'money') return value;
const cents = Number(value);
return Number.isFinite(cents) ? cents / 100 : undefined;
}
/** 校验并执行当前业务动作。 */
async function submit() {
const action = props.action;

View File

@@ -147,6 +147,7 @@
:action="activeAction"
:identity="identity"
:current-status="Number(record.status)"
:context-record="record"
:relation-options="relationOptions"
:relation-loading="relationLoading"
@search-relation="searchRelation"