feat(shipping-notice): 落地 XFA 拆分、版面签名、统一进度与处理域履约

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
hugoandCursor committed 2026-08-06 10:18:37 +08:00
1 parent 3a9fbac2fc
commit d2b3d74def
571 files changed
+78064 -24681

No files matched your search

@@ -3,7 +3,8 @@
* 用途:发货「我的待办」壳——Pending|Processing|Done + 识别 Run 续办表 + 右侧任务工作台或复核深链。
* 依赖:shipping-tasks.api(my-todos)、shipping.api 详情、ShippingTaskWorkbench、ShippingRunProgressTable、useShippingTodoBadge。
* 逻辑:review_case 项用 review_run_no 打开人工复核;task 项打开任务处理工作台;
* 仅对进行中 Workflow/Task 自动刷新(前台 2s / 后台 8s)。
* 轮询仅依据 shipping_processing_status / process_status / Intake parse_status,
* 不回退 WorkflowItem lifecycle;created/queued/parsing Intake 持续刷新。
*/
<script setup lang="ts">
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
@@ -22,6 +23,14 @@ import {
type ShippingMyTodosCount,
} from '@/features/workspace/api/shipping-tasks.api';
import { useShippingTodoBadge } from '../composables/useShippingTodoBadge';
import {
IN_PROGRESS_PROCESSING_STATUSES,
TERMINAL_PROCESSING_STATUSES,
} from '@/features/chat/shipping/shippingProcessingFulfillment';
import {
IN_PROGRESS_PROCESS,
isShippingTodoListItemInProgress,
} from './shippingTaskCenterPolling';
import ShippingTaskWorkbench from './ShippingTaskWorkbench.vue';
import ShippingRunProgressTable from './ShippingRunProgressTable.vue';
@@ -30,33 +39,29 @@ const FOREGROUND_POLL_MS = 2000;
/** 页面隐藏时后台轮询间隔。 */
const BACKGROUND_POLL_MS = 8000;
/** 仍视为进行中、需要自动刷新的任务 process_status。 */
const IN_PROGRESS_PROCESS = new Set([
'parsing',
'parsed',
'matching',
'matched',
'waiting_upload',
'uploading',
'upload_failed',
'exporting',
'needs_human',
'pending_void',
]);
/**
* 判断详情是否仍处于进行中。
* 核心逻辑:与列表同源——优先 shipping_processing_status;缺失时回退 process_status;
* 不回退 WorkflowItem lifecycle(UI-03)。
*/
function isDetailInProgress(task: ShippingTaskDetail | null): boolean {
if (!task) return false;
const unified = String(task.shipping_processing_status || '').trim().toLowerCase();
if (unified) {
if (TERMINAL_PROCESSING_STATUSES.has(unified)) return false;
return IN_PROGRESS_PROCESSING_STATUSES.has(unified);
}
const process = String(task.process_status || '').trim();
return IN_PROGRESS_PROCESS.has(process);
}
/** WorkflowItem 仍开放处理的生命周期(含待人工上传登记)。 */
const IN_PROGRESS_WORKFLOW_ITEM = new Set([
'queued',
'layout_parsing',
'extracting',
'building_order',
'inventory_matching',
'generating_excel',
'pending_review',
'manual_upload_pending',
'reparse_failed',
'failed',
]);
/**
* 判断列表项是否应触发轮询刷新。
* 核心逻辑:委托 isShippingTodoListItemInProgress(Intake created/queued/parsing 必须轮询)。
*/
function isListItemInProgress(item: ShippingTaskSummary): boolean {
return isShippingTodoListItemInProgress(item);
}
const route = useRoute();
const router = useRouter();
@@ -104,49 +109,43 @@ const selectedItem = computed(() =>
);
const isReviewSelection = computed(() => selectedItem.value?.item_kind === 'review_case'
|| Boolean(selectedItem.value?.review_run_no && !selectedItem.value?.task_no));
const isIntakeSelection = computed(() => selectedItem.value?.item_kind === 'order_intake'
|| Boolean(selectedItem.value?.intake_no && !selectedItem.value?.task_no && !selectedItem.value?.review_run_no));
/**
* 待办列表项稳定主键:复核用 case_no,任务用 task_no。
* 待办列表项稳定主键:复核用 case_no,Intake 用 intake_no,任务用 task_no。
*/
function todoItemKey(item: ShippingTaskSummary): string {
if (item.item_kind === 'review_case' || item.review_case_no) {
return String(item.todo_ref || item.review_case_no || item.review_run_no || '');
}
if (item.item_kind === 'order_intake' || item.intake_no) {
return String(item.todo_ref || item.intake_no || '');
}
return String(item.todo_ref || item.task_no || '');
}
/**
* 列表展示编号:复核显示 case_no,任务显示 SN。
* 列表展示编号:复核显示 case_no,Intake 显示 intake_no,任务显示 SN。
*/
function todoDisplayNo(item: ShippingTaskSummary): string {
if (item.item_kind === 'review_case' || item.review_case_no) {
return String(item.review_case_no || item.review_run_no || item.todo_ref || '—');
}
if (item.item_kind === 'order_intake' || item.intake_no) {
return String(item.intake_no || item.todo_ref || '—');
}
return String(item.task_no || item.todo_ref || '—');
}
/**
* 判断详情是否仍处于进行中(含绑定 WorkflowItem)。
*/
function isDetailInProgress(task: ShippingTaskDetail | null): boolean {
if (!task) return false;
const process = String(task.process_status || '').trim();
if (IN_PROGRESS_PROCESS.has(process)) return true;
const itemStatus = String(task.workflow_item?.lifecycle_status || '').trim();
return IN_PROGRESS_WORKFLOW_ITEM.has(itemStatus);
}
/**
* 是否应继续自动轮询:仅 processing 桶、进行中详情,或 runs 面。
* 是否应继续自动轮询:processing 桶、进行中详情,或 runs 面;列表项按统一投影 / process_status。
*/
const shouldAutoRefresh = computed(() => {
if (surface.value === 'runs') return true;
if (bucket.value === 'processing') return true;
if (isDetailInProgress(detail.value)) return true;
return tasks.value.some((item) => {
const status = String(item.process_status || '').trim();
return IN_PROGRESS_PROCESS.has(status) || item.item_kind === 'review_case';
});
return tasks.value.some((item) => isListItemInProgress(item));
});
/**
@@ -335,6 +334,20 @@ function openReview(item: ShippingTaskSummary) {
void router.push({ path: `/chat/${agentId}`, query });
}
/**
* 打开对话「本次处理中」卡,聚焦未建 OT 的 Intake 材料。
*/
function openIntakeConversation(item: ShippingTaskSummary) {
const agentId = Number(item.owner_agent_id || chatAgentId.value || 0);
if (!agentId) return;
const query: Record<string, string> = {};
const cid = String(item.conversation_id || '').trim();
if (cid) query.conversation_id = cid;
const intakeNo = String(item.intake_no || item.todo_ref || '').trim();
if (intakeNo) query.intake_no = intakeNo;
void router.push({ path: `/chat/${agentId}`, query });
}
/**
* 可选深链:打开 Chat 会话查看上下文(非履约写入口)。
*/
@@ -356,10 +369,17 @@ async function selectTodo(item: ShippingTaskSummary) {
const nextQuery: Record<string, string> = { ...route.query as Record<string, string> };
if (item.item_kind === 'review_case' || item.review_run_no) {
delete nextQuery.task_no;
delete nextQuery.intake_no;
if (item.review_run_no) nextQuery.run_no = String(item.review_run_no);
detail.value = null;
} else if (item.item_kind === 'order_intake' || item.intake_no) {
delete nextQuery.task_no;
delete nextQuery.run_no;
if (item.intake_no) nextQuery.intake_no = String(item.intake_no);
detail.value = null;
} else if (item.task_no) {
delete nextQuery.run_no;
delete nextQuery.intake_no;
nextQuery.task_no = item.task_no;
await loadDetail(item.task_no);
}
@@ -386,7 +406,12 @@ watch(selectedItem, (item) => {
detail.value = null;
return;
}
if (item.item_kind === 'review_case' || (item.review_run_no && !item.task_no)) {
if (
item.item_kind === 'review_case'
|| item.item_kind === 'order_intake'
|| (item.review_run_no && !item.task_no)
|| (item.intake_no && !item.task_no)
) {
detail.value = null;
return;
}
@@ -512,6 +537,7 @@ onBeforeUnmount(() => {
<option value="review">{{ $t('workspace.shippingNotice.myTodos.filters.review') }}</option>
<option value="exception">{{ $t('workspace.shippingNotice.myTodos.filters.exception') }}</option>
<option value="manual_upload">{{ $t('workspace.shippingNotice.myTodos.filters.manualUpload') }}</option>
<option value="intake_parse">{{ $t('workspace.shippingNotice.myTodos.filters.intakeParse') }}</option>
</select>
</label>
<label class="space-y-1 flex-1 min-w-[10rem]">
@@ -578,6 +604,12 @@ onBeforeUnmount(() => {
>
{{ $t('workspace.shippingNotice.myTodos.openReview') }}
</span>
<span
v-else-if="item.todo_category === 'intake_parse' || item.item_kind === 'order_intake'"
class="rounded-full bg-violet-50 px-2 py-0.5 text-[10px] text-violet-700"
>
{{ $t('workspace.shippingNotice.myTodos.intakeParseBadge') }}
</span>
<span
v-else-if="item.can_handle === false"
class="rounded-full bg-slate-100 px-2 py-0.5 text-[10px] text-slate-600"
@@ -636,6 +668,30 @@ onBeforeUnmount(() => {
{{ $t('workspace.shippingNotice.myTodos.openReview') }}
</button>
</div>
<div
v-else-if="isIntakeSelection && selectedItem"
class="space-y-4 rounded-2xl border border-default bg-surface p-6"
data-testid="my-todos-intake-selection"
>
<div class="font-mono text-lg font-bold text-primary">{{ todoDisplayNo(selectedItem) }}</div>
<p class="text-sm text-secondary">
{{ selectedItem.ui_state?.summary?.message || selectedItem.ui_state?.summary?.current_todo }}
</p>
<p v-if="selectedItem.source_file_name" class="text-xs text-muted">
{{ selectedItem.source_file_name }}
<span v-if="selectedItem.intake_parse_status"> · {{ selectedItem.intake_parse_status }}</span>
</p>
<button
type="button"
class="inline-flex items-center gap-1.5 rounded-xl bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50"
:disabled="!(selectedItem.owner_agent_id || chatAgentId)"
data-testid="my-todos-open-intake-conversation"
@click="openIntakeConversation(selectedItem)"
>
<ExternalLink class="h-3.5 w-3.5" />
{{ $t('workspace.shippingNotice.myTodos.openConversation') }}
</button>
</div>
<div v-else-if="detailLoading" class="rounded-2xl border border-dashed border-default py-16 text-center text-sm text-muted">
{{ $t('workspace.shippingNotice.loading') }}
</div>