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"
|
||||
|
||||
Reference in new issue
Block a user