feat(shipping-process-gates): 落地全门禁中断恢复并消除双真相
纳入 Execution/Gate/Attempt 模型与迁移、Worker/API/前端恢复卡片与 Admin 诊断, Gate 阻断时清零旧 action_buttons,异常摘要统一脱敏,并为运维筛选与 Attempt Diff 补齐入口。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
b352c281d5
commit
323928626b
92 files changed
+11930
-458
No files matched your search
+30
-7
@@ -1,26 +1,39 @@
|
||||
<!--
|
||||
features/chat/components/shipping-review/ReviewBuildEligibilityPanel.vue
|
||||
用途:展示建单前资格摘要(can_build、阻断原因、行级 Reservation 与库存候选)。
|
||||
依赖:vue-i18n、ShippingOrderReviewBuildEligibility 类型。
|
||||
逻辑:ShippingOrderReviewView 传入 draft.build_eligibility;只读展示,不发起写请求。
|
||||
用途:展示建单前资格摘要(can_build、阻断原因、行级 Reservation 与库存候选)及 Gate 恢复卡片。
|
||||
依赖:vue-i18n、ProcessGateRecoveryCard、ShippingOrderReviewBuildEligibility 类型。
|
||||
逻辑:ShippingOrderReviewView 传入 draft.build_eligibility 与 case.process_gate;只读展示资格,Gate 动作可导航/POST。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { ShippingOrderReviewBuildEligibility } from '@/features/chat/types/shipping.api.types';
|
||||
import ProcessGateRecoveryCard from '@/features/shipping-process-gates/components/ProcessGateRecoveryCard.vue';
|
||||
import type {
|
||||
ShippingOrderReviewBuildEligibility,
|
||||
ShippingProcessGateUserSummary,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
import type { ProcessGateNavigationContext } from '@/features/shipping-process-gates/composables/processGateNavigation';
|
||||
|
||||
const props = defineProps<{
|
||||
eligibility: ShippingOrderReviewBuildEligibility | null;
|
||||
processGate?: ShippingProcessGateUserSummary | null;
|
||||
canHandleGate?: boolean;
|
||||
navigationContext?: ProcessGateNavigationContext;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
gateRefreshed: [];
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
const canHandle = computed(() => props.canHandleGate !== false);
|
||||
|
||||
/**
|
||||
* 解析建单资格状态文案。
|
||||
*/
|
||||
function statusLabel(status: string): string {
|
||||
const key = `chat.shippingOrderReview.buildEligibility.status.${status}`;
|
||||
return te(key) ? t(key) : status;
|
||||
return te(key) ? t(key) : t('chat.shippingOrderReview.buildEligibility.status.unknown');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -30,7 +43,7 @@ function blockReasonLabel(reason?: string | null): string {
|
||||
const normalized = String(reason || '').trim();
|
||||
if (!normalized) return '—';
|
||||
const key = `chat.shippingOrderReview.buildEligibility.blockReasons.${normalized}`;
|
||||
return te(key) ? t(key) : normalized;
|
||||
return te(key) ? t(key) : t('chat.shippingOrderReview.buildEligibility.blockReasons.unknown');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,7 +53,7 @@ function routingStatusLabel(status?: string | null): string {
|
||||
const normalized = String(status || '').trim();
|
||||
if (!normalized) return '—';
|
||||
const key = `chat.shippingOrderReview.buildEligibility.routingStatus.${normalized}`;
|
||||
return te(key) ? t(key) : normalized;
|
||||
return te(key) ? t(key) : t('chat.shippingOrderReview.buildEligibility.routingStatus.unknown');
|
||||
}
|
||||
|
||||
/** 未满足建单资格的明细行。 */
|
||||
@@ -60,6 +73,15 @@ const blockingSummary = computed(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-4">
|
||||
<ProcessGateRecoveryCard
|
||||
v-if="processGate?.current_blocking_gate"
|
||||
:summary="processGate"
|
||||
:can-handle="canHandle"
|
||||
:navigation-context="navigationContext"
|
||||
@refreshed="emit('gateRefreshed')"
|
||||
@refresh-needed="emit('gateRefreshed')"
|
||||
/>
|
||||
<section
|
||||
v-if="eligibility"
|
||||
class="rounded-xl border border-slate-200 bg-white p-4 shadow-sm dark:border-slate-800 dark:bg-slate-900"
|
||||
@@ -164,4 +186,5 @@ const blockingSummary = computed(() => {
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
@@ -5,6 +5,7 @@
|
||||
* orderExtractionProgressDisplay、Workflow 计数投影、vue-router、vue-i18n。
|
||||
* 逻辑:有 Workflow 投影时优先展示统一 counts;否则回退 handling_items / primary_notice;
|
||||
* 「查看处理详情」挂载详情抽屉;抽屉内证据/复核入口携带 focus+document_id 打开复核页;
|
||||
* 用户界面只展示业务原因,内部错误码仅保留在管理员审计中;
|
||||
* 文档与时间线加载失败支持独立就地重试;右侧 ShippingWorkflowTimeline 承接逐 PDF 明细。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
@@ -19,8 +20,10 @@ import type {
|
||||
import type {
|
||||
ShippingOrderExtractionDocumentResult,
|
||||
ShippingOrderExtractionProgressEvent,
|
||||
ShippingProcessGateUserSummary,
|
||||
ShippingWorkflowItemCounts,
|
||||
} from '../../types/shipping.api.types';
|
||||
import ProcessGateRecoveryCard from '@/features/shipping-process-gates/components/ProcessGateRecoveryCard.vue';
|
||||
import {
|
||||
listWorkspaceShippingOrderExtractionDocuments,
|
||||
listWorkspaceShippingOrderExtractionProgressEvents,
|
||||
@@ -60,6 +63,22 @@ const confirmCancelOpen = ref(false);
|
||||
const cancelReason = ref('');
|
||||
const injectedWorkflow = inject(SHIPPING_WORKFLOW_KEY, null);
|
||||
|
||||
/**
|
||||
* 从 Workflow Items 中取首个阻断 Gate 摘要,供 Run 级卡片展示。
|
||||
*/
|
||||
const runLevelProcessGate = computed((): ShippingProcessGateUserSummary | null => {
|
||||
const items = injectedWorkflow?.items.value || [];
|
||||
for (const item of items) {
|
||||
if (item.process_gate?.current_blocking_gate) return item.process_gate;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
const gateNavigationContext = computed(() => ({
|
||||
agentId: String(route.params.agentId || ''),
|
||||
conversationId: String(route.query.conversation_id || ''),
|
||||
}));
|
||||
|
||||
const detailsOpen = ref(false);
|
||||
const detailsLoading = ref(false);
|
||||
const detailsLoadFailed = ref(false);
|
||||
@@ -249,18 +268,7 @@ function handlingTitle(item: ShippingOrderExtractionHandlingItemState): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析原因码是否已有本地化文案。
|
||||
* @param code - 原因码
|
||||
*/
|
||||
function hasReasonLabel(code: string): boolean {
|
||||
const normalized = String(code || '').trim();
|
||||
if (!normalized) return false;
|
||||
return te(`chat.shippingOrderExtractionReason.${normalized}`)
|
||||
|| te(`chat.shippingOrderExtractionHandling.reason.${normalized}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析原因码文案;未知码回退通用提示(原始码放入技术详情)。
|
||||
* 解析原因码文案;未知或内部技术码统一回退为可执行的业务提示。
|
||||
* @param code - 原因码
|
||||
*/
|
||||
function reasonLabel(code: string): string {
|
||||
@@ -272,16 +280,6 @@ function reasonLabel(code: string): string {
|
||||
return te(freezeKey) ? t(freezeKey) : t('chat.shippingOrderExtractionReasonUnknown');
|
||||
}
|
||||
|
||||
/**
|
||||
* 收集事项中无本地化文案的原因码,供可展开技术详情展示。
|
||||
* @param item - 处理事项
|
||||
*/
|
||||
function unknownReasonCodes(item: ShippingOrderExtractionHandlingItemState): string[] {
|
||||
return (item.reasonCodes || [])
|
||||
.map((code) => String(code || '').trim())
|
||||
.filter((code) => code && !hasReasonLabel(code));
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开订单复核工作台(Chat order-review 模式)。
|
||||
* @param options.documentId - 可选,定位到具体 PDF
|
||||
@@ -536,6 +534,16 @@ function openCancelConfirm() {
|
||||
<span v-if="workflowLastActivityLabel" class="ml-1">· {{ workflowLastActivityLabel }}</span>
|
||||
</div>
|
||||
|
||||
<ProcessGateRecoveryCard
|
||||
v-if="runLevelProcessGate?.current_blocking_gate"
|
||||
class="mt-2"
|
||||
:summary="runLevelProcessGate"
|
||||
:can-handle="true"
|
||||
:navigation-context="gateNavigationContext"
|
||||
@refreshed="emit('refresh')"
|
||||
@refresh-needed="emit('refresh')"
|
||||
/>
|
||||
|
||||
<div
|
||||
v-if="handlingItems.length"
|
||||
class="mt-2 space-y-1.5"
|
||||
@@ -569,18 +577,6 @@ function openCancelConfirm() {
|
||||
<div v-if="item.reasonCodes.length" class="mt-1 opacity-80">
|
||||
{{ t('chat.shippingOrderExtractionHandling.reasonPrefix') }}
|
||||
{{ item.reasonCodes.slice(0, 4).map(reasonLabel).join(';') }}
|
||||
<details
|
||||
v-if="unknownReasonCodes(item).length"
|
||||
class="mt-1"
|
||||
data-testid="shipping-order-extraction-reason-tech"
|
||||
>
|
||||
<summary class="cursor-pointer opacity-90">
|
||||
{{ t('chat.shippingOrderExtractionReasonTechDetails') }}
|
||||
</summary>
|
||||
<code class="mt-1 block break-all text-[11px]">
|
||||
{{ unknownReasonCodes(item).join(', ') }}
|
||||
</code>
|
||||
</details>
|
||||
</div>
|
||||
<div
|
||||
v-if="affectedRows(item).length"
|
||||
|
||||
@@ -4,14 +4,17 @@
|
||||
* 依赖:vue-i18n、useMessage、useShippingNoticeWorkflow(inject 或自建)、DetailDrawer、ReasonDialog。
|
||||
* 逻辑:多批次时展示切换器;Items 以文件名为主标题;
|
||||
* 分组进行中/待处理/待复核/待人工上传登记/失败/已完成(登记前不得进已完成);
|
||||
* 「仅看待处理」过滤;查看进度 / 取消 / 重试重识别;取消与重识别用应用内原因弹窗。
|
||||
* 「仅看待处理」过滤;待复核项提供直接进入复核工作台;查看进度 / 取消 / 重试重识别;
|
||||
* 取消与重识别用应用内原因弹窗。侧栏在桌面端可收窄,在窄屏自动占满宽度。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, inject, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { ChevronDown, ChevronRight, RefreshCw } from 'lucide-vue-next';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import ProcessGateRecoveryCard from '@/features/shipping-process-gates/components/ProcessGateRecoveryCard.vue';
|
||||
import {
|
||||
getWorkspaceShippingWorkflowItem,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
@@ -39,6 +42,13 @@ const props = defineProps<{
|
||||
|
||||
const { t, te, locale } = useI18n();
|
||||
const msg = useMessage();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
const gateNavigationContext = computed(() => ({
|
||||
agentId: String(route.params.agentId || ''),
|
||||
conversationId: String(props.conversationId || route.query.conversation_id || ''),
|
||||
}));
|
||||
|
||||
const injected = inject(SHIPPING_WORKFLOW_KEY, null);
|
||||
/** 父级已 provide/传入时本地 composable 以空 conversationId 待机,避免双轮询。 */
|
||||
@@ -72,6 +82,31 @@ const items = computed((): ShippingWorkflowItem[] => ctl.value.items.value);
|
||||
const loading = computed(() => ctl.value.loading.value);
|
||||
const error = computed(() => ctl.value.error.value);
|
||||
|
||||
/**
|
||||
* 打开当前 PDF 对应的人工复核工作台。
|
||||
* 核心逻辑:复核入口必须复用当前 WorkflowItem 的 Run/Case/文档上下文,
|
||||
* 避免用户从侧栏进入后还要重新寻找待处理文件。
|
||||
*/
|
||||
async function openReview(item: ShippingWorkflowItem) {
|
||||
const runNo = String(item.current_run_no || '').trim();
|
||||
if (!runNo) return;
|
||||
const query: Record<string, string> = {
|
||||
mode: 'order-review',
|
||||
run_no: runNo,
|
||||
focus: 'draft',
|
||||
document_id: String(item.current_document_id || ''),
|
||||
};
|
||||
const caseNo = String(item.current_case_no || '').trim();
|
||||
if (caseNo) query.case_no = caseNo;
|
||||
const conversationId = String(props.conversationId || route.query.conversation_id || '').trim();
|
||||
if (conversationId) query.conversation_id = conversationId;
|
||||
await router.push({
|
||||
name: 'Chat',
|
||||
params: { agentId: String(route.params.agentId || '') },
|
||||
query,
|
||||
});
|
||||
}
|
||||
|
||||
const counts = computed(() => workflow.value?.counts || {
|
||||
total: items.value.length,
|
||||
processing: 0,
|
||||
@@ -202,7 +237,7 @@ const groupOrder: ItemGroupKey[] = [
|
||||
*/
|
||||
function statusLabel(status: string): string {
|
||||
const key = `chat.shippingWorkflow.itemStatus.${status}`;
|
||||
return te(key) ? t(key) : status;
|
||||
return te(key) ? t(key) : t('chat.shippingWorkflow.itemStatus.unknown');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -286,6 +321,36 @@ function openReparseDialog(item: ShippingWorkflowItem) {
|
||||
reasonDialogOpen.value = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将重新识别失败转换为可执行提示,而不是直接展示内部配置错误。
|
||||
* @param error - API 层 BusinessError 或未知异常
|
||||
* @returns 面向业务人员的分层错误提示
|
||||
*/
|
||||
function reparseErrorMessage(error: unknown): { title: string; message: string } {
|
||||
if (!(error instanceof BusinessError)) {
|
||||
return { title: t('chat.shippingWorkflow.reparseError.title'), message: t('chat.shippingWorkflow.reparseError.generic') };
|
||||
}
|
||||
const details = error.details || {};
|
||||
const code = String(error.code || '').toUpperCase();
|
||||
const requestId = error.requestId ? `\n${t('chat.shippingWorkflow.reparseError.requestId', { id: error.requestId })}` : '';
|
||||
if (code.includes('SCHEMA_VERSION_INVALID') || code.includes('SNAPSHOT_OBSOLETE') || code.includes('CANDIDATE_SOURCE_CHANGED')) {
|
||||
return {
|
||||
title: t('chat.shippingWorkflow.reparseError.title'),
|
||||
message: `${t('chat.shippingWorkflow.reparseError.schemaUnavailable')}\n${t('chat.shippingWorkflow.reparseError.fallback')}\n${t('chat.shippingWorkflow.reparseError.contactAdmin')}${requestId}`,
|
||||
};
|
||||
}
|
||||
if (code.includes('REPARSE_PENDING')) {
|
||||
return { title: t('chat.shippingWorkflow.reparseError.title'), message: t('chat.shippingWorkflow.reparseError.pending') };
|
||||
}
|
||||
const fallback = details.fallback_available === true
|
||||
? `\n${t('chat.shippingWorkflow.reparseError.fallback')}`
|
||||
: '';
|
||||
return {
|
||||
title: t('chat.shippingWorkflow.reparseError.title'),
|
||||
message: `${error.message || t('chat.shippingWorkflow.reparseError.generic')}${fallback}${requestId}`,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 原因弹窗确认:按 action 取消或重识别。
|
||||
*/
|
||||
@@ -316,8 +381,7 @@ async function onReasonConfirm(payload: { reason: string; comment?: string }) {
|
||||
// 失败时关闭原因确认框,避免与错误提示双遮罩。
|
||||
reasonDialogOpen.value = false;
|
||||
reasonDialogItem.value = null;
|
||||
const message = err instanceof BusinessError ? err.message : t('errors.generic');
|
||||
msg.error(message);
|
||||
msg.error(reparseErrorMessage(err));
|
||||
} finally {
|
||||
actionBusyItemNo.value = null;
|
||||
}
|
||||
@@ -333,7 +397,8 @@ watch(
|
||||
|
||||
<template>
|
||||
<aside
|
||||
class="flex w-72 shrink-0 flex-col border-l border-default bg-surface shadow-[-8px_0_24px_rgba(15,23,42,0.04)]"
|
||||
class="flex shrink-0 flex-col border-l border-default bg-surface shadow-[-8px_0_24px_rgba(15,23,42,0.04)] transition-[width] duration-200"
|
||||
:class="collapsed ? 'w-14 md:w-14' : 'w-full md:w-72'"
|
||||
data-testid="shipping-workflow-timeline"
|
||||
>
|
||||
<div class="flex w-full items-center gap-1 border-b border-default px-2 py-2">
|
||||
@@ -342,7 +407,7 @@ watch(
|
||||
class="flex min-w-0 flex-1 items-center justify-between gap-2 rounded-md px-1 py-1 text-left hover:bg-surface-muted/60"
|
||||
@click="collapsed = !collapsed"
|
||||
>
|
||||
<div class="min-w-0">
|
||||
<div v-if="!collapsed" class="min-w-0">
|
||||
<div class="text-sm font-semibold text-primary">
|
||||
{{ t('chat.shippingWorkflow.title') }}
|
||||
</div>
|
||||
@@ -528,7 +593,26 @@ watch(
|
||||
<div v-if="item.last_activity_at || item.updated_at" class="mt-0.5 text-[11px] text-muted">
|
||||
{{ formatUpdatedLabel(item.last_activity_at || item.updated_at) }}
|
||||
</div>
|
||||
<ProcessGateRecoveryCard
|
||||
v-if="item.process_gate?.current_blocking_gate"
|
||||
class="mt-2"
|
||||
:summary="item.process_gate"
|
||||
:can-handle="true"
|
||||
:navigation-context="gateNavigationContext"
|
||||
@refreshed="() => void ctl.refresh()"
|
||||
@refresh-needed="() => void ctl.refresh()"
|
||||
/>
|
||||
<div class="mt-2 flex flex-wrap gap-2">
|
||||
<button
|
||||
v-if="groupKey === 'pending_review' && item.current_run_no"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded-md bg-brand-600 px-2.5 py-1 text-[11px] font-semibold text-white shadow-sm hover:bg-brand-700 disabled:opacity-50"
|
||||
:disabled="actionBusyItemNo === item.item_no"
|
||||
data-testid="shipping-workflow-action-open-review"
|
||||
@click="openReview(item)"
|
||||
>
|
||||
{{ t('chat.shippingWorkflow.actions.openReview') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 text-[11px] font-medium text-brand-700 hover:underline"
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* 依赖:无(纯类型模块)。
|
||||
* 逻辑:shipping.api.ts 与 Chat/工作台组件统一引用本文件 DTO 类型。
|
||||
* 阶段 0 冻结用户可见阶段、健康提示、取消元数据与审计 DTO;写路径与 UI 在后续阶段启用。
|
||||
* 门禁恢复 Phase 1:ShippingProcessGate* 联合类型与 Python process_gate_contract 对齐。
|
||||
*/
|
||||
export type InventorySourceStatus =
|
||||
| 'unresolved'
|
||||
@@ -218,6 +219,138 @@ export interface ShippingProcessFieldGate {
|
||||
issues?: ShippingParseIssue[];
|
||||
}
|
||||
|
||||
/**
|
||||
* 全门禁中断恢复 — 业务门禁编码(与 process_gate_contract.PROCESS_GATE_CODES 对齐)。
|
||||
* Phase 1 仅冻结类型;统一 Execution API 在后续阶段接线。
|
||||
*/
|
||||
export type ShippingProcessGateCode =
|
||||
| 'document_materialization'
|
||||
| 'layout_parsing'
|
||||
| 'document_profile_routing'
|
||||
| 'order_field_extraction'
|
||||
| 'field_completeness'
|
||||
| 'reservation_validation'
|
||||
| 'customer_resolution'
|
||||
| 'duplicate_detection'
|
||||
| 'field_conflict_resolution'
|
||||
| 'inventory_source_routing'
|
||||
| 'order_freeze_readiness'
|
||||
| 'task_creation'
|
||||
| 'inventory_preparation'
|
||||
| 'inventory_field_mapping'
|
||||
| 'inventory_matching'
|
||||
| 'inventory_sufficiency'
|
||||
| 'excel_readiness'
|
||||
| 'artifact_generation'
|
||||
| 'manual_upload_handoff';
|
||||
|
||||
/** 门禁实例状态(与 PROCESS_GATE_STATUSES 对齐)。 */
|
||||
export type ShippingProcessGateStatus =
|
||||
| 'pending'
|
||||
| 'queued'
|
||||
| 'running'
|
||||
| 'passed'
|
||||
| 'blocked_retryable'
|
||||
| 'blocked_manual'
|
||||
| 'waiting_external'
|
||||
| 'failed_terminal'
|
||||
| 'invalidated'
|
||||
| 'skipped';
|
||||
|
||||
/**
|
||||
* 服务端下发的主要恢复动作码(与 PROCESS_GATE_ACTION_CODES 对齐)。
|
||||
* 客户端禁止本地发明或提交起始阶段 / 目标状态 / Worker 名。
|
||||
*/
|
||||
export type ShippingProcessGateActionCode =
|
||||
| 'rematerialize_document'
|
||||
| 'retry_layout_parsing'
|
||||
| 'reroute_document_profile'
|
||||
| 'open_profile_review'
|
||||
| 'retry_order_extraction'
|
||||
| 'open_order_review'
|
||||
| 'edit_order_fields'
|
||||
| 'revalidate_reservation'
|
||||
| 'edit_reservation'
|
||||
| 'retry_customer_resolution'
|
||||
| 'confirm_customer'
|
||||
| 'retry_duplicate_detection'
|
||||
| 'adjudicate_duplicate'
|
||||
| 'resolve_field_conflicts'
|
||||
| 'retry_with_latest_rules'
|
||||
| 'open_inventory_source_review'
|
||||
| 'adopt_rule_suggestion'
|
||||
| 'keep_manual_inventory_decision'
|
||||
| 'recheck_freeze_readiness'
|
||||
| 'retry_task_creation'
|
||||
| 'retry_inventory_preparation'
|
||||
| 'poll_inventory_preparation'
|
||||
| 'upload_inventory_file'
|
||||
| 'retry_inventory_field_mapping'
|
||||
| 'confirm_inventory_field_mapping'
|
||||
| 'retry_inventory_matching'
|
||||
| 'open_inventory_match_review'
|
||||
| 'recheck_inventory_sufficiency'
|
||||
| 'open_shortage_review'
|
||||
| 'recheck_excel_readiness'
|
||||
| 'regenerate_excel_artifact'
|
||||
| 'regenerate_manual_upload_todo';
|
||||
|
||||
/** 门禁责任方(与 PROCESS_GATE_RESPONSIBLE_PARTIES 对齐)。 */
|
||||
export type ShippingProcessGateResponsibleParty =
|
||||
| 'system'
|
||||
| 'worker'
|
||||
| 'owner'
|
||||
| 'admin'
|
||||
| 'external';
|
||||
|
||||
/** Gate 用户安全投影(与 serialize_process_gate include_diagnostics=false 对齐)。 */
|
||||
export interface ShippingProcessGateProjection {
|
||||
gate_code: ShippingProcessGateCode | string;
|
||||
sequence_no: number;
|
||||
label?: string | null;
|
||||
status: ShippingProcessGateStatus | string;
|
||||
evaluation_version: number;
|
||||
blocking_reason_code?: string | null;
|
||||
blocking_reason?: Record<string, unknown> | null;
|
||||
findings?: Array<Record<string, unknown>>;
|
||||
next_action_code?: ShippingProcessGateActionCode | string | null;
|
||||
passed_at?: string | null;
|
||||
latest_attempt?: {
|
||||
attempt_no?: number;
|
||||
status?: string;
|
||||
} | null;
|
||||
}
|
||||
|
||||
/** Execution 用户 Gate 摘要(ui_state.process_gate / GET execution 对齐)。 */
|
||||
export interface ShippingProcessGateUserSummary {
|
||||
execution_no: string;
|
||||
status: string;
|
||||
current_blocking_gate?: ShippingProcessGateProjection | null;
|
||||
blocking_reason_code?: string | null;
|
||||
blocking_message?: string | null;
|
||||
next_action_code?: ShippingProcessGateActionCode | string | null;
|
||||
responsible_party?: ShippingProcessGateResponsibleParty | string | null;
|
||||
diagnostic_hint?: string | null;
|
||||
case_no?: string | null;
|
||||
review_case_no?: string | null;
|
||||
review_run_no?: string | null;
|
||||
task_no?: string | null;
|
||||
navigation?: {
|
||||
target?: 'order_review' | 'task_workspace' | string;
|
||||
focus?: string | null;
|
||||
run_no?: string | null;
|
||||
case_no?: string | null;
|
||||
task_no?: string | null;
|
||||
} | null;
|
||||
gates_track?: Array<{
|
||||
gate_code: ShippingProcessGateCode | string;
|
||||
label?: string | null;
|
||||
status: string;
|
||||
sequence_no: number;
|
||||
}>;
|
||||
current_findings?: Array<Record<string, unknown>>;
|
||||
}
|
||||
|
||||
export interface ShippingFieldEvidenceItem {
|
||||
field?: string;
|
||||
line_index?: number;
|
||||
@@ -468,8 +601,12 @@ export interface ShippingTaskUiState {
|
||||
allowed_actions?: string[] | null;
|
||||
/** STP 履约事实;仅后端投影,前端禁止二次推导 */
|
||||
stp_facts?: ShippingStpFacts | null;
|
||||
/** 统一 Gate 用户摘要(优先于 legacy action_buttons) */
|
||||
process_gate?: ShippingProcessGateUserSummary | null;
|
||||
};
|
||||
action_buttons: ShippingChatAction[];
|
||||
/** 顶层 Gate 摘要;与 summary.process_gate 同源 */
|
||||
process_gate?: ShippingProcessGateUserSummary | null;
|
||||
updated_at?: string | null;
|
||||
}
|
||||
|
||||
@@ -1061,6 +1198,33 @@ export interface ShippingOrderReviewRun {
|
||||
items: ShippingOrderReviewCaseSummary[];
|
||||
}
|
||||
|
||||
/** 库存路由规则版本摘要(行级投影 / 规则建议内复用)。 */
|
||||
export interface ShippingOrderReviewInventoryRuleVersion {
|
||||
rule_id?: number;
|
||||
rule_code?: string;
|
||||
version?: number;
|
||||
}
|
||||
|
||||
/** 库存路由命中规则摘要。 */
|
||||
export interface ShippingOrderReviewInventoryMatchedRule {
|
||||
rule_id?: number;
|
||||
rule_code?: string;
|
||||
version?: number;
|
||||
priority?: number;
|
||||
action_type?: string;
|
||||
scope?: string;
|
||||
}
|
||||
|
||||
/** 规则引擎产出的库存源建议;人工覆盖后仍可对照。 */
|
||||
export interface ShippingOrderReviewInventoryRuleSuggestion {
|
||||
source_codes?: string[];
|
||||
raw_source_codes?: string[];
|
||||
unavailable_source_codes?: string[];
|
||||
routing_status?: string;
|
||||
rule_versions?: ShippingOrderReviewInventoryRuleVersion[];
|
||||
matched_rule_ids?: number[];
|
||||
}
|
||||
|
||||
/** 建单前资格行级投影;与后端 validation.line_projections 对齐。 */
|
||||
export interface ShippingOrderReviewBuildEligibilityLineProjection {
|
||||
line_key?: string | null;
|
||||
@@ -1068,6 +1232,22 @@ export interface ShippingOrderReviewBuildEligibilityLineProjection {
|
||||
effective_reservation_id?: string | null;
|
||||
inventory_source_hint?: string | null;
|
||||
candidate_inventory_source_codes?: string[];
|
||||
/** 规则原始命中源(含不可用) */
|
||||
raw_rule_source_codes?: string[];
|
||||
/** 规则建议可用源 */
|
||||
rule_suggestion_source_codes?: string[];
|
||||
/** 规则命中但当前不可用的源 */
|
||||
unavailable_source_codes?: string[];
|
||||
/** 不可用源 → 原因文案 */
|
||||
unavailable_reasons?: Record<string, string>;
|
||||
matched_rule_ids?: number[];
|
||||
matched_rules?: ShippingOrderReviewInventoryMatchedRule[];
|
||||
rule_versions?: ShippingOrderReviewInventoryRuleVersion[];
|
||||
rule_suggestion?: ShippingOrderReviewInventoryRuleSuggestion;
|
||||
/** 人工结果与最新规则建议不一致,待采纳/保留 */
|
||||
suggestion_pending?: boolean;
|
||||
/** 与 rule_suggestion_source_codes 同义兼容字段 */
|
||||
rule_source_codes?: string[];
|
||||
routing_status?: string;
|
||||
can_build?: boolean;
|
||||
block_reason?: string | null;
|
||||
@@ -1093,6 +1273,20 @@ export interface ShippingOrderReviewInventoryCandidatesWrite {
|
||||
reason: string;
|
||||
}
|
||||
|
||||
/** 整单或行级重新匹配库存路由写请求。 */
|
||||
export interface ShippingOrderReviewInventoryRoutingRerouteWrite {
|
||||
expected_draft_version: number;
|
||||
idempotency_key?: string;
|
||||
line_key?: string;
|
||||
}
|
||||
|
||||
/** 采纳规则建议 / 保留人工路由写请求。 */
|
||||
export interface ShippingOrderReviewInventoryRoutingDecisionWrite {
|
||||
expected_draft_version: number;
|
||||
idempotency_key?: string;
|
||||
reason?: string;
|
||||
}
|
||||
|
||||
export interface ShippingOrderReviewCase {
|
||||
case_no: string;
|
||||
run_no: string;
|
||||
@@ -1114,6 +1308,7 @@ export interface ShippingOrderReviewCase {
|
||||
} | null;
|
||||
available_actions: string[];
|
||||
llm_suggestions?: ShippingOrderReviewLlmSuggestion[];
|
||||
process_gate?: ShippingProcessGateUserSummary | null;
|
||||
}
|
||||
|
||||
export interface ShippingOrderReviewConfirmResponse {
|
||||
@@ -1360,6 +1555,9 @@ export interface ShippingWorkflowItem {
|
||||
reparse_kind?: 'case_version' | 'failed_run_retry' | string | null;
|
||||
/** 详情接口 include_events=true 时附带。 */
|
||||
events?: ShippingWorkflowEvent[];
|
||||
/** 当前 WorkflowItem 版本关联 Execution 的用户 Gate 摘要。 */
|
||||
process_gate?: ShippingProcessGateUserSummary | null;
|
||||
gate_user_hint?: string | null;
|
||||
}
|
||||
|
||||
/** Workflow 批次投影;与 serialize_workflow 对齐。 */
|
||||
|
||||
@@ -5,10 +5,12 @@
|
||||
ReviewLineNoOverrideDialog、ReviewBuildEligibilityPanel、ReviewInventoryCandidatesPanel、
|
||||
ReviewWorkflowProgressPanel、ReviewLlmSuggestionPanel。
|
||||
逻辑:左 PDF 预览 + 中部订单编辑 + 右侧独立建单资格/库存候选门禁区(sticky);
|
||||
build_eligibility 驱动建单门禁与零候选时已启用库存源选择;破坏性操作二次确认;
|
||||
build_eligibility 驱动建单门禁、路由恢复(reroute / adopt / keep)与零候选时已启用库存源选择;
|
||||
破坏性操作二次确认;
|
||||
底部操作窄屏纵向堆叠(异常操作在上、保存/确认建单在下且确认最后);
|
||||
初始加载失败提供就地重试(再次调用 load);
|
||||
确认后挂载自动进度面板并轮询 Workflow Item;内部项次 line_no 编辑须经覆盖原因弹窗;
|
||||
确认后挂载自动进度面板;重识别按 WorkflowItem 真实阶段展示并在新版就绪后自动切换;
|
||||
内部项次 line_no 编辑须经覆盖原因弹窗;
|
||||
AI 建议请求/裁决走 useShippingOrderReview.requestSuggestion / decideSuggestion。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
@@ -53,7 +55,7 @@ const {
|
||||
draftConflictDiffLines,
|
||||
buildEligibility,
|
||||
canConfirmBuild,
|
||||
manualInventoryLines,
|
||||
routingRecoveryLines,
|
||||
isViewingHistoricalVersion,
|
||||
isReadOnly,
|
||||
loading,
|
||||
@@ -80,6 +82,9 @@ const {
|
||||
deleteLine,
|
||||
validate,
|
||||
setLineInventoryCandidates,
|
||||
rerouteInventoryRouting,
|
||||
adoptInventoryRoutingSuggestion,
|
||||
keepManualInventoryRouting,
|
||||
confirm,
|
||||
createManualDraft,
|
||||
markNonOrder,
|
||||
@@ -92,6 +97,10 @@ const {
|
||||
editable,
|
||||
showWorkflowProgress,
|
||||
workflowProgressPolling,
|
||||
reparseProgressActive,
|
||||
reparseProgressPolling,
|
||||
reparseProgressRefreshFailed,
|
||||
reparseProgressStage,
|
||||
} = useShippingOrderReview();
|
||||
const msg = useMessage();
|
||||
|
||||
@@ -100,6 +109,11 @@ const agentId = computed(() => String(route.params.agentId || ''));
|
||||
const conversationId = computed(() => String(page.conversationId || route.query.conversation_id || ''));
|
||||
const itemNoFromQuery = computed(() => String(route.query.item_no || ''));
|
||||
const reviewFocus = computed(() => String(route.query.focus || '').trim());
|
||||
/** Gate 恢复卡片导航上下文(复核台深链)。 */
|
||||
const reviewGateNavigationContext = computed(() => ({
|
||||
agentId: agentId.value,
|
||||
conversationId: conversationId.value,
|
||||
}));
|
||||
const focusedEvidenceRef = ref<{ fieldId: string; lineIndex?: number } | null>(null);
|
||||
|
||||
watch(
|
||||
@@ -291,8 +305,24 @@ const caseStatusLabel = (status: string) => {
|
||||
};
|
||||
const statusBannerText = computed(() => {
|
||||
if (!statusMessage.value) return '';
|
||||
return t(`chat.shippingOrderReview.statusBanner.${statusMessage.value}`);
|
||||
const key = `chat.shippingOrderReview.statusBanner.${statusMessage.value}`;
|
||||
return te(key) ? t(key) : t('chat.shippingOrderReview.statusBanner.unknown');
|
||||
});
|
||||
|
||||
/** 将服务端复核问题码转换为业务说明;未知代码不得直接展示给用户。 */
|
||||
const reviewIssueLabel = (code?: string) => {
|
||||
const normalized = String(code || '').trim();
|
||||
const key = `chat.shippingOrderReview.issueCodes.${normalized}`;
|
||||
return normalized && te(key) ? t(key) : t('chat.shippingOrderReview.issueCodes.unknown');
|
||||
};
|
||||
|
||||
/** 重识别阶段顺序;仅展示后端状态,不推算虚假百分比。 */
|
||||
const reparseProgressStages = ['submitted', 'layout_parsing', 'extracting', 'draft_ready'] as const;
|
||||
const reparseProgressIndex = computed(() => (
|
||||
reparseProgressStage.value === 'failed'
|
||||
? reparseProgressStages.indexOf('extracting')
|
||||
: reparseProgressStages.indexOf(reparseProgressStage.value)
|
||||
));
|
||||
const workItemVersionLabel = computed(() => {
|
||||
const versionNo = workItem.value?.current_version_no;
|
||||
if (!versionNo) return '';
|
||||
@@ -359,6 +389,27 @@ const submitInventoryCandidates = async (payload: { lineKey: string; sourceCodes
|
||||
await reportSave(() => setLineInventoryCandidates(payload.lineKey, payload.sourceCodes, payload.reason));
|
||||
};
|
||||
|
||||
/**
|
||||
* 重新匹配库存路由(行级或整单);进度复用 saving。
|
||||
*/
|
||||
const onInventoryRoutingReroute = async (lineKey?: string) => {
|
||||
await reportSave(() => rerouteInventoryRouting(lineKey));
|
||||
};
|
||||
|
||||
/**
|
||||
* 采纳待决规则建议。
|
||||
*/
|
||||
const onInventoryRoutingAdopt = async (payload: { lineKey: string; reason?: string }) => {
|
||||
await reportSave(() => adoptInventoryRoutingSuggestion(payload.lineKey, payload.reason));
|
||||
};
|
||||
|
||||
/**
|
||||
* 保留当前人工库存路由结果。
|
||||
*/
|
||||
const onInventoryRoutingKeep = async (payload: { lineKey: string; reason?: string }) => {
|
||||
await reportSave(() => keepManualInventoryRouting(payload.lineKey, payload.reason));
|
||||
};
|
||||
|
||||
/** 打开指定类型的二次确认弹窗。 */
|
||||
const openActionDialog = (action: ReviewConfirmAction) => {
|
||||
pendingAction.value = action;
|
||||
@@ -556,7 +607,10 @@ const selectVersionFromHistory = async (caseNo: string) => {
|
||||
*/
|
||||
const jumpToCurrentVersion = async () => {
|
||||
const target = await openCurrentVersion();
|
||||
if (!target) return;
|
||||
if (!target) {
|
||||
msg.warning(t('chat.shippingOrderReview.currentVersionUnavailable'));
|
||||
return;
|
||||
}
|
||||
await router.replace({
|
||||
query: {
|
||||
...route.query,
|
||||
@@ -776,6 +830,64 @@ watch(
|
||||
/>
|
||||
</div>
|
||||
|
||||
<section
|
||||
v-if="reparseProgressActive"
|
||||
class="mx-4 mt-3 rounded-xl border border-sky-200 bg-white p-4 shadow-sm dark:border-sky-900 dark:bg-slate-900"
|
||||
data-testid="review-reparse-progress"
|
||||
>
|
||||
<div class="flex flex-wrap items-start justify-between gap-2">
|
||||
<div>
|
||||
<h2 class="text-sm font-semibold">{{ t('chat.shippingOrderReview.reparseProgress.title') }}</h2>
|
||||
<p class="mt-0.5 text-xs text-slate-500 dark:text-slate-400">
|
||||
{{ t('chat.shippingOrderReview.reparseProgress.subtitle') }}
|
||||
</p>
|
||||
</div>
|
||||
<span v-if="reparseProgressPolling" class="text-xs text-sky-700 dark:text-sky-300">
|
||||
{{ t('chat.shippingOrderReview.reparseProgress.polling') }}
|
||||
</span>
|
||||
</div>
|
||||
<ol class="mt-3 grid gap-2 sm:grid-cols-4">
|
||||
<li
|
||||
v-for="(stage, index) in reparseProgressStages"
|
||||
:key="stage"
|
||||
class="rounded-lg border px-3 py-2 text-xs"
|
||||
:class="index < reparseProgressIndex
|
||||
? 'border-emerald-200 bg-emerald-50 text-emerald-900 dark:border-emerald-900 dark:bg-emerald-950/40 dark:text-emerald-100'
|
||||
: index === reparseProgressIndex
|
||||
? 'border-sky-300 bg-sky-50 text-sky-950 dark:border-sky-800 dark:bg-sky-950/40 dark:text-sky-100'
|
||||
: 'border-slate-200 bg-slate-50 text-slate-500 dark:border-slate-800 dark:bg-slate-950/40 dark:text-slate-400'"
|
||||
:data-testid="`review-reparse-stage-${stage}`"
|
||||
>
|
||||
<span class="font-semibold">{{ index + 1 }}.</span>
|
||||
{{ t(`chat.shippingOrderReview.reparseProgress.stages.${stage}`) }}
|
||||
</li>
|
||||
</ol>
|
||||
<p
|
||||
v-if="reparseProgressRefreshFailed"
|
||||
class="mt-3 text-xs text-amber-700 dark:text-amber-300"
|
||||
data-testid="review-reparse-refresh-failed"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.reparseProgress.refreshFailed') }}
|
||||
</p>
|
||||
<p
|
||||
v-if="reparseProgressStage === 'failed'"
|
||||
class="mt-3 flex flex-wrap items-center justify-between gap-2 rounded-lg border border-rose-200 bg-rose-50 px-3 py-2 text-xs text-rose-800 dark:border-rose-900 dark:bg-rose-950/40 dark:text-rose-200"
|
||||
data-testid="review-reparse-failed"
|
||||
>
|
||||
<span>{{ t('chat.shippingOrderReview.reparseProgress.failed') }}</span>
|
||||
<button
|
||||
v-if="activeCase?.available_actions.includes('reparse')"
|
||||
type="button"
|
||||
class="rounded border border-rose-300 px-2.5 py-1 font-medium hover:bg-rose-100 disabled:opacity-50 dark:border-rose-800 dark:hover:bg-rose-900/50"
|
||||
:disabled="saving"
|
||||
data-testid="review-reparse-retry"
|
||||
@click="openActionDialog('reparse')"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.reparseProgress.retry') }}
|
||||
</button>
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<div v-if="loading" class="p-8 text-sm text-slate-600 dark:text-slate-300">{{ t('chat.shippingOrderReview.loading') }}</div>
|
||||
<div
|
||||
v-else-if="loadFailed"
|
||||
@@ -863,7 +975,9 @@ watch(
|
||||
|
||||
<div v-if="activeCase?.draft?.issues?.length" class="rounded-lg border border-amber-300 bg-amber-50 p-3 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-100">
|
||||
<div class="font-semibold">{{ t('chat.shippingOrderReview.issues') }}</div>
|
||||
<div v-for="issue in activeCase.draft.issues" :key="`${issue.code}-${issue.severity}`" class="mt-1">{{ issue.code }}</div>
|
||||
<div v-for="issue in activeCase.draft.issues" :key="`${issue.code}-${issue.severity}`" class="mt-1">
|
||||
{{ reviewIssueLabel(issue.code) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ReviewLlmSuggestionPanel
|
||||
@@ -1054,13 +1168,22 @@ watch(
|
||||
data-testid="review-build-gate-rail"
|
||||
:aria-label="t('chat.shippingOrderReview.buildGateRail')"
|
||||
>
|
||||
<ReviewBuildEligibilityPanel :eligibility="buildEligibility" />
|
||||
<ReviewBuildEligibilityPanel
|
||||
:eligibility="buildEligibility"
|
||||
:process-gate="activeCase?.process_gate"
|
||||
:can-handle-gate="editable"
|
||||
:navigation-context="reviewGateNavigationContext"
|
||||
@gate-refreshed="reloadLatestDraft"
|
||||
/>
|
||||
<ReviewInventoryCandidatesPanel
|
||||
:lines="manualInventoryLines"
|
||||
:lines="routingRecoveryLines"
|
||||
:enabled-source-codes="buildEligibility?.enabled_inventory_source_codes || []"
|
||||
:editable="editable"
|
||||
:saving="saving"
|
||||
@submit="submitInventoryCandidates"
|
||||
@reroute="onInventoryRoutingReroute"
|
||||
@adopt="onInventoryRoutingAdopt"
|
||||
@keep="onInventoryRoutingKeep"
|
||||
/>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user