完善订单金额调整上下文
This commit is contained in:
@@ -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] } },
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user