fix(shipping-recovery): 恢复库存RPA入口与门禁恢复流程

This commit is contained in:
hugo committed 2026-09-04 20:38:48 +08:00
1 parent eb55f407ae
commit 938f3dd0e8
8 files changed
+1329 -194

No files matched your search

@@ -14,10 +14,7 @@ import logging
from flask import current_app
from app import db
from app.models import (
ShippingNotice,
ShippingTaskInventoryRpaAttempt,
)
from app.models import ShippingOrderTask, ShippingTaskInventoryRpaAttempt
_LOGGER = logging.getLogger(__name__)
@@ -82,8 +79,8 @@ def _scan_stale_inventory_attempts(*, timeout_seconds: int) -> int:
total = 0
for task in (
ShippingNotice.query
.filter(ShippingNotice.task_no.in_(task_nos))
ShippingOrderTask.query
.filter(ShippingOrderTask.task_no.in_(task_nos))
.all()
):
try:
@@ -59,6 +59,7 @@ const api = vi.hoisted(() => ({
confirmCase: vi.fn(),
validateDraft: vi.fn(),
patchHeader: vi.fn(),
}));
@@ -89,7 +90,7 @@ vi.mock('../api/shipping.api', () => ({
confirmWorkspaceShippingOrderReviewCase: api.confirmCase,
patchWorkspaceShippingOrderReviewHeaderField: vi.fn(),
patchWorkspaceShippingOrderReviewHeaderField: api.patchHeader,
patchWorkspaceShippingOrderReviewLineField: vi.fn(),
@@ -135,7 +136,7 @@ const buildCase = (patch: Partial<ShippingOrderReviewCase> = {}): ShippingOrderR
header_values: {},
lines: [{ line_key: 'line-1' }],
lines: [{ draft_line_id: 'line-1' }],
issues: [],
@@ -149,7 +150,7 @@ const buildCase = (patch: Partial<ShippingOrderReviewCase> = {}): ShippingOrderR
line_projections: [{
line_key: 'line-1',
draft_line_id: 'line-1',
line_index: 0,
@@ -403,7 +404,7 @@ describe('useShippingOrderReview build eligibility writes', () => {
expect(review.canConfirmBuild.value).toBe(false);
expect(review.routingRecoveryLines.value).toHaveLength(1);
expect(review.routingRecoveryLines.value[0]?.line_key).toBe('line-1');
expect(review.routingRecoveryLines.value[0]?.draft_line_id).toBe('line-1');
});
@@ -441,6 +442,68 @@ describe('useShippingOrderReview build eligibility writes', () => {
expect(resume).toEqual({ outcome: 'auto_create_enqueued' });
});
it('tracks an enqueued validation until the worker creates the formal order task', async () => {
vi.useFakeTimers();
const queuedCase = buildCase({
status: 'ready',
automation: { status: 'queued' },
});
const confirmedCase = buildCase({
status: 'confirmed',
order_task_no: 'OT-1',
confirmed_task_no: 'OT-1',
automation: { status: 'running' },
});
api.validateDraft.mockResolvedValue({
case: queuedCase,
resume_outcome: { outcome: 'auto_create_enqueued' },
});
api.getCase.mockResolvedValueOnce(buildCase()).mockResolvedValue(confirmedCase);
api.getQueue.mockResolvedValue({
summary: { total: 1, needs_action: 0, processing: 1, completed: 0 },
items: [{
case_no: 'CASE-1', document_id: 1, status: 'confirmed',
lifecycle_stage: 'fulfillment_prep', lifecycle_entries: [],
}],
});
api.getExtractionRun.mockResolvedValue({ run_no: 'RUN-1', status: 'completed' });
api.getProcessingWorkItem.mockResolvedValue({
work_item_no: 'OT-1', status: 'processing', stage: 'inventory_preparation',
});
const review = useShippingOrderReview();
await review.load('RUN-1', 'CASE-1');
await review.validate();
await vi.advanceTimersByTimeAsync(0);
expect(review.workflowProgressPolling.value).toBe(true);
await vi.advanceTimersByTimeAsync(PROGRESS_POLL_MS + 100);
expect(review.reviewProgressContext.value?.user_task_no).toBe('OT-1');
expect(api.getProcessingWorkItem).toHaveBeenCalledWith('order_task', 'OT-1');
review.stopWorkflowProgressPolling();
vi.useRealTimers();
});
it('does not treat a field edit revalidation as a formal-order creation request', async () => {
vi.useFakeTimers();
const revalidatingCase = buildCase({
status: 'draft',
automation: { status: 'queued' },
});
api.patchHeader.mockResolvedValue(revalidatingCase);
const review = useShippingOrderReview();
await review.load('RUN-1', 'CASE-1');
await review.patchHeader('ship_to_name', '新收货方');
await vi.advanceTimersByTimeAsync(PROGRESS_POLL_MS + 100);
// 字段编辑后的 queued 是异步重校验,不是用户已确认的建单请求。
expect(api.getCase).toHaveBeenCalledTimes(1);
expect(review.workflowProgressPolling.value).toBe(false);
vi.useRealTimers();
});
it('refreshes the current Case silently without entering the PDF-switch loading state', async () => {
const review = useShippingOrderReview();
await review.load('RUN-1', 'CASE-1');
@@ -934,6 +997,44 @@ describe('useShippingOrderReview build eligibility writes', () => {
vi.useRealTimers();
});
it('stops workflow progress polling once the unified work item is interrupted (waiting_human)', async () => {
vi.useFakeTimers();
const readyCase = buildCase({
status: 'ready',
draft: {
...buildCase().draft!,
build_eligibility: { can_build: true, status: 'ready', line_projections: [] },
},
});
api.getCase.mockResolvedValue(readyCase);
api.getRun.mockResolvedValue({
run_no: 'RUN-1', summary: {},
items: [{ case_no: 'CASE-1', document_id: 1, status: 'ready', available_actions: ['confirm'] }],
});
api.getEvidence.mockResolvedValue({ items: [] });
api.getPreview.mockResolvedValue({ preview_url: '' });
api.getProcessingWorkItem.mockResolvedValue({
work_item_no: 'OT-1', status: 'blocked', user_status: 'waiting_human',
currentGate: { gateCode: 'inventory_matching', status: 'blocked_manual' },
});
api.confirmCase.mockResolvedValue({
task_no: 'SN-1', order_task_no: 'OT-1', shipping_notice_no: 'SN-1', idempotent_replay: false,
case: { ...readyCase, status: 'confirmed', order_task_no: 'OT-1' }, auto_progress_started: true,
});
const review = useShippingOrderReview();
await review.load('RUN-1', 'CASE-1', { conversationId: 'conv-1', itemNo: 'WFI-1' });
await review.confirm();
await vi.advanceTimersByTimeAsync(0);
await Promise.resolve();
// 中断(waiting_human,即“等待人工处理”)视为线性终态:结果不会自行变化,必须停止轮询。
expect(review.workflowProgressPolling.value).toBe(false);
review.stopWorkflowProgressPolling();
vi.useRealTimers();
});
it('refreshes the active Case and queue while post-confirm automation is still active', async () => {
vi.useFakeTimers();
const readyCase = buildCase({
@@ -1116,7 +1217,8 @@ describe('useShippingOrderReview build eligibility writes', () => {
run_no: caseNo === 'CASE-2' ? 'RUN-2' : 'RUN-1',
}));
const review = useShippingOrderReview();
const onReparseCaseReady = vi.fn();
const review = useShippingOrderReview({ onReparseCaseReady });
await review.load('RUN-1', 'CASE-1', { conversationId: 'conv-1', itemNo: 'SWI-1' });
await review.reparseDocument('document_quality');
@@ -1125,6 +1227,8 @@ describe('useShippingOrderReview build eligibility writes', () => {
expect(review.reviewRun.value?.run_no).toBe('RUN-2');
expect(review.activeCase.value?.case_no).toBe('CASE-2');
// 关键断言:只有新版 Case 真正落到 activeCase 后,页面才接收可同步深链的目标。
expect(onReparseCaseReady).toHaveBeenCalledWith({ runNo: 'RUN-2', caseNo: 'CASE-2', documentId: 1 });
review.stopReparseCaseRefreshPolling();
vi.useRealTimers();
});
@@ -1250,6 +1354,44 @@ describe('useShippingOrderReview build eligibility writes', () => {
vi.useRealTimers();
});
it('[选法 2] defers review Case + Evidence load on a formal downstream work item', async () => {
api.getRun.mockResolvedValue({ run_no: 'RUN-1', summary: {}, items: [] });
api.getQueue.mockResolvedValue({
summary: { total: 1, needs_action: 0, processing: 0, completed: 1 },
items: [{
case_no: 'CASE-1', document_id: 1, status: 'confirmed',
lifecycle_stage: 'fulfillment_prep', lifecycle_entries: [],
has_formal_ot: true, confirmed_task_no: 'SN-1',
}],
});
api.getCase.mockClear();
api.getEvidence.mockClear();
const review = useShippingOrderReview();
await review.load('RUN-1', 'CASE-1', { conversationId: 'conv-1' });
// 正式任务下游阶段:首屏不拉复核 Case 快照 + Evidence。
expect(api.getCase).not.toHaveBeenCalled();
expect(api.getEvidence).not.toHaveBeenCalled();
});
it('[选法 2] loadReviewCase lazily fetches review Case + Evidence on demand', async () => {
api.getCase.mockClear();
api.getEvidence.mockClear();
api.getCase.mockResolvedValue({
case: buildCase({ case_no: 'CASE-1' }),
projection_version: 1,
loading_context: null,
});
api.getEvidence.mockResolvedValue({ case_no: 'CASE-1', items: [] });
const review = useShippingOrderReview();
await review.loadReviewCase('CASE-1');
expect(api.getCase).toHaveBeenCalledWith('CASE-1');
expect(api.getEvidence).toHaveBeenCalledWith('CASE-1');
});
});
@@ -1295,7 +1437,7 @@ describe('inventory routing recovery', () => {
can_build: true,
status: 'ready',
line_projections: [{
line_key: 'line-pending',
draft_line_id: 'line-pending',
line_index: 0,
can_build: false,
block_reason: 'inventory_source_unavailable',
@@ -1309,7 +1451,7 @@ describe('inventory routing recovery', () => {
const review = useShippingOrderReview();
await review.load('RUN-1', 'CASE-1');
expect(review.routingRecoveryLines.value).toHaveLength(1);
expect(review.routingRecoveryLines.value[0]?.line_key).toBe('line-pending');
expect(review.routingRecoveryLines.value[0]?.draft_line_id).toBe('line-pending');
});
it('reroutes inventory routing with idempotency_key and expected_draft_version', async () => {
@@ -1324,7 +1466,7 @@ describe('inventory routing recovery', () => {
expect(api.rerouteInventoryRouting).toHaveBeenCalledWith('CASE-1', {
expected_draft_version: 2,
idempotency_key: 'idem-reroute-1',
line_key: 'line-1',
draft_line_id: 'line-1',
});
expect(review.activeCase.value?.draft?.draft_version).toBe(3);
uuidSpy.mockRestore();
@@ -5,9 +5,17 @@
* 逻辑:按 runNo 加载 Review Run/Case;合成 ShippingReviewProgressContext;
* OT 绑定 Case.order_task_no / Candidate;切换时保留稳定显示壳,目标快照到齐后原子替换;
* 409 REVIEW_DRAFT_VERSION_MISMATCH 冲突处理;build_eligibility 驱动 confirm/reroute;
* 重识别后刷新正式 Run/Case/Gate 投影;PDF Blob 由 ensurePreviewLoaded 按需加载。
* 重识别后刷新正式 Run/Case/Gate 投影,并在新版 Case 确认落位后通知页面同步深链;
* PDF Blob 由 ensurePreviewLoaded 按需加载。
*/
import { computed, getCurrentInstance, onBeforeUnmount, ref } from 'vue';
import {
computed,
getCurrentInstance,
onBeforeUnmount,
ref,
toValue,
type MaybeRefOrGetter,
} from 'vue';
import { BusinessError } from '@/shared/api/client';
import {
addWorkspaceShippingOrderReviewLine,
@@ -303,7 +311,13 @@ function synthesizeWorkItemFromReviewContext(params: {
};
}
export function useShippingOrderReview(options: { onWorkflowRefresh?: () => void } = {}) {
export function useShippingOrderReview(options: {
onWorkflowRefresh?: () => void;
/** 新版重解析 Case 已完成 load 后通知页面;路由和工作面仍由页面统一裁决。 */
onReparseCaseReady?: (target: { runNo: string; caseNo: string; documentId: number }) => void | Promise<void>;
/** 正式任务 OT 号(选法 2):正式任务下游阶段不再反推复核 Case,改由任务详情提供。 */
externalOrderTaskNo?: MaybeRefOrGetter<string | null | undefined>;
} = {}) {
const reviewRun = ref<ShippingOrderReviewRun | null>(null);
const reviewQueue = ref<ShippingOrderReviewQueue | null>(null);
const activeCase = ref<ShippingOrderReviewCase | null>(null);
@@ -316,8 +330,10 @@ export function useShippingOrderReview(options: { onWorkflowRefresh?: () => void
const authoritativeOrderTaskNo = computed(() => {
const item = reviewProgressContext.value;
const no = String(item?.user_task_no || '').trim();
if (!no || item?.user_task_authoritative === false) return null;
return no;
if (no && item?.user_task_authoritative !== false) return no;
// [选法 2] 正式任务下游阶段 activeCase 可能为空;OT 号改由任务详情提供。
const external = String(toValue(options.externalOrderTaskNo) ?? '').trim();
return external || null;
});
const {
projection: shippingProcessingProjection,
@@ -399,6 +415,7 @@ export function useShippingOrderReview(options: { onWorkflowRefresh?: () => void
let contextConversationId = '';
let contextItemNo = '';
let progressPollTimer: ReturnType<typeof window.setInterval> | null = null;
let stpCreatePollTimer: ReturnType<typeof window.setInterval> | null = null;
let reparseCaseRefreshTimer: ReturnType<typeof window.setInterval> | null = null;
/**
@@ -423,12 +440,67 @@ export function useShippingOrderReview(options: { onWorkflowRefresh?: () => void
workflowProgressPolling.value = false;
};
/**
* 跟踪复核条件满足后的异步 STP 建单,直到后端产生正式 OT。
*
* 核心逻辑:复核写操作只保证校验/入队成功;Worker 后续才会把
* Case 绑定到 order_task_no。发现 OT 后复用既有任务级投影轮询,避免
* 在各个复核按钮中重复实现阶段刷新逻辑。
*/
const stopStpAutoCreateTracking = () => {
if (stpCreatePollTimer != null) {
window.clearInterval(stpCreatePollTimer);
stpCreatePollTimer = null;
}
};
const startStpAutoCreateTracking = () => {
stopStpAutoCreateTracking();
const caseNo = String(activeCase.value?.case_no || '').trim();
const initialStatus = String(activeCase.value?.automation?.status || '').trim().toLowerCase();
if (!caseNo || !['queued', 'running'].includes(initialStatus)) return;
const tick = async () => {
if (typeof document !== 'undefined' && document.hidden) return;
try {
const [caseSnapshot, queue] = await Promise.all([
getWorkspaceShippingOrderReviewCase(caseNo),
reviewRun.value?.run_no
? getWorkspaceShippingOrderReviewQueue(reviewRun.value.run_no)
: Promise.resolve(null),
]);
if (String(activeCase.value?.case_no || '').trim() !== caseNo) return;
applyCaseSnapshot(caseSnapshot);
if (queue) reviewQueue.value = queue;
await refreshWorkItemContext();
const taskNo = String(
caseSnapshot.case?.order_task_no
|| caseSnapshot.case?.confirmed_task_no
|| reviewProgressContext.value?.user_task_no
|| '',
).trim();
const status = String(caseSnapshot.case?.automation?.status || '').trim().toLowerCase();
if (taskNo) {
stopStpAutoCreateTracking();
startWorkflowProgressPolling(taskNo);
} else if (['failed', 'manual_fallback'].includes(status)) {
stopStpAutoCreateTracking();
}
} catch {
// 临时网络失败由下一拍继续读取,不改变后端 Job 状态。
}
};
void tick();
stpCreatePollTimer = window.setInterval(() => { void tick(); }, PROGRESS_POLL_MS);
};
/**
* 等待后端明确产出新复核 Case 后切换工作台,不将 Run 技术状态推断成另一条用户进度。
*
* AI 触发时机:用户发起“重新识别此 PDF”后调用。
* 核心逻辑:以会话级 Review Stream 队列中同一 document_id 的 source_run_no + case_no
* 触发 Case 加载;completed 也可能已生成可复核 Case,不能仅按 Run 技术终态停止。
* 触发 Case 加载;新版 Case 真正落位后通知页面同步后端授权的生命周期深链;
* completed 也可能已生成可复核 Case,不能仅按 Run 技术终态停止。
* failed/cancelled 仅刷新正式投影并停止,失败原因由正式状态卡与 Gate 表达。
*
* Args:
@@ -457,13 +529,22 @@ export function useShippingOrderReview(options: { onWorkflowRefresh?: () => void
if (['review_required', 'partially_completed', 'completed'].includes(normalizedStatus)) {
const target = await resolveCurrentStreamTarget(targetDocumentId, targetRunNo);
if (target) {
window.clearInterval(reparseCaseRefreshTimer!);
reparseCaseRefreshTimer = null;
await load(target.runNo, target.caseNo, {
conversationId: contextConversationId,
itemNo: contextItemNo || undefined,
restoreProgress: false,
});
// [STEP] 只有新 Case 真正落到工作台才停止轮询;Stream 尚未激活或 load
// 静默失败(内部回滚旧快照)时保留下一拍重试,避免一次性失败把用户
// 永远留在已被替代的历史版本上。
if (String(activeCase.value?.case_no || '').trim() === target.caseNo) {
await options.onReparseCaseReady?.({
runNo: target.runNo,
caseNo: target.caseNo,
documentId: targetDocumentId || 0,
});
stopReparseCaseRefreshPolling();
}
}
return;
}
@@ -522,8 +603,11 @@ export function useShippingOrderReview(options: { onWorkflowRefresh?: () => void
showWorkflowProgress.value = true;
workflowProgressPolling.value = true;
// RPA 超时、可重试失败和人工复核都可能被后续回调推进,页面留存期间持续读取 Projection。
// needs_human(等待人工)视为线性终态:结果不会自行变化,继续轮询浪费资源。
const UNIFIED_TERMINAL = new Set(['completed', 'cancelled', 'needs_human']);
// 等待人工(waiting_human,即“中断”)视为线性终态:结果不会自行变化,继续轮询浪费资源。
// 注意:统一投影的用户态值是 waiting_human(旧字段是 needs_human),若沿用旧的
// needs_human 会让已中断任务永远匹配不到终态、一直空转轮询;failed 同理是停止状态。
// 可重试失败(retryable)不在此列,需保留轮询以便后续成功回调自动刷新工作流。
const UNIFIED_TERMINAL = new Set(['completed', 'cancelled', 'waiting_human', 'failed']);
let lastUnifiedStatus = '';
let lastLifecycleFingerprint = '';
const RUN_TERMINAL = new Set(['completed', 'partially_completed', 'failed', 'cancelled']);
@@ -589,6 +673,7 @@ export function useShippingOrderReview(options: { onWorkflowRefresh?: () => void
onBeforeUnmount(() => {
caseSwitchAbortController?.abort();
stopWorkflowProgressPolling();
stopStpAutoCreateTracking();
stopReparseCaseRefreshPolling();
stopShippingProcessing();
clearPreview();
@@ -960,16 +1045,13 @@ export function useShippingOrderReview(options: { onWorkflowRefresh?: () => void
const queueRequest = getWorkspaceShippingOrderReviewQueue(runNo);
// 路由已明确目标 Case 时,详情读取不应等待较慢的 Run/Queue 摘要;
// 四份数据仍在全部成功后原子提交,避免混合工作面。
const preferredCaseRequest = preferredCaseNo
? Promise.all([
getWorkspaceShippingOrderReviewCase(preferredCaseNo),
getWorkspaceShippingOrderReviewEvidence(preferredCaseNo),
])
: null;
// 已有稳定工作台且路由明确目标 PDF 时,目标详情是用户切换的关键路径;
// Run/Queue 只负责后续更新导航和阶段摘要,不能用其慢投影阻塞当前文件显示。
if (hasStableWorkbench && preferredCaseRequest) {
const [caseSnapshot, caseEvidence] = await preferredCaseRequest;
if (hasStableWorkbench && preferredCaseNo) {
const [caseSnapshot, caseEvidence] = await Promise.all([
getWorkspaceShippingOrderReviewCase(preferredCaseNo),
getWorkspaceShippingOrderReviewEvidence(preferredCaseNo),
]);
if (generation !== caseLoadGeneration) return;
applyCaseSnapshot(caseSnapshot);
evidence.value = caseEvidence?.items || [];
@@ -987,22 +1069,28 @@ export function useShippingOrderReview(options: { onWorkflowRefresh?: () => void
return;
}
const [run, queue, preferredSnapshot] = await Promise.all([
runRequest,
queueRequest,
preferredCaseRequest,
]);
const [run, queue] = await Promise.all([runRequest, queueRequest]);
if (generation !== caseLoadGeneration) return;
// [STREAM] Run 替代不等于其内全部 PDF 替代;当前文件只由队列 Stream 裁决。
const caseNo = preferredCaseNo || queue.items[0]?.case_no || run.items[0]?.case_no;
const [caseSnapshot, caseEvidence] = preferredSnapshot
? preferredSnapshot
: caseNo
? await Promise.all([
getWorkspaceShippingOrderReviewCase(caseNo),
getWorkspaceShippingOrderReviewEvidence(caseNo),
])
: [null, null];
// [选法 2] 正式任务下游阶段(通知准备/货代上传/通知完成)本阶段不拉复核编辑器
// (Case 快照 + Evidence),改由任务详情 + 统一投影驱动;进入「订单复核」才补拉。
const navItem = (queue.items || run.items).find(
(item) => String(item.case_no || '').trim() === String(caseNo || '').trim(),
) || null;
const navStage = String(navItem?.lifecycle_stage || '').trim().toLowerCase();
const isFormalDownstream = Boolean(
navItem?.has_formal_ot
&& !['intake_parse', 'order_review'].includes(navStage),
);
let caseSnapshot: ShippingOrderReviewCaseSnapshot | null = null;
let caseEvidence: { case_no: string; items: ShippingOrderReviewEvidence[] } | null = null;
if (!isFormalDownstream && caseNo) {
[caseSnapshot, caseEvidence] = await Promise.all([
getWorkspaceShippingOrderReviewCase(caseNo),
getWorkspaceShippingOrderReviewEvidence(caseNo),
]);
}
if (generation !== caseLoadGeneration) return;
reviewRun.value = run;
reviewQueue.value = queue;
@@ -1134,6 +1222,8 @@ export function useShippingOrderReview(options: { onWorkflowRefresh?: () => void
const save = async (action: () => Promise<ShippingOrderReviewCase>) => {
saving.value = true;
saveFailed.value = false;
// 任意草稿变更都会使上一轮“已提交建单”跟踪失效;新的草稿版本必须重新显式提交。
stopStpAutoCreateTracking();
const localVersion = version();
try {
const nextCase = await action();
@@ -1182,9 +1272,9 @@ export function useShippingOrderReview(options: { onWorkflowRefresh?: () => void
return String(field?.field_code || fieldId).trim();
};
const draftLineIndex = (lineKey: string) => {
const draftLineIndex = (draftLineId: string) => {
const lines = activeCase.value?.draft?.lines || [];
return lines.findIndex((row) => String(row.line_key || '') === String(lineKey || ''));
return lines.findIndex((row) => String(row.draft_line_id || '') === String(draftLineId || ''));
};
const formalEditOptions = () => ({
@@ -1315,7 +1405,6 @@ export function useShippingOrderReview(options: { onWorkflowRefresh?: () => void
fieldId: string,
value: unknown,
restoreMachine = false,
override?: { override_reason_code?: string; override_reason_text?: string },
) => {
if (!activeCase.value) return Promise.resolve();
if (isFormalTaskFieldEdit()) {
@@ -1338,8 +1427,6 @@ export function useShippingOrderReview(options: { onWorkflowRefresh?: () => void
expected_draft_version: version(),
value,
restore_machine: restoreMachine,
override_reason_code: override?.override_reason_code,
override_reason_text: override?.override_reason_text,
}));
};
const addLine = () => activeCase.value && save(() => addWorkspaceShippingOrderReviewLine(activeCase.value!.case_no, version()));
@@ -1351,6 +1438,12 @@ export function useShippingOrderReview(options: { onWorkflowRefresh?: () => void
try {
const response = await validateWorkspaceShippingOrderReviewDraft(activeCase.value.case_no, version());
await save(async () => response.case);
// 只有显式“保存并校验”且后端确认已入队时,才跟踪 Worker 创建正式订单。
// 普通字段编辑/增删行虽然会触发异步重校验,但仍停留在订单复核阶段。
const outcome = String(response.resume_outcome?.outcome || '').trim();
if (['auto_create_enqueued', 'already_queued', 'already_running'].includes(outcome)) {
startStpAutoCreateTracking();
}
return response.resume_outcome;
} finally {
validationInProgress.value = false;
@@ -1359,15 +1452,15 @@ export function useShippingOrderReview(options: { onWorkflowRefresh?: () => void
/**
* ?????????????????409 ????? markWriteFailure?
* @param lineKey - ???????? reroute
* @param draftLineId - 草稿行稳定身份;为空表示整单重算
*/
const rerouteInventoryRouting = (lineKey?: string) => {
const rerouteInventoryRouting = (draftLineId?: string) => {
if (!activeCase.value) return Promise.resolve();
const trimmed = String(lineKey || '').trim();
const trimmed = String(draftLineId || '').trim();
return save(() => postWorkspaceShippingOrderReviewInventoryRoutingReroute(activeCase.value!.case_no, {
expected_draft_version: version(),
idempotency_key: crypto.randomUUID(),
...(trimmed ? { line_key: trimmed } : {}),
...(trimmed ? { draft_line_id: trimmed } : {}),
}));
};
@@ -1517,7 +1610,7 @@ export function useShippingOrderReview(options: { onWorkflowRefresh?: () => void
try {
const response = await requestWorkspaceShippingOrderReviewLlmSuggestion(activeCase.value.case_no, {
field_id: focusedFieldId.value,
line_key: focusedLineKey.value,
draft_line_id: focusedLineKey.value,
issue_code: issueCode ?? undefined,
expected_draft_version: activeCase.value.draft?.draft_version,
});
@@ -1580,6 +1673,31 @@ export function useShippingOrderReview(options: { onWorkflowRefresh?: () => void
return target;
};
/**
* 【选法 2】正式任务下游阶段懒加载复核编辑器:不重拉 Run/Queue,仅按需读取
* 当前文件的 Case 快照 + Evidence,供用户从「通知准备」切回「订单复核」阶段使用。
*/
const loadReviewCase = async (caseNo: string | null | undefined) => {
const normalized = String(caseNo || '').trim();
if (!normalized) return;
const generation = ++caseLoadGeneration;
try {
const [caseSnapshot, caseEvidence] = await Promise.all([
getWorkspaceShippingOrderReviewCase(normalized),
getWorkspaceShippingOrderReviewEvidence(normalized),
]);
if (generation !== caseLoadGeneration) return;
applyCaseSnapshot(caseSnapshot);
evidence.value = caseEvidence?.items || [];
clearPreview();
await refreshWorkItemContext(contextConversationId, contextItemNo, {
expectedLoadGeneration: generation,
});
} catch {
// 懒加载失败保留当前工作面,不抛到页面主流程。
}
};
return {
reviewRun,
reviewQueue,
@@ -1638,6 +1756,7 @@ export function useShippingOrderReview(options: { onWorkflowRefresh?: () => void
saveFailed,
versionsLoading,
load,
loadReviewCase,
selectCase,
resetCaseTransientState,
requestedCaseNo,
@@ -1654,6 +1773,8 @@ export function useShippingOrderReview(options: { onWorkflowRefresh?: () => void
validate,
rerouteInventoryRouting,
confirm,
startStpAutoCreateTracking,
stopStpAutoCreateTracking,
startWorkflowProgressPolling,
stopWorkflowProgressPolling,
startReparseCaseRefreshPolling,
File diff suppressed because it is too large. Load diff
@@ -200,6 +200,7 @@ const {
isFieldEditable,
loadReviewCase,
showWorkflowProgress,
workflowProgressPolling,
startWorkflowProgressPolling,
stopWorkflowProgressPolling,
stopReparseCaseRefreshPolling,
@@ -675,6 +676,32 @@ const showObjectRetryOnFooter = computed(() => (
* 补任一字段。否则“检查已通过”与旧 Gate 的“待裁决”会被拼到同一张卡上。
*/
const currentTaskUiState = computed(() => shippingProcessingProjection.value?.uiState ?? null);
/**
* Gate/RPA 动作已受理但新投影尚未落位时的本地过渡态。
* 仅用于避免上一帧 failed 在轮询窗口继续冒充当前状态;真实终态仍以后端
* shippingProcessingProjection 为准,不新增业务状态或动作权限。
*/
const recoveryProjectionPending = ref(false);
const recoveryProjectionBaselineVersion = ref<number | null>(null);
watch(
shippingProcessingProjection,
(projection) => {
if (!recoveryProjectionPending.value || !projection) return;
const version = Number(projection.progressVersion || 0);
const baseline = recoveryProjectionBaselineVersion.value;
const status = String(projection.userStatus || projection.status || '').trim().toLowerCase();
const gateStatus = String(projection.currentGate?.status || '').trim().toLowerCase();
const hasFreshVersion = baseline == null || version > baseline;
const isActive = ['running', 'processing', 'automating', 'queued'].includes(status)
|| ['pending', 'queued', 'running', 'waiting_external'].includes(gateStatus);
const isSettled = ['completed', 'cancelled', 'waiting_human', 'retryable'].includes(status);
if (hasFreshVersion || isActive || isSettled) {
recoveryProjectionPending.value = false;
recoveryProjectionBaselineVersion.value = null;
}
},
);
/**
* 正式 OT 已存在且文件切换或统一处理投影读取中时,Case Gate 只是降级快照,不能先暴露可执行动作。
* Projection 返回后才拥有动作裁决权;非切换错误路径仍保留原有的 Case Gate 恢复能力。
@@ -698,22 +725,14 @@ const NOTICE_SCOPED_ACTION_CODES = new Set([
'regenerate_excel_artifact',
]);
function isNoticeScopedAction(action: ShippingUnifiedAction | null | undefined): boolean {
return NOTICE_SCOPED_ACTION_CODES.has(String(action?.code || '').trim());
}
/**
* 将正式任务详情的已启用 Gate 动作适配为右侧当前任务卡的展示契约。
*
* 正式 OT 的写授权只能来自 ``ui_state.actions``;统一处理 Projection 仅承载
* 进度、阶段和阻断事实,不能以历史动作码替代正式 Gate 动作。
* 判断动作是否属于 Notice 作用域(应在通知组而非任务卡展示)。
* 核心逻辑:只读 code,兼容 ShippingUnifiedAction 与 Projection 的 primary/secondary 动作形状。
* @param action - 任意带 code 的动作对象
* @returns 是否为 Notice 作用域动作
*/
function toCurrentTaskAction(action: ShippingUnifiedAction | null | undefined) {
if (!action?.enabled || !String(action.code || '').trim() || isNoticeScopedAction(action)) return null;
return {
code: String(action.code).trim(),
i18nKey: `workspace.shippingNotice.processGate.actionCodes.${action.code}`,
};
function isNoticeScopedAction(action: { code?: string | null } | null | undefined): boolean {
return NOTICE_SCOPED_ACTION_CODES.has(String(action?.code || '').trim());
}
const formalTaskActions = computed(() => {
@@ -725,15 +744,23 @@ const formalTaskActions = computed(() => {
/** 行级库存选源动作:只在表格逐行处理,禁止作为任务级按钮出现在右侧"当前任务"卡(避免与表格打勾重复)。 */
const LINE_SCOPE_INVENTORY_ACTIONS = new Set([
'override_line_inventory_source',
'select_line_inventory_source',
]);
const currentTaskPrimaryAction = computed(() => {
if (formalTaskProjectionPending.value) return null;
if (hasFormalOt.value) {
const first = toCurrentTaskAction(formalTaskActions.value[0]);
if (!first || LINE_SCOPE_INVENTORY_ACTIONS.has(first.code)) return null;
return first;
// [§2.4 单源] 正式 OT 的主动作只从 A(shippingProcessingProjection.ui_state.primary_action)读,
// 不再读 B(formalTaskDetail.ui_state.actions —— 之后仅作工作面事实)。后端 flatten 已保证
// A==C==B(动作码同源),故该改动纯收敛、不改变已授权按钮。
// 注意:A 的 i18nKey 可能是 chat 域(如 chat.shippingProcessing.action.*),而右卡
// ReviewCurrentProcessingCard 只解析 workspace.shippingNotice.processGate.actionCodes.*,
// 故必须统一映射到卡片域,否则按钮会因 businessActionLabel 为空而 fail-closed 消失。
const action = currentTaskUiState.value?.primary_action ?? null;
if (!action?.code || LINE_SCOPE_INVENTORY_ACTIONS.has(action.code)) return null;
return {
code: String(action.code).trim(),
i18nKey: `workspace.shippingNotice.processGate.actionCodes.${action.code}`,
};
}
const projection = shippingProcessingProjection.value;
if (projection) {
@@ -759,6 +786,7 @@ const currentTaskPrimaryAction = computed(() => {
});
const currentTaskUserStatus = computed(() => {
if (formalTaskDetail.value?.ui_state?.lifecycle_stage === 'upload_complete') return 'completed';
if (recoveryProjectionPending.value) return 'running';
// 已确认 OT 且权威投影在途时,先消费后端 automation 运行态(queued/running → running,
// failed/manual_fallback → failed),状态行即显真实值,不应退回「正在获取最新状态」骨架;
// authority 仍以右侧投影为准,投影到达后覆盖。
@@ -778,6 +806,7 @@ const currentTaskUserStatus = computed(() => {
* 仅当原因码在隐藏白名单且映射结果==当前状态(纯重复)才隐藏,其余诊断信息一律保留。
*/
const currentTaskStatusDetail = computed<{ text: string } | null>(() => {
if (recoveryProjectionPending.value) return null;
if (['completed', 'cancelled'].includes(String(currentTaskUserStatus.value || ''))) return null;
const message = resolveExtractionActivityMessage(lifecycleProgressForView.value, { t, te });
if (!message) return null;
@@ -788,12 +817,14 @@ const currentTaskStatusDetail = computed<{ text: string } | null>(() => {
});
const currentTaskBlockingReason = computed(() => {
if (formalTaskDetail.value?.ui_state?.lifecycle_stage === 'upload_complete') return null;
if (recoveryProjectionPending.value) return null;
if (formalTaskProjectionPending.value) return null;
return currentTaskUiState.value?.blocking_reason ?? null;
});
/** 当前 Gate 状态必须与右栏动作同源,均来自统一处理 Projection。 */
const currentTaskGateStatus = computed(() => {
if (formalTaskDetail.value?.ui_state?.lifecycle_stage === 'upload_complete') return null;
if (recoveryProjectionPending.value) return 'running';
if (formalTaskProjectionPending.value) return null;
const projection = shippingProcessingProjection.value;
if (projection?.currentGate?.status) return projection.currentGate.status;
@@ -809,15 +840,20 @@ const currentTaskRetryable = computed(() => (
const currentTaskRecoveryActions = computed(() => {
if (formalTaskProjectionPending.value) return [];
if (hasFormalOt.value) {
// [STAGE_CAPABILITY] 门禁恢复动作 + 阶段能力(任务级、已启用)按 code 去重。
// 能力统一在右侧"当前任务"卡展示,主工作台不再重复放按钮。这样在整库存阶段
// (含非原生 gate,如 inventory_field_mapping 死局)右侧卡始终有"重抓/重读/改源"。
// 行级库存选源动作(override/select_line_inventory_source)只在表格逐行处理,
// 禁止作为任务级按钮出现在右侧卡,避免与表格"打勾"重复。
const gateRecovery = formalTaskActions.value.slice(1)
.filter((action) => String(action.code || '').trim() !== 'download_excel' && !isNoticeScopedAction(action))
.map(toCurrentTaskAction)
.filter((action): action is NonNullable<typeof action> => Boolean(action));
// [§2.4 单源] 恢复动作从 A(shippingProcessingProjection.ui_state.secondary_actions)读,
// 不再从 B(formalTaskDetail.ui_state.actions)slice。能力仍取任务级
// stage_context.preparation.capabilities(B 工作面事实,§2 保留)。动作码同源(A==C==B),
// 该改动纯收敛。行级库存选源动作只在表格逐行处理,禁止作为任务级按钮出现在右侧卡。
const gateRecovery = (currentTaskUiState.value?.secondary_actions || [])
.filter((action) => action.enabled
&& String(action.code || '').trim() !== 'download_excel'
&& !isNoticeScopedAction(action))
.map((action) => ({
code: String(action.code || '').trim(),
// 统一右卡 domain:actionCodes.<code>(见 currentTaskPrimaryAction 注;A 的 i18nKey 可能是 chat 域)。
i18nKey: `workspace.shippingNotice.processGate.actionCodes.${String(action.code || '').trim()}`,
}))
.filter((action): action is { code: string; i18nKey: string } => Boolean(action.code));
const capabilityActions = (formalPreparationContext.value?.capabilities || [])
.filter((cap) => cap.scope === 'task' && cap.enabled && String(cap.action_code || '').trim())
.map((cap) => ({
@@ -1640,6 +1676,10 @@ async function retryFormalUploadRpa(taskNo: string) {
* 一次性自动推进许可,待后端生命周期投影确认后才更新深链。
*/
function handleGateRecoveryAccepted(options: { releaseAutoAdvance?: boolean } = {}) {
if (hasFormalOt.value) {
recoveryProjectionBaselineVersion.value = shippingProcessingProjection.value?.progressVersion ?? null;
recoveryProjectionPending.value = true;
}
const caseNo = String(activeCase.value?.case_no || '').trim();
if (options.releaseAutoAdvance && caseNo) {
// 放行前可能是用户手动进入通知准备;该历史意图不能阻止本次放行后的自动推进。
@@ -2634,14 +2674,17 @@ async function retryFormalPreparationLine(
/**
* 人工上传登记是后端 Gate 的受控写动作;仅进入「货代上传」工作面不构成授权。
* 任务详情与批次中心共用 ui_state.actions,避免页面按上传状态或生命周期自行放行。
* [§2 单源] 授权从 A(shippingProcessingProjection.ui_state)读 —— §2.5 差异① 已归一,A 的
* secondary_actions/primary_action 透传原始 mark_manual_uploaded 码(与 B/C 一致的写契约码)。
* 避免页面按上传状态或生命周期自行放行。
*/
const manualUploadRegistrationAuthorized = computed(() => {
const actions = formalTaskDetail.value?.ui_state?.actions;
const candidates = [actions?.primary, ...(actions?.secondary || [])];
return candidates.some((action) => (
action?.code === 'mark_manual_uploaded' && action.enabled === true
));
const uiState = currentTaskUiState.value;
// primary_action 无 enabled 字段,出现即视为已授权;secondary_actions 必须 enabled === true。
if (uiState?.primary_action?.code === 'mark_manual_uploaded') return true;
return (uiState?.secondary_actions || []).some(
(action) => action.code === 'mark_manual_uploaded' && action.enabled === true,
);
});
/** 直接在订单复核页打开人工上传登记,避免依赖仅在 formal_task 模式挂载的 TaskTodoPanel ref。 */
@@ -2838,6 +2881,42 @@ watch(
{ immediate: true },
);
// ============================================================================
// 正式 OT 自动推进的「阶段无关」投影轮询(问题1修复的正解)
// ============================================================================
// 背景:shippingProcessingProjection 是整工作台唯一的轻量实时投影(progressVersion 变化会
// 触发 [REFRESH_ON_CHANGE] 重新加载正式任务详情 → 表格数字/门禁/阶段自动更新)。但它的刷新
// 完全依赖 startWorkflowProgressPolling(useShippingProcessingWorkItem 已关 continuousPolling),
// 而历史上只有「货代上传」watching 会持续推进该轮询;通知准备阶段的 RPA 取数→匹配→满足性
// 异步推进期间轮询被停,导致「可用数量/缺口/匹配状态」停在初值,需手动刷新。
// 方案:新增一条与业务阶段解耦的推进监控——只要存在正式 OT、且其投影仍处于「自动推进中」
// (非终态/非等待人工/非中断),就保持轮询;落到终态/等待人工即停止。与货代上传 watcher 互不耦合,
// prep 阶段不再寄生在 freight 逻辑上。
const OT_PROGRESS_ACTIVE_STATUSES = new Set(['running', 'processing', 'automating', 'queued']);
const OT_PROGRESS_IDLE_STATUSES = new Set(['waiting_human', 'interrupted', 'failed', 'completed', 'cancelled']);
function isOtProgressing(projection: typeof shippingProcessingProjection.value): boolean {
const status = String(
projection?.uiState?.status
|| projection?.userStatus
|| projection?.status
|| '',
).trim().toLowerCase();
return OT_PROGRESS_ACTIVE_STATUSES.has(status) && !OT_PROGRESS_IDLE_STATUSES.has(status);
}
watch(
[() => hasFormalOt.value, authoritativeOrderTaskNo, shippingProcessingProjection],
([hasOt, otNo, projection]) => {
// 仅当正式 OT 存在且其投影处于自动推进态时保持轮询;否则停止,避免空转。
if (!hasOt || !otNo || !projection || !isOtProgressing(projection)) {
if (workflowProgressPolling.value) stopWorkflowProgressPolling();
return;
}
// 已在轮询则不动,避免每次投影刷新都重建 interval(否则 2.5s 定时器被反复重置)。
if (!workflowProgressPolling.value) startWorkflowProgressPolling();
},
{ immediate: true },
);
function toggleFreightNoticeSelection(businessNo: string, checked: boolean) {
selectedFreightBusinessNos.value = checked
? Array.from(new Set([...selectedFreightBusinessNos.value, businessNo]))
@@ -49,7 +49,7 @@ export interface AdminProcessExecutionListPage {
page_size: number;
}
export interface AdminProcessExecutionDetail extends ShippingProcessGateUserSummary {
export interface AdminProcessExecutionDetail extends Omit<ShippingProcessGateUserSummary, 'current_gate'> {
current_gate?: Record<string, unknown> | null;
current_blocking_gate?: ShippingProcessGateUserSummary['current_blocking_gate'];
gates?: Array<Record<string, unknown>>;
@@ -54,6 +54,24 @@ function summary() {
} as never;
}
/** 非原生 Gate 摘要:阶段能力不在 recovery_targets / allowed_actions 内(Task 5 根因)。 */
function capabilitySummary() {
return {
execution_no: 'EXEC-1',
status: 'blocked',
current_blocking_gate: {
gate_code: 'inventory_field_mapping',
evaluation_version: 5,
status: 'blocked',
},
primary_action: null,
allowed_actions: [],
recovery_targets: [],
action_presentation: [],
next_action_code: null,
} as never;
}
function mountComposable() {
let exposed!: ReturnType<typeof useShippingProcessGateRecovery>;
const app = createApp(defineComponent({
@@ -92,4 +110,62 @@ describe('useShippingProcessGateRecovery', () => {
app.unmount();
});
it('dispatches an enabled stage capability past the server guard when stageCapabilityBypass is true', async () => {
// 断言:能力动作不在 recovery_targets / allowed_actions 内(非原生 Gate 的根因场景),
// 开启 stageCapabilityBypass 后仍应 POST 到 request_gate_action,而非返回 noop。
const { exposed, app } = mountComposable();
const result = await exposed.submitPrimaryAction(capabilitySummary(), {
actionCode: 'override_line_inventory_source',
stageCapabilityBypass: true,
});
expect(result.outcome).toBe('submitted');
expect(postActionMock).toHaveBeenCalledTimes(1);
expect(getExecutionMock).not.toHaveBeenCalled();
expect(postActionMock).toHaveBeenCalledWith(
'EXEC-1',
'inventory_field_mapping',
expect.objectContaining({ action_code: 'override_line_inventory_source' }),
);
app.unmount();
});
it('uses current_gate when the user projection omits current_blocking_gate', async () => {
const { exposed, app } = mountComposable();
const result = await exposed.submitPrimaryAction({
execution_no: 'EXEC-1',
status: 'processing',
current_gate: { gate_code: 'inventory_preparation', evaluation_version: 7, status: 'running' },
allowed_actions: [],
recovery_targets: [],
} as never, {
actionCode: 'retry_inventory_preparation',
stageCapabilityBypass: true,
});
expect(result.outcome).toBe('submitted');
expect(postActionMock).toHaveBeenCalledWith(
'EXEC-1',
'inventory_preparation',
expect.objectContaining({ action_code: 'retry_inventory_preparation' }),
);
app.unmount();
});
it('keeps a non-capability action not in recovery_targets / allowed_actions guarded as noop', async () => {
// 断言:普通门禁动作不在服务端恢复集合内时,仍被 serverRecoveryAction 守卫拦截
// 返回 noop,符合「普通动作必须保持服务端校验」的不变式。
const { exposed, app } = mountComposable();
const result = await exposed.submitPrimaryAction(capabilitySummary(), {
actionCode: 'retry_freight_upload_rpa',
});
expect(result.outcome).toBe('noop');
expect(postActionMock).not.toHaveBeenCalled();
app.unmount();
});
});
@@ -85,62 +85,82 @@ export function useShippingProcessGateRecovery() {
navigationContext?: ProcessGateNavigationContext;
/** 仅允许使用服务端 recovery_targets 下发的动作码覆盖主动作。 */
actionCode?: ShippingProcessGateActionCode | string;
/**
* 阶段能力强制绕过:跳过服务端 recovery_targets/allowed_actions 校验与展示精确匹配,
* 直接把请求动作码作为 mutation POST 到 request_gate_action;后端按阶段能力豁免
* (Task 4)做授权并执行 execute_stage_capability。仅由已按 enabled 裁决的调用方
* (如 prep 工作台)用于正式阶段能力;普通门禁动作必须保持服务端校验。
*/
stageCapabilityBypass?: boolean;
},
): Promise<ProcessGateActionResult> {
const gate = summary.current_blocking_gate;
// 正式 OT 的系统等待态不会投影 current_blocking_gate,但仍保留
// current_gate 供通知准备阶段能力(改源/重抓)提交到当前 Execution。
// 普通人工恢复优先使用 current_blocking_gate,避免把非当前 Gate 当成待办。
const gate = summary.current_blocking_gate || summary.current_gate;
const requestedAction = String(options?.actionCode || '').trim();
const stageCapabilityBypass = Boolean(options?.stageCapabilityBypass);
const serverRecoveryAction = (summary.recovery_targets || [])
.find((target) => String(target.action_code || '').trim() === requestedAction)
?.action_code
|| (summary.allowed_actions || []).find((code) => String(code).trim() === requestedAction);
if (requestedAction && !serverRecoveryAction) {
if (requestedAction && !stageCapabilityBypass && !serverRecoveryAction) {
msg.warning(t('workspace.shippingNotice.processGate.noAction'));
return { outcome: 'noop' };
}
const actionCode = (serverRecoveryAction || summary.next_action_code || gate?.next_action_code || '') as ShippingProcessGateActionCode | '';
// 阶段能力不在 recovery_targets/allowed_actions 内;绕过时以调用方请求动作码为准。
const actionCode = (
stageCapabilityBypass && requestedAction
? requestedAction
: (serverRecoveryAction || summary.next_action_code || gate?.next_action_code || '')
) as ShippingProcessGateActionCode | '';
if (!summary.execution_no || !gate?.gate_code || !actionCode) {
msg.warning(t('workspace.shippingNotice.processGate.noAction'));
return { outcome: 'noop' };
}
const action = resolveActionPresentation(summary, String(actionCode));
if (!action) {
msg.warning(t('workspace.shippingNotice.processGate.noAction'));
return { outcome: 'noop' };
}
if (String(action.dispatch || '').trim() === 'dialog') {
const uiHandler = String(action.ui_handler || '').trim();
if (!uiHandler) {
// 阶段能力是纯 mutation POST:调用方已按 enabled 裁决,且其动作码不在门禁
// action_presentation 内,故跳过展示精确匹配与 dialog/导航分支,由后端授权。
if (!stageCapabilityBypass) {
const action = resolveActionPresentation(summary, String(actionCode));
if (!action) {
msg.warning(t('workspace.shippingNotice.processGate.noAction'));
return { outcome: 'failed' };
return { outcome: 'noop' };
}
return {
outcome: 'dialog',
uiHandler,
taskNo: String(summary.navigation?.task_no || summary.task_no || '').trim().toUpperCase(),
};
}
if (isProcessGateNavigationAction(action)) {
const route = buildProcessGateNavigationRoute(
summary,
action,
options?.navigationContext || {},
);
if (!route) {
msg.warning(t('workspace.shippingNotice.processGate.navigationMissing'));
return { outcome: 'failed' };
if (String(action.dispatch || '').trim() === 'dialog') {
const uiHandler = String(action.ui_handler || '').trim();
if (!uiHandler) {
msg.warning(t('workspace.shippingNotice.processGate.noAction'));
return { outcome: 'failed' };
}
return {
outcome: 'dialog',
uiHandler,
taskNo: String(summary.navigation?.task_no || summary.task_no || '').trim().toUpperCase(),
};
}
busy.value = true;
try {
await router.push(route);
return { outcome: 'navigated' };
} catch {
msg.warning(t('workspace.shippingNotice.actions.failed'));
return { outcome: 'failed' };
} finally {
busy.value = false;
if (isProcessGateNavigationAction(action)) {
const route = buildProcessGateNavigationRoute(
summary,
action,
options?.navigationContext || {},
);
if (!route) {
msg.warning(t('workspace.shippingNotice.processGate.navigationMissing'));
return { outcome: 'failed' };
}
busy.value = true;
try {
await router.push(route);
return { outcome: 'navigated' };
} catch {
msg.warning(t('workspace.shippingNotice.actions.failed'));
return { outcome: 'failed' };
} finally {
busy.value = false;
}
}
}