chore(shipping-notice): 统一货代发货生命周期阶段命名并优化全链路业务逻辑
This commit is contained in:
1 parent
5ef8329bd8
commit
4ec4e57005
183 files changed
+14653
-3936
No files matched your search
@@ -5,7 +5,10 @@
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { ShippingProcessingProjection } from '@/features/chat/types/shipping.api.types';
|
||||
import { resolveProcessingActionPresentation } from './actionPresentation';
|
||||
import {
|
||||
resolveConversationTaskActionPresentation,
|
||||
resolveProcessingActionPresentation,
|
||||
} from './actionPresentation';
|
||||
|
||||
function projection(
|
||||
overrides: Partial<ShippingProcessingProjection> = {},
|
||||
@@ -40,6 +43,23 @@ function projection(
|
||||
}
|
||||
|
||||
describe('resolveProcessingActionPresentation', () => {
|
||||
it('hides an internal edit_draft capability on the review surface', () => {
|
||||
const result = resolveProcessingActionPresentation({
|
||||
workItemType: 'order_intake',
|
||||
status: 'waiting_review',
|
||||
uiState: {
|
||||
status: 'waiting_human',
|
||||
primary_action: { code: 'edit_draft', i18nKey: null, parameters: {} },
|
||||
secondary_actions: [],
|
||||
},
|
||||
} as ShippingProcessingProjection, {
|
||||
surface: 'review',
|
||||
actionsExecutable: true,
|
||||
});
|
||||
|
||||
// edit_draft 是草稿编辑能力,不是当前任务 CTA;不能向用户渲染内部码。
|
||||
expect(result).toEqual({ primary: null, secondary: null, overflow: [] });
|
||||
});
|
||||
it('does not turn diagnostic gate nextActionCode into a user action', () => {
|
||||
const result = resolveProcessingActionPresentation(projection({
|
||||
currentGate: {
|
||||
@@ -79,6 +99,24 @@ describe('resolveProcessingActionPresentation', () => {
|
||||
expect(result.overflow).toEqual([]);
|
||||
});
|
||||
|
||||
it('uses the backend intake parse target for the navigation label', () => {
|
||||
const result = resolveProcessingActionPresentation(projection({
|
||||
uiState: {
|
||||
status: 'waiting_human', stage: 'intake_parse', lifecycleStage: 'intake_parse',
|
||||
lifecycleEntries: [], blocking_reason: null,
|
||||
primary_action: {
|
||||
code: 'open_order_review', i18nKey: 'action.open_order_review', parameters: {},
|
||||
executionMode: 'navigate', targetSurface: 'order_lifecycle_workbench',
|
||||
targetLifecycleStage: 'intake_parse',
|
||||
},
|
||||
secondary_actions: [],
|
||||
},
|
||||
}), { surface: 'right' });
|
||||
|
||||
// 后端目标为接收解析时,前端不得沿用“进入订单处理”的泛化文案。
|
||||
expect(result.primary?.labelKey).toBe('chat.shippingProcessing.action.open_intake_parse');
|
||||
});
|
||||
|
||||
it('does not revive a legacy primary action when authoritative ui_state explicitly has none', () => {
|
||||
const result = resolveProcessingActionPresentation(projection({
|
||||
primaryAction: { code: 'retry_parse', i18nKey: 'action.retry_parse', parameters: {} },
|
||||
@@ -159,10 +197,83 @@ describe('resolveProcessingActionPresentation', () => {
|
||||
expect(intentChain(order1)).toBe(intentChain(order2));
|
||||
});
|
||||
|
||||
it('maps open_order_review label to processing entry on chat surface', () => {
|
||||
it('keeps the primary order-review action semantic when it navigates to the lifecycle workbench', () => {
|
||||
const result = resolveProcessingActionPresentation(projection({
|
||||
availableActions: ['open_order_review'],
|
||||
}), { surface: 'chat' });
|
||||
expect(result.primary?.labelKey).toBe('chat.shippingProcessing.action.open_order_processing');
|
||||
// 工作台是执行位置;第一行必须说明当前要做的业务动作,而不是复用第二行阶段入口的总称。
|
||||
expect(result.primary?.labelKey).toBe('chat.shippingProcessing.action.open_order_review');
|
||||
});
|
||||
|
||||
it('does not reinterpret a backend view action as lifecycle authorization', () => {
|
||||
const result = resolveProcessingActionPresentation(projection({
|
||||
status: 'waiting_human',
|
||||
availableActions: ['view'],
|
||||
}), { surface: 'chat' });
|
||||
|
||||
// 生命周期入口必须由后端显式返回 open_order_review;view 只能保持查看语义。
|
||||
expect(result.primary).toMatchObject({ intent: 'view_result', actionCode: 'view' });
|
||||
});
|
||||
|
||||
it('preserves a backend-directed fulfillment preparation target for review navigation', () => {
|
||||
const result = resolveProcessingActionPresentation(projection({
|
||||
uiState: {
|
||||
status: 'waiting_human', stage: 'inventory_matching', blocking_reason: null,
|
||||
primary_action: {
|
||||
code: 'view_result',
|
||||
targetLifecycleStage: 'fulfillment_prep',
|
||||
targetSurface: 'order_lifecycle_workbench',
|
||||
},
|
||||
secondary_actions: [],
|
||||
},
|
||||
}), { surface: 'review' });
|
||||
|
||||
expect(result.primary).toMatchObject({
|
||||
intent: 'view_result',
|
||||
targetLifecycleStage: 'fulfillment_prep',
|
||||
});
|
||||
});
|
||||
|
||||
it('preserves a backend-directed fulfillment target on a secondary action', () => {
|
||||
const result = resolveProcessingActionPresentation(projection({
|
||||
uiState: {
|
||||
status: 'waiting_human', stage: 'inventory_matching', blocking_reason: null,
|
||||
primary_action: null,
|
||||
secondary_actions: [{
|
||||
code: 'view_result', enabled: true,
|
||||
targetLifecycleStage: 'fulfillment_prep',
|
||||
targetSurface: 'order_lifecycle_workbench',
|
||||
executionMode: 'navigate',
|
||||
}],
|
||||
},
|
||||
}), { surface: 'right' });
|
||||
|
||||
// 次动作不能在展示层退化为无阶段目标的“最终结果查看”。
|
||||
expect(result.primary).toMatchObject({
|
||||
intent: 'view_result',
|
||||
targetLifecycleStage: 'fulfillment_prep',
|
||||
});
|
||||
});
|
||||
|
||||
it('preserves a backend-directed fulfillment target on a conversation task secondary action', () => {
|
||||
const result = resolveConversationTaskActionPresentation({
|
||||
task_no: 'SN-1', group: 'needs_action', status_label: 'waiting_human',
|
||||
uiState: {
|
||||
status: 'waiting_human', stage: 'inventory_matching', blocking_reason: null,
|
||||
primary_action: null,
|
||||
secondary_actions: [{
|
||||
code: 'view_result', enabled: true,
|
||||
targetLifecycleStage: 'fulfillment_prep',
|
||||
targetSurface: 'order_lifecycle_workbench',
|
||||
executionMode: 'navigate',
|
||||
}],
|
||||
},
|
||||
} as ShippingProcessingProjection['conversationProcessing']['statusGroups']['needs_action'][number]);
|
||||
|
||||
// 右侧会话任务与批次卡必须保留同一个后端授权目标。
|
||||
expect(result.primary).toMatchObject({
|
||||
intent: 'view_result',
|
||||
targetLifecycleStage: 'fulfillment_prep',
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -42,6 +42,7 @@ const ACTION_CODE_TO_INTENT: Record<string, ShippingProcessingActionIntent> = {
|
||||
open_shortage_review: 'open_shortage_review',
|
||||
upload_inventory_file: 'upload_inventory_file',
|
||||
retry_inventory_preparation: 'retry',
|
||||
retry_inventory_matching: 'open_inventory_match_review',
|
||||
retry: 'retry',
|
||||
retry_parse: 'retry',
|
||||
retry_failed_documents: 'retry',
|
||||
@@ -74,10 +75,6 @@ const ACTION_CODE_TO_INTENT: Record<string, ShippingProcessingActionIntent> = {
|
||||
};
|
||||
|
||||
const AUTOMATING_STATUSES = new Set(['processing', 'automating', 'queued']);
|
||||
const NEEDS_ACTION_STATUSES = new Set([
|
||||
'blocked', 'waiting_review', 'pending_review', 'waiting_human',
|
||||
'failed', 'reparse_failed', 'manual_upload_pending', 'upload_rpa_failed',
|
||||
]);
|
||||
/** 永不升为主 CTA 的动作码(仍可作次要/溢出)。 */
|
||||
const NEVER_PRIMARY_CODES = new Set(['cancel_task', 'cancel_run', 'view_details']);
|
||||
|
||||
@@ -94,18 +91,21 @@ export function mapActionCodeToIntent(code: string | null | undefined): Shipping
|
||||
|
||||
/**
|
||||
* 构建单个动作项。
|
||||
* 核心逻辑:默认 labelKey=action.{intent};chat/right 面改写订单处理 / 重试解析 / 查看进度。
|
||||
* 核心逻辑:默认 labelKey=action.{intent};chat/right 面只改写重试解析 / 查看进度。
|
||||
*/
|
||||
function toItem(
|
||||
code: string,
|
||||
intent: ShippingProcessingActionIntent,
|
||||
surface?: ActionPresentationSurface,
|
||||
targetLifecycleStage?: string | null,
|
||||
): ActionPresentationItem {
|
||||
let labelKey = `chat.shippingProcessing.action.${intent}`;
|
||||
const normalized = String(code || '').trim().toLowerCase();
|
||||
const chatOrRight = surface === 'chat' || surface === 'right';
|
||||
if (intent === 'open_order_review' && chatOrRight) {
|
||||
labelKey = 'chat.shippingProcessing.action.open_order_processing';
|
||||
// 后端明确指定接收解析 surface 时,文案必须与目标一致;不能因复用同一
|
||||
// 只读导航动作码而误显示为订单处理。该分支不改变权限或路由目标。
|
||||
if (targetLifecycleStage === 'intake_parse') {
|
||||
labelKey = 'chat.shippingProcessing.action.open_intake_parse';
|
||||
} else if (normalized === 'retry_inventory_preparation') {
|
||||
labelKey = 'workspace.shippingNotice.processGate.actionCodes.retry_inventory_preparation';
|
||||
} else if (normalized === 'retry_freight_upload_rpa' || normalized === 'retry_upload') {
|
||||
@@ -123,6 +123,12 @@ function toItem(
|
||||
intent,
|
||||
actionCode: code,
|
||||
labelKey,
|
||||
targetLifecycleStage: (
|
||||
targetLifecycleStage === 'intake_parse'
|
||||
|| targetLifecycleStage === 'order_review'
|
||||
|| targetLifecycleStage === 'fulfillment_prep'
|
||||
|| targetLifecycleStage === 'upload_complete'
|
||||
) ? targetLifecycleStage : null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -192,7 +198,10 @@ export function resolveProcessingActionPresentation(
|
||||
const items: ActionPresentationItem[] = [];
|
||||
const seen = new Set<string>();
|
||||
|
||||
const pushCode = (raw: string | null | undefined) => {
|
||||
const pushCode = (
|
||||
raw: string | null | undefined,
|
||||
targetLifecycleStage?: string | null,
|
||||
) => {
|
||||
const code = String(raw || '').trim();
|
||||
if (!code) return;
|
||||
const key = code.toLowerCase();
|
||||
@@ -200,10 +209,8 @@ export function resolveProcessingActionPresentation(
|
||||
if (key === 'regenerate_manual_upload_todo') return;
|
||||
if (seen.has(key)) return;
|
||||
seen.add(key);
|
||||
// 识别/建单失败的 view 是进入当前 Case 处理;已完成任务才打开只读结果。
|
||||
const intent = key === 'view' && NEEDS_ACTION_STATUSES.has(status)
|
||||
? 'open_order_review'
|
||||
: mapActionCodeToIntent(code);
|
||||
// [AUTHORITY] view 仅表示查看;生命周期入口必须由后端显式下发 open_order_review。
|
||||
const intent = mapActionCodeToIntent(code);
|
||||
if (!intent || intent === 'none') {
|
||||
// [fail-closed] 未知动作不渲染原始码,仅告警。
|
||||
warnUnregisteredWorkbenchAction({
|
||||
@@ -232,7 +239,16 @@ export function resolveProcessingActionPresentation(
|
||||
return;
|
||||
}
|
||||
}
|
||||
items.push(toItem(code, intent, surface));
|
||||
items.push(toItem(
|
||||
code,
|
||||
intent,
|
||||
surface,
|
||||
targetLifecycleStage ?? (
|
||||
authoritativeUiState?.primary_action?.code === code
|
||||
? authoritativeUiState.primary_action.targetLifecycleStage
|
||||
: null
|
||||
),
|
||||
));
|
||||
};
|
||||
|
||||
// [AUTHORITY] 新版只消费同一份 ui_state;currentGate 只保留诊断,禁止产生或替换按钮。
|
||||
@@ -244,7 +260,8 @@ export function resolveProcessingActionPresentation(
|
||||
? authoritativeUiState.secondary_actions.filter((action) => action.enabled).map((action) => action.code)
|
||||
: normalizeActionCodes(projection.availableActions || []);
|
||||
for (const action of actionCodes) {
|
||||
pushCode(action);
|
||||
const secondary = authoritativeUiState?.secondary_actions.find((item) => item.code === action);
|
||||
pushCode(action, secondary?.targetLifecycleStage);
|
||||
}
|
||||
// Gate 19 RPA 失败时,人工登记作为任务级替代路径展示,避免与 RPA 重试并列。
|
||||
return partitionActionItems(items);
|
||||
@@ -268,7 +285,6 @@ export function resolveConversationTaskActionPresentation(
|
||||
const userStatus = String(task.uiState?.status ?? task.userStatus ?? '').trim().toLowerCase();
|
||||
const legacyStatus = String(task.status_label ?? '').trim().toLowerCase();
|
||||
const status = userStatus || legacyStatus;
|
||||
const isNeedsAction = task.group === 'needs_action' || NEEDS_ACTION_STATUSES.has(status);
|
||||
const isProcessing = task.group === 'processing' || AUTOMATING_STATUSES.has(status);
|
||||
if (task.group === 'history' || status === 'cancelled') {
|
||||
return empty;
|
||||
@@ -276,22 +292,27 @@ export function resolveConversationTaskActionPresentation(
|
||||
const items: ActionPresentationItem[] = [];
|
||||
const seen = new Set<string>();
|
||||
|
||||
const pushCode = (raw: string | null | undefined) => {
|
||||
const pushCode = (
|
||||
raw: string | null | undefined,
|
||||
targetLifecycleStage?: string | null,
|
||||
) => {
|
||||
const code = String(raw || '').trim();
|
||||
if (!code) return;
|
||||
const key = code.toLowerCase();
|
||||
if (seen.has(key)) return;
|
||||
const intent = key === 'view' && isNeedsAction
|
||||
? 'open_order_review'
|
||||
: mapActionCodeToIntent(code);
|
||||
// 任务卡同样禁止通过“待处理 + view”补造订单生命周期权限。
|
||||
const intent = mapActionCodeToIntent(code);
|
||||
if (!intent || intent === 'none') return;
|
||||
seen.add(key);
|
||||
items.push(toItem(code, intent, surface));
|
||||
items.push(toItem(code, intent, surface, targetLifecycleStage));
|
||||
};
|
||||
|
||||
pushCode(task.uiState
|
||||
? task.uiState.primary_action?.code
|
||||
: (task.primaryAction?.code || task.primary_action));
|
||||
pushCode(
|
||||
task.uiState
|
||||
? task.uiState.primary_action?.code
|
||||
: (task.primaryAction?.code || task.primary_action),
|
||||
task.uiState?.primary_action?.targetLifecycleStage,
|
||||
);
|
||||
// [ORDER-STABLE] 对 available_actions 标准化排序,确保后端顺序变化不影响按钮渲染顺序。
|
||||
const normalizedTaskActions = normalizeActionCodes(
|
||||
task.uiState?.secondary_actions?.filter((item) => item.enabled).map((item) => item.code)
|
||||
@@ -299,7 +320,8 @@ export function resolveConversationTaskActionPresentation(
|
||||
|| [],
|
||||
);
|
||||
for (const action of normalizedTaskActions) {
|
||||
pushCode(action);
|
||||
const secondary = task.uiState?.secondary_actions.find((item) => item.code === action);
|
||||
pushCode(action, secondary?.targetLifecycleStage);
|
||||
}
|
||||
|
||||
const hasPrimaryCandidate = items.some(
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { ShippingProcessingProjection } from '@/features/chat/types/shipping.api.types';
|
||||
import { resolveShippingProcessingStatusLabel, shippingProcessingStageKey } from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import { resolveShippingProcessingReasonLabel, resolveShippingProcessingStageLabel, resolveShippingProcessingStatusLabel } from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import { buildProgressRangeHint, buildProgressWindow } from '../progressWindow';
|
||||
import { useProcessingActionPresentation } from '../composables/useProcessingActionPresentation';
|
||||
import type { ActionPresentationItem } from '../types';
|
||||
@@ -35,8 +35,8 @@ const currentNodes = computed(() => buildProgressWindow(props.projection, 'chat'
|
||||
* 当前阶段中性名称。
|
||||
*/
|
||||
const currentStageLabel = computed(() => {
|
||||
const key = rangeHint.value?.currentLabelKey || shippingProcessingStageKey(props.projection.stage);
|
||||
return te(key) ? t(key) : props.projection.stage;
|
||||
const labelKey = rangeHint.value?.currentLabelKey || null;
|
||||
return resolveShippingProcessingStageLabel(props.projection.stage, te, t, labelKey);
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -59,10 +59,15 @@ const summaryLine = computed(() => {
|
||||
* Gate 阻断原因文案。
|
||||
*/
|
||||
const blockerLabel = computed(() => {
|
||||
const code = String(props.projection.currentGate?.blockingReasonCode || '').trim();
|
||||
if (!code) return '';
|
||||
const key = `workspace.shippingNotice.workflowReasons.${code}`;
|
||||
return te(key) ? t(key) : code;
|
||||
return resolveShippingProcessingReasonLabel(
|
||||
props.projection.uiState
|
||||
? props.projection.uiState.blocking_reason
|
||||
: props.projection.blockingReason || {
|
||||
code: props.projection.currentGate?.blockingReasonCode || null,
|
||||
},
|
||||
te,
|
||||
t,
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,8 +10,8 @@ import { useI18n } from 'vue-i18n';
|
||||
import { X } from 'lucide-vue-next';
|
||||
import type { ShippingProcessingProjection } from '@/features/chat/types/shipping.api.types';
|
||||
import {
|
||||
resolveShippingProcessingStageLabel,
|
||||
resolveShippingProcessingStatusLabel,
|
||||
shippingProcessingStageKey,
|
||||
} from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import {
|
||||
REVIEW_PROGRESS_DOMAIN_RANGES,
|
||||
@@ -70,8 +70,7 @@ const domainGroups = computed(() => (
|
||||
* 阶段名。
|
||||
*/
|
||||
function nodeLabel(node: ProgressWindowNode): string {
|
||||
const key = shippingProcessingStageKey(node.stage);
|
||||
return te(key) ? t(key) : node.stage;
|
||||
return resolveShippingProcessingStageLabel(node.stage, te, t);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,7 +13,7 @@ import type {
|
||||
ShippingProcessingProjection,
|
||||
ShippingProcessingStageNodeStatus,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
import { shippingProcessingStageKey } from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import { resolveShippingProcessingStageLabel } from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import { buildProgressRangeHint } from '../progressWindow';
|
||||
import {
|
||||
readAuthoritativeStageNodes,
|
||||
@@ -135,8 +135,7 @@ const currentNeedLabel = computed<string | null>(() => {
|
||||
const currentStageName = computed(() => {
|
||||
const stage = String(authoritativeUiState.value?.stage || props.projection.stage || '').trim();
|
||||
if (!stage) return '—';
|
||||
const key = shippingProcessingStageKey(stage);
|
||||
return te(key) ? t(key) : stage;
|
||||
return resolveShippingProcessingStageLabel(stage, te, t);
|
||||
});
|
||||
|
||||
watch(
|
||||
@@ -168,8 +167,7 @@ function nodeToneClass(status: ShippingProcessingStageNodeStatus, isCurrent: boo
|
||||
* 节点展示短标签(允许两行,不再截断到 4 字硬砍)。
|
||||
*/
|
||||
function nodeShortLabel(stage: string): string {
|
||||
const key = shippingProcessingStageKey(stage);
|
||||
return te(key) ? t(key) : stage;
|
||||
return resolveShippingProcessingStageLabel(stage, te, t);
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -248,7 +246,7 @@ function nodeShortLabel(stage: string): string {
|
||||
:data-stage="node.stage"
|
||||
:data-status="node.status"
|
||||
:data-current="node.stage === projection.stage ? '1' : '0'"
|
||||
:title="te(shippingProcessingStageKey(node.stage)) ? t(shippingProcessingStageKey(node.stage)) : node.stage"
|
||||
:title="resolveShippingProcessingStageLabel(node.stage, te, t)"
|
||||
>
|
||||
<div class="font-semibold">{{ node.absoluteIndex + 1 }}</div>
|
||||
<div class="line-clamp-2 break-words">{{ nodeShortLabel(node.stage) }}</div>
|
||||
@@ -275,7 +273,7 @@ function nodeShortLabel(stage: string): string {
|
||||
:data-stage="node.stage"
|
||||
:data-status="node.status"
|
||||
:data-current="node.stage === projection.stage ? '1' : '0'"
|
||||
:title="te(shippingProcessingStageKey(node.stage)) ? t(shippingProcessingStageKey(node.stage)) : node.stage"
|
||||
:title="resolveShippingProcessingStageLabel(node.stage, te, t)"
|
||||
>
|
||||
<div class="font-semibold">{{ node.absoluteIndex + 1 }}</div>
|
||||
<div class="line-clamp-2 break-words">{{ nodeShortLabel(node.stage) }}</div>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { ShippingProcessingProjection } from '@/features/chat/types/shipping.api.types';
|
||||
import { resolveShippingProcessingStatusLabel, shippingProcessingStageKey } from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import { resolveShippingProcessingStageLabel, resolveShippingProcessingStatusLabel } from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import { useProcessingActionPresentation } from '../composables/useProcessingActionPresentation';
|
||||
import type { ActionPresentationItem } from '../types';
|
||||
import { resolveGateReasonLabel } from '../gateReasonLabel';
|
||||
@@ -36,8 +36,7 @@ const actionPresentation = useProcessingActionPresentation(projectionRef, { surf
|
||||
*/
|
||||
const inlineLine = computed(() => {
|
||||
const stage = props.projection.uiState?.stage || props.projection.userStage || props.projection.stage;
|
||||
const stageKey = shippingProcessingStageKey(stage);
|
||||
const stageLabel = te(stageKey) ? t(stageKey) : stage;
|
||||
const stageLabel = resolveShippingProcessingStageLabel(stage, te, t);
|
||||
return `● ${stageLabel}`;
|
||||
});
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { ShippingProcessingProjection } from '@/features/chat/types/shipping.api.types';
|
||||
import { shippingProcessingStageKey } from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import { resolveShippingProcessingStageLabel } from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import { buildProgressWindow } from '../progressWindow';
|
||||
import { useProgressDensity } from '../composables/useProgressDensity';
|
||||
import type { ProgressDensity, ProgressWindowNode } from '../types';
|
||||
@@ -30,8 +30,7 @@ const nodes = computed(() => buildProgressWindow(props.projection, densityRef.va
|
||||
* 节点展示文案。
|
||||
*/
|
||||
function nodeLabel(node: ProgressWindowNode): string {
|
||||
const key = shippingProcessingStageKey(node.stage);
|
||||
return te(key) ? t(key) : node.stage;
|
||||
return resolveShippingProcessingStageLabel(node.stage, te, t);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<!--
|
||||
features/shipping-progress/components/WorkbenchProgressGrouped.vue
|
||||
用途:任务台四阶段进度——接收解析 / 订单复核 / 发货准备 / 上传完成;可选动作栏。
|
||||
用途:任务台四阶段进度——接收解析 / 订单复核 / 通知准备 / 通知完成;可选动作栏。
|
||||
依赖:vue-i18n、ShippingProcessingProjection、UnifiedProgressTrack、UnifiedActionBar。
|
||||
逻辑:由 ShippingTaskWorkbench 挂载;任务台履约动作归 TaskTodoPanel,默认关闭本组件动作栏(UI-05)。
|
||||
-->
|
||||
@@ -8,18 +8,25 @@
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { ShippingProcessingProjection } from '@/features/chat/types/shipping.api.types';
|
||||
import { shippingProcessingStageKey } from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import { resolveShippingProcessingStageLabel } from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import { useProcessingActionPresentation } from '../composables/useProcessingActionPresentation';
|
||||
import type { ActionPresentationItem } from '../types';
|
||||
import UnifiedActionBar from './UnifiedActionBar.vue';
|
||||
import UnifiedProgressTrack from './UnifiedProgressTrack.vue';
|
||||
|
||||
type FourStageNode = {
|
||||
code: 'intake_parse' | 'order_review' | 'fulfillment_prep' | 'upload_complete';
|
||||
status: 'passed' | 'running' | 'blocked' | 'pending';
|
||||
};
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
projection: ShippingProcessingProjection;
|
||||
/** 是否渲染投影动作栏;任务台内嵌时应为 false,避免与 TaskTodoPanel 双入口。 */
|
||||
showActions?: boolean;
|
||||
/** 是否允许展开技术 15 节点;批次中心只展示业务四阶段。 */
|
||||
showTechnicalDetail?: boolean;
|
||||
/** 后端已折叠的四阶段节点;缺失时 fail-closed,不从 15 阶重算。 */
|
||||
fourStageNodes?: FourStageNode[] | null;
|
||||
}>(), {
|
||||
showActions: true,
|
||||
showTechnicalDetail: true,
|
||||
@@ -34,34 +41,26 @@ const showDetailTrack = ref(false);
|
||||
|
||||
const projectionRef = computed(() => props.projection);
|
||||
const actionPresentation = useProcessingActionPresentation(projectionRef, { surface: 'workbench' });
|
||||
const DOMAIN_RANGES = [
|
||||
{ key: 'intake_parse', label: '接收解析', stages: ['upload_received', 'email_parsing', 'email_adjudicating', 'document_parsing', 'candidate_creating'] },
|
||||
{ key: 'order_review', label: '订单复核', stages: ['order_creating', 'review_required', 'waiting_review'] },
|
||||
{ key: 'fulfillment_prep', label: '发货准备', stages: ['inventory_fetching', 'inventory_matching', 'excel_generating'] },
|
||||
{ key: 'upload_complete', label: '上传完成', stages: ['freight_uploading', 'completed'] },
|
||||
] as const;
|
||||
const DOMAIN_LABELS: Record<FourStageNode['code'], string> = {
|
||||
intake_parse: '接收解析',
|
||||
order_review: '订单复核',
|
||||
fulfillment_prep: '通知准备',
|
||||
upload_complete: '通知完成',
|
||||
};
|
||||
|
||||
// 四阶段是后端从正式 Gate/work_items 裁决后的业务投影;这里不再由 15 阶技术节点聚合。
|
||||
const domainSummaries = computed(() => Array.isArray(props.fourStageNodes) ? props.fourStageNodes : []);
|
||||
|
||||
/**
|
||||
* 判断某域是否为当前/已过/未到。
|
||||
*/
|
||||
function domainState(index: number): 'passed' | 'current' | 'pending' {
|
||||
const currentStage = String(
|
||||
props.projection.uiState?.stage || props.projection.userStage || props.projection.stage || '',
|
||||
).trim();
|
||||
const currentIndex = DOMAIN_RANGES.findIndex((domain) => (
|
||||
(domain.stages as readonly string[]).includes(currentStage)
|
||||
));
|
||||
if (index < currentIndex) return 'passed';
|
||||
if (index === currentIndex || (currentIndex < 0 && index === 0)) return 'current';
|
||||
return 'pending';
|
||||
}
|
||||
|
||||
/**
|
||||
* 域标签样式。
|
||||
*/
|
||||
function domainClass(state: 'passed' | 'current' | 'pending'): string {
|
||||
function domainClass(state: FourStageNode['status']): string {
|
||||
if (state === 'passed') return 'border-emerald-200 bg-emerald-50 text-emerald-800';
|
||||
if (state === 'current') return 'border-brand-300 bg-brand-50 text-brand-800';
|
||||
if (state === 'blocked') return 'border-amber-300 bg-amber-50 text-amber-900';
|
||||
if (state === 'running') return 'border-brand-300 bg-brand-50 text-brand-800';
|
||||
return 'border-default bg-surface text-muted';
|
||||
}
|
||||
|
||||
@@ -70,8 +69,7 @@ function domainClass(state: 'passed' | 'current' | 'pending'): string {
|
||||
*/
|
||||
const currentStageLabel = computed(() => {
|
||||
const stage = props.projection.uiState?.stage || props.projection.userStage || props.projection.stage;
|
||||
const key = shippingProcessingStageKey(stage);
|
||||
return te(key) ? t(key) : stage;
|
||||
return resolveShippingProcessingStageLabel(stage, te, t);
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -86,14 +84,14 @@ const currentStageLabel = computed(() => {
|
||||
|
||||
<div class="grid gap-2 sm:grid-cols-4" data-testid="workbench-four-stage-track">
|
||||
<div
|
||||
v-for="(domain, index) in DOMAIN_RANGES"
|
||||
:key="domain.key"
|
||||
v-for="domain in domainSummaries"
|
||||
:key="domain.code"
|
||||
class="rounded-xl border px-3 py-2 text-xs font-semibold"
|
||||
:class="domainClass(domainState(index))"
|
||||
:data-domain="domain.key"
|
||||
:data-state="domainState(index)"
|
||||
:class="domainClass(domain.status)"
|
||||
:data-domain="domain.code"
|
||||
:data-state="domain.status"
|
||||
>
|
||||
{{ domain.label }}
|
||||
{{ DOMAIN_LABELS[domain.code] }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -178,10 +178,40 @@ describe('shipping progress presenters', () => {
|
||||
|
||||
it('mounts WorkbenchProgressGrouped with domain groups', () => {
|
||||
const wrapper = mount(WorkbenchProgressGrouped, {
|
||||
props: { projection },
|
||||
props: {
|
||||
projection,
|
||||
fourStageNodes: [
|
||||
{ code: 'intake_parse', status: 'passed' },
|
||||
{ code: 'order_review', status: 'blocked' },
|
||||
{ code: 'fulfillment_prep', status: 'pending' },
|
||||
{ code: 'upload_complete', status: 'pending' },
|
||||
],
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.find('[data-testid="workbench-progress-grouped"]').exists()).toBe(true);
|
||||
expect(wrapper.findAll('[data-domain]').length).toBe(4);
|
||||
});
|
||||
|
||||
it('uses backend four-stage nodes instead of the current technical stage', () => {
|
||||
const blockedProjection = {
|
||||
...projection,
|
||||
// stage 仍是早期解析节点;四阶段态必须以服务端折叠节点为准。
|
||||
stage: 'document_parsing',
|
||||
};
|
||||
const wrapper = mount(WorkbenchProgressGrouped, {
|
||||
props: {
|
||||
projection: blockedProjection,
|
||||
fourStageNodes: [
|
||||
{ code: 'intake_parse', status: 'passed' },
|
||||
{ code: 'order_review', status: 'passed' },
|
||||
{ code: 'fulfillment_prep', status: 'blocked' },
|
||||
{ code: 'upload_complete', status: 'pending' },
|
||||
],
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.get('[data-domain="fulfillment_prep"]').attributes('data-state')).toBe('blocked');
|
||||
expect(wrapper.get('[data-domain="intake_parse"]').attributes('data-state')).toBe('passed');
|
||||
});
|
||||
});
|
||||
@@ -23,6 +23,16 @@ describe('gateReasonLabel', () => {
|
||||
expect(resolveGateReasonLabel('customer_unresolved', i18n)).toBe('确认客户');
|
||||
});
|
||||
|
||||
it('resolveGateReasonLabel uses the existing Process Gate reason label', () => {
|
||||
const i18n = makeI18n({
|
||||
'workspace.shippingNotice.processGate.reasons.inventory_shortage_review_required': '存在库存缺口,需要人工处理',
|
||||
'chat.shippingProcessing.gateReasons.generic': '需要处理',
|
||||
});
|
||||
|
||||
// 当前任务卡和进度条必须共用该映射,不能把后端原因码直接展示给用户。
|
||||
expect(resolveGateReasonLabel('inventory_shortage_review_required', i18n)).toBe('存在库存缺口,需要人工处理');
|
||||
});
|
||||
|
||||
it('resolveCurrentNeedLabel uses blockingReasonCode first', () => {
|
||||
const i18n = makeI18n({
|
||||
'chat.shippingProcessing.gateReasons.customer_unresolved': '确认客户',
|
||||
|
||||
@@ -29,6 +29,7 @@ export function resolveGateReasonLabel(
|
||||
const keys = [
|
||||
`chat.shippingProcessing.gateReasons.${normalized}`,
|
||||
`workspace.shippingNotice.workflowReasons.${normalized}`,
|
||||
`workspace.shippingNotice.processGate.reasons.${normalized}`,
|
||||
];
|
||||
for (const key of keys) {
|
||||
if (i18n.te(key)) return i18n.t(key);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
import type {
|
||||
LifecycleWorkbenchStage,
|
||||
ShippingProcessingActionIntent,
|
||||
ShippingProcessingStage,
|
||||
ShippingProcessingStageNodeStatus,
|
||||
@@ -39,6 +40,8 @@ export interface ActionPresentationItem {
|
||||
actionCode: string;
|
||||
/** i18n 键优先 chat.shippingProcessing.action.* */
|
||||
labelKey: string;
|
||||
/** 后端明确下发的生命周期工作面目标;仅用于导航,不能由前端自行推断。 */
|
||||
targetLifecycleStage?: LifecycleWorkbenchStage | null;
|
||||
}
|
||||
|
||||
/** 统一动作投影:四页面只消费本结构拼按钮。 */
|
||||
|
||||
@@ -55,6 +55,7 @@ describe('workbenchActionRegistry', () => {
|
||||
for (const code of [
|
||||
'confirm_inventory_source',
|
||||
'match_inventory',
|
||||
'retry_inventory_matching',
|
||||
'generate_excel',
|
||||
'mark_manual_uploaded',
|
||||
'retry_upload',
|
||||
@@ -69,6 +70,8 @@ describe('workbenchActionRegistry', () => {
|
||||
expect(WORKBENCH_ACTION_REGISTRY.open_inventory_source_review.reviewBehavior).toBe('open_inventory_candidates');
|
||||
expect(WORKBENCH_ACTION_REGISTRY.confirm_inventory_source.reviewBehavior).toBe('todo_panel');
|
||||
expect(WORKBENCH_ACTION_REGISTRY.confirm_customer.reviewBehavior).toBe('open_customer_dialog');
|
||||
// 保存订单并校验只属于工作台底栏,不得注册为右栏当前任务动作。
|
||||
expect(WORKBENCH_ACTION_REGISTRY.validate).toBeUndefined();
|
||||
});
|
||||
|
||||
it('hides open_order_review / edit_formal_task / refresh on review surface', () => {
|
||||
@@ -110,6 +113,10 @@ describe('workbenchActionRegistry', () => {
|
||||
|
||||
it('exposes match_inventory as primary for review Footer', () => {
|
||||
const result = resolveProcessingActionPresentation(projection({
|
||||
uiState: {
|
||||
status: 'waiting_human', stage: 'inventory_matching', blocking_reason: null,
|
||||
primary_action: { code: 'match_inventory', label_key: 'x' }, secondary_actions: [],
|
||||
},
|
||||
currentGate: {
|
||||
gateCode: 'inventory_match',
|
||||
status: 'blocked',
|
||||
@@ -124,9 +131,35 @@ describe('workbenchActionRegistry', () => {
|
||||
expect(result.secondary).toBeNull();
|
||||
});
|
||||
|
||||
it('routes backend retry_inventory_matching through the formal Gate todo action', () => {
|
||||
const result = resolveProcessingActionPresentation(projection({
|
||||
uiState: {
|
||||
status: 'retryable', stage: 'inventory_matching', blocking_reason: null,
|
||||
primary_action: { code: 'retry_inventory_matching', label_key: 'x' }, secondary_actions: [],
|
||||
},
|
||||
currentGate: {
|
||||
gateCode: 'inventory_matching',
|
||||
status: 'blocked_retryable',
|
||||
nextActionCode: 'retry_inventory_matching',
|
||||
blockingReasonCode: 'inventory_match_failed',
|
||||
attemptNo: 1,
|
||||
},
|
||||
}), { surface: 'review', actionsExecutable: true });
|
||||
|
||||
expect(result.primary?.actionCode).toBe('retry_inventory_matching');
|
||||
const resolved = resolveWorkbenchActionItem(result.primary!, { postCreate: true });
|
||||
expect(resolved?.reviewBehavior).toBe('todo_panel');
|
||||
expect(resolved?.todoActionCode).toBe('retry_inventory_matching');
|
||||
});
|
||||
|
||||
it('shows RPA upload retry instead of manual upload entries when Gate 19 is blocked', () => {
|
||||
const result = resolveProcessingActionPresentation(projection({
|
||||
stage: 'freight_uploading',
|
||||
uiState: {
|
||||
status: 'retryable', stage: 'freight_uploading', blocking_reason: null,
|
||||
primary_action: { code: 'retry_freight_upload_rpa', label_key: 'x' },
|
||||
secondary_actions: [{ code: 'download_excel', enabled: true }],
|
||||
},
|
||||
currentGate: {
|
||||
gateCode: 'freight_upload_rpa',
|
||||
status: 'blocked',
|
||||
|
||||
@@ -191,6 +191,15 @@ export const WORKBENCH_ACTION_REGISTRY: Record<string, WorkbenchActionRegistryEn
|
||||
stageFamily: 'post_create',
|
||||
scrollTestId: 'review-formal-task-todo-panel',
|
||||
},
|
||||
retry_inventory_matching: {
|
||||
intent: 'open_inventory_match_review',
|
||||
reviewBehavior: 'todo_panel',
|
||||
todoActionCode: 'retry_inventory_matching',
|
||||
requiresFormalTask: true,
|
||||
isWrite: true,
|
||||
stageFamily: 'post_create',
|
||||
scrollTestId: 'review-formal-task-todo-panel',
|
||||
},
|
||||
open_shortage_review: {
|
||||
intent: 'open_shortage_review',
|
||||
reviewBehavior: 'focus_inventory_issues',
|
||||
|
||||
Reference in new issue
Block a user