feat(shipping-notice): 落地 XFA 统一视觉拆分确认门禁与处理投影收敛

闭合拆分预览令牌单次消费、样本 checksum 绑定与确认审计;正式提取改为 bindings-only。
同步统一标注工作台交互,并补齐进度投影/任务中心与迁移文档。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
hugoandCursor committed 2026-08-06 10:21:25 +08:00
1 parent d2b3d74def
commit 84a881b554
195 files changed
+20269 -3463

No files matched your search

@@ -1,15 +1,17 @@
/**
* features/workspace/shipping-task-center/ShippingTaskCenterPage.vue
* 用途:发货「我的待办」壳——Pending|Processing|Done + 识别 Run 续办表 + 右侧任务工作台或复核深链。
* 依赖:shipping-tasks.api(my-todos)、shipping.api 详情、ShippingTaskWorkbench、ShippingRunProgressTable、useShippingTodoBadge。
* 逻辑:review_case 项用 review_run_no 打开人工复核;task 项打开任务处理工作台;
* 轮询仅依据 shipping_processing_status / process_status / Intake parse_status,
* 不回退 WorkflowItem lifecycle;created/queued/parsing Intake 持续刷新。
* 用途:发货「任务中心」壳——Pending|Processing|Done + 识别 Run 续办表;仅列表入口。
* 依赖:shipping-tasks.api(my-todos)、shipping.api 详情(直链摘要)、ShippingRunProgressTable、useShippingTodoBadge、
* shippingProcessingLabels。
* 逻辑:选中项展示入口卡 + 统一进度紧凑摘要(UI-03);唯一主按钮深链「订单处理工作台」或对话;
* 不内嵌 ShippingTaskWorkbench;轮询依据 shipping_processing_status /
* process_status / Intake parse_status。
*/
<script setup lang="ts">
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { ExternalLink, RefreshCw } from 'lucide-vue-next';
import { useI18n } from 'vue-i18n';
import {
getWorkspaceShippingTask,
listShippingChatAgents,
@@ -27,13 +29,19 @@ import {
IN_PROGRESS_PROCESSING_STATUSES,
TERMINAL_PROCESSING_STATUSES,
} from '@/features/chat/shipping/shippingProcessingFulfillment';
import {
resolveShippingProcessingStatusLabel,
shippingProcessingStageKey,
} from '@/features/chat/shipping/shippingProcessingLabels';
import { stageAbsoluteIndex } from '@/features/shipping-progress/progressWindow';
import { resolveGateReasonLabel } from '@/features/shipping-progress/gateReasonLabel';
import {
IN_PROGRESS_PROCESS,
isShippingTodoListItemInProgress,
} from './shippingTaskCenterPolling';
import ShippingTaskWorkbench from './ShippingTaskWorkbench.vue';
import ShippingRunProgressTable from './ShippingRunProgressTable.vue';
const { t, te } = useI18n();
/** 进行中 Workflow/Task 前台轮询间隔。 */
const FOREGROUND_POLL_MS = 2000;
/** 页面隐藏时后台轮询间隔。 */
@@ -70,7 +78,7 @@ const { refreshShippingTodoBadge } = useShippingTodoBadge();
/** todos=建单后待办;runs=建单前识别续办 */
const surface = ref<'todos' | 'runs'>('todos');
const bucket = ref<'pending' | 'processing' | 'done'>('pending');
const filterTodoCategory = ref<'all' | 'review' | 'exception' | 'manual_upload'>('all');
const filterTodoCategory = ref<'all' | 'review' | 'exception' | 'manual_upload' | 'intake_parse'>('all');
const filterCustomer = ref('');
const filterTaskNo = ref('');
const appliedFilters = ref({
@@ -82,6 +90,7 @@ const loading = ref(false);
const detailLoading = ref(false);
const tasks = ref<ShippingTaskSummary[]>([]);
const selectedRef = ref<string | null>(null);
/** 仅直链摘要,供入口卡展示;禁止内嵌履约工作台。 */
const detail = ref<ShippingTaskDetail | null>(null);
const currentPage = ref(1);
const pageSize = 20;
@@ -97,11 +106,9 @@ let pollTimer: ReturnType<typeof setTimeout> | null = null;
let pollInFlight = false;
const totalPages = computed(() => Math.max(1, Math.ceil(totalTasks.value / pageSize)));
const canHandle = computed(() => detail.value?.can_handle !== false);
const preferredTaskNo = computed(() =>
String(route.params.taskNo || route.query.task_no || '').trim().toUpperCase(),
);
const preferredReviewRun = computed(() => String(route.query.run_no || '').trim());
const isDirectTaskRoute = computed(() => Boolean(String(route.params.taskNo || '').trim()));
const selectedItem = computed(() =>
@@ -111,6 +118,53 @@ const isReviewSelection = computed(() => selectedItem.value?.item_kind === 'revi
|| 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));
/** 建单后 Notice/OT 任务选中(列表项或直链详情)。 */
const isTaskSelection = computed(() => {
if (isDirectTaskRoute.value && detail.value) return true;
if (!selectedItem.value) return false;
return !isReviewSelection.value && !isIntakeSelection.value && Boolean(selectedItem.value.task_no);
});
/**
* 入口卡展示对象:优先列表选中项,直链时回退详情摘要。
*/
const entryItem = computed((): ShippingTaskSummary | ShippingTaskDetail | null => {
if (selectedItem.value) return selectedItem.value;
if (detail.value) return detail.value;
return null;
});
/**
* 任务中心选中项的统一进度紧凑摘要(UI-03):阶段 · n/15 + 阻断文案。
*/
const entryProgressSummary = computed(() => {
const item = entryItem.value;
if (!item) return null;
const stage = String(
('shipping_processing_stage' in item ? item.shipping_processing_stage : null)
|| '',
).trim();
const status = String(item.shipping_processing_status || '').trim();
if (!stage && !status) return null;
const stageKey = shippingProcessingStageKey(stage || '');
const stageLabel = stage && te(stageKey) ? t(stageKey) : (stage || resolveShippingProcessingStatusLabel(status, te, t));
const index = stage ? stageAbsoluteIndex(stage) + 1 : 0;
const gateCode = String(
item.ui_state?.process_gate?.current_blocking_gate?.blocking_reason_code
|| item.ui_state?.process_gate?.blocking_reason_code
|| '',
).trim();
const blocker = resolveGateReasonLabel(gateCode, { t, te });
return {
stageLabel,
index,
total: 15,
statusLabel: resolveShippingProcessingStatusLabel(status, te, t),
blocker,
poNumber: String(item.po_number || '').trim() || null,
customerName: String(item.customer_name || '').trim() || null,
};
});
/**
* 待办列表项稳定主键:复核用 case_no,Intake 用 intake_no,任务用 task_no。
@@ -139,12 +193,12 @@ function todoDisplayNo(item: ShippingTaskSummary): string {
}
/**
* 是否应继续自动轮询:processing 桶、进行中详情,或 runs 面;列表项按统一投影 / process_status。
* 是否应继续自动轮询: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;
if (isDirectTaskRoute.value && isDetailInProgress(detail.value)) return true;
return tasks.value.some((item) => isListItemInProgress(item));
});
@@ -169,7 +223,7 @@ function stopAutoRefresh() {
}
/**
* 调度下一次自动刷新(仅进行中 Workflow/Task)。
* 调度下一次自动刷新(仅进行中项)。
*/
function scheduleAutoRefresh() {
stopAutoRefresh();
@@ -192,7 +246,7 @@ function scheduleAutoRefresh() {
}
/**
* 解析货代 Chat Agent,供复核/会话深链。
* 解析货代 Chat Agent,供订单处理/会话深链。
*/
async function resolveChatAgent() {
try {
@@ -231,7 +285,7 @@ function applyFilters() {
}
/**
* 清空筛选条件并重新拉取列表。
* 清空筛选并重载。
*/
function resetFilters() {
filterTodoCategory.value = 'all';
@@ -242,35 +296,29 @@ function resetFilters() {
}
/**
* 按当前 bucket 分页拉取「我的待办」;优先选中路由 task_no / run_no。
* 拉取当前桶待办列表。
* @param resetPage - 切换桶时重置到第一页
*/
async function loadTodos(resetPage = false) {
if (resetPage) currentPage.value = 1;
loading.value = true;
try {
const res = await listWorkspaceShippingMyTodos({
const category = appliedFilters.value.todo_category || undefined;
const result = await listWorkspaceShippingMyTodos({
bucket: bucket.value,
page: currentPage.value,
page_size: pageSize,
...(appliedFilters.value.todo_category ? { todo_category: appliedFilters.value.todo_category } : {}),
...(appliedFilters.value.customer ? { customer: appliedFilters.value.customer } : {}),
...(appliedFilters.value.task_no ? { task_no: appliedFilters.value.task_no } : {}),
todo_category: category as 'review' | 'exception' | 'manual_upload' | 'intake_parse' | undefined,
customer: appliedFilters.value.customer || undefined,
task_no: appliedFilters.value.task_no || undefined,
});
tasks.value = res.items || [];
totalTasks.value = Number(res.total || 0);
const byTask = preferredTaskNo.value
? tasks.value.find((item) => String(item.task_no || '').toUpperCase() === preferredTaskNo.value)
: null;
const byRun = preferredReviewRun.value
? tasks.value.find((item) => String(item.review_run_no || '') === preferredReviewRun.value)
: null;
const preferred = byTask || byRun;
if (preferred) {
selectedRef.value = todoItemKey(preferred);
} else if (selectedRef.value && !tasks.value.some((item) => todoItemKey(item) === selectedRef.value)) {
selectedRef.value = tasks.value[0] ? todoItemKey(tasks.value[0]) : null;
} else if (!selectedRef.value && tasks.value[0]) {
selectedRef.value = todoItemKey(tasks.value[0]);
tasks.value = result.items || [];
totalTasks.value = Number(result.total || 0);
if (preferredTaskNo.value && !selectedRef.value) {
const hit = tasks.value.find(
(item) => String(item.task_no || '').toUpperCase() === preferredTaskNo.value,
);
if (hit) selectedRef.value = todoItemKey(hit);
}
} catch {
tasks.value = [];
@@ -281,7 +329,7 @@ async function loadTodos(resetPage = false) {
}
/**
* 拉取任务详情;复核项不拉 Task API。
* 直链场景拉取任务摘要(仅入口卡,不挂工作台)。
*/
async function loadDetail(taskNo: string) {
detailLoading.value = true;
@@ -295,30 +343,20 @@ async function loadDetail(taskNo: string) {
}
/**
* 列表与详情联动刷新。
* @param options.silent - 轮询时不强制切换 loading 闪烁(详情仍更新)
* 列表与(可选)直链摘要联动刷新。
*/
async function refreshAll(options?: { silent?: boolean }) {
const silent = Boolean(options?.silent);
if (!silent) {
await Promise.all([loadTodos(), loadCounts()]);
} else {
await Promise.all([loadTodos(), loadCounts()]);
}
async function refreshAll(_options?: { silent?: boolean }) {
await Promise.all([loadTodos(), loadCounts()]);
if (isDirectTaskRoute.value && preferredTaskNo.value) {
await loadDetail(preferredTaskNo.value);
return;
}
const item = selectedItem.value;
if (item?.task_no && item.item_kind !== 'review_case') {
await loadDetail(item.task_no);
}
}
/**
* 打开人工复核工作台(Chat 主区替换为 order-review 模式)。
* 打开订单处理工作台(Chat 主区 order-review;单 OT 全生命周期)。
* 任务中心仅作列表入口,禁止在本页履约写操作。
*/
function openReview(item: ShippingTaskSummary) {
function openOrderProcessing(item: ShippingTaskSummary | ShippingTaskDetail) {
const runNo = String(item.review_run_no || '').trim();
if (!runNo) return;
const agentId = Number(item.owner_agent_id || chatAgentId.value || 0);
@@ -334,6 +372,16 @@ function openReview(item: ShippingTaskSummary) {
void router.push({ path: `/chat/${agentId}`, query });
}
/**
* 当前入口是否可深链订单处理工作台。
*/
function canOpenOrderProcessing(item: ShippingTaskSummary | ShippingTaskDetail | null): boolean {
if (!item) return false;
const runNo = String(item.review_run_no || '').trim();
const agentId = Number(item.owner_agent_id || chatAgentId.value || 0);
return Boolean(runNo && agentId);
}
/**
* 打开对话「本次处理中」卡,聚焦未建 OT 的 Intake 材料。
*/
@@ -351,37 +399,40 @@ function openIntakeConversation(item: ShippingTaskSummary) {
/**
* 可选深链:打开 Chat 会话查看上下文(非履约写入口)。
*/
function openInChat() {
if (!chatAgentId.value || !detail.value) return;
const query: Record<string, string> = { task_id: detail.value.task_no };
const batchNo = String(detail.value.batch_no || '').trim();
function openInChat(item?: ShippingTaskSummary | ShippingTaskDetail | null) {
const row = item || entryItem.value;
if (!chatAgentId.value || !row) return;
const query: Record<string, string> = {};
const taskNo = String(row.task_no || '').trim();
const orderTaskNo = String(row.order_task_no || '').trim();
if (taskNo) query.task_id = taskNo;
if (orderTaskNo) query.focus_task_no = orderTaskNo;
const batchNo = String(('batch_no' in row ? row.batch_no : '') || '').trim();
if (batchNo) query.batch_no = batchNo;
const cid = String(detail.value.conversation_id || '').trim();
const cid = String(row.conversation_id || '').trim();
if (/^[0-9a-f]{32}$/i.test(cid)) query.conversation_id = cid;
void router.push({ path: `/chat/${chatAgentId.value}`, query });
}
/**
* 选中列表项:复核显示入口卡;任务加载工作台详情。
* 选中列表项:仅更新选中态与 query;不拉详情工作台。
*/
async function selectTodo(item: ShippingTaskSummary) {
selectedRef.value = todoItemKey(item);
detail.value = null;
const nextQuery: Record<string, string> = { ...route.query as Record<string, string> };
if (item.item_kind === 'review_case' || item.review_run_no) {
if (item.item_kind === 'review_case' || (item.review_run_no && !item.task_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);
}
void router.replace({
name: route.name || 'workspace-shipping-my-tasks',
@@ -403,27 +454,20 @@ watch(bucket, () => {
watch(selectedItem, (item) => {
if (!item) {
detail.value = null;
if (!isDirectTaskRoute.value) detail.value = null;
return;
}
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;
}
if (item.task_no && detail.value?.task_no !== item.task_no) {
void loadDetail(item.task_no);
}
// 列表选中不拉详情;履约写一律走订单处理工作台。
detail.value = null;
});
watch(shouldAutoRefresh, () => {
scheduleAutoRefresh();
});
/**
* 页面可见性变化时重排轮询间隔。
*/
function onVisibilityChange() {
scheduleAutoRefresh();
}
@@ -436,7 +480,9 @@ onMounted(async () => {
await loadDetail(preferredTaskNo.value);
} else {
const hit = tasks.value.find((item) => String(item.task_no || '').toUpperCase() === preferredTaskNo.value);
if (!hit) {
if (hit) {
selectedRef.value = todoItemKey(hit);
} else {
selectedRef.value = preferredTaskNo.value;
await loadDetail(preferredTaskNo.value);
}
@@ -488,237 +534,311 @@ onBeforeUnmount(() => {
</button>
</div>
<div v-if="isDirectTaskRoute" class="rounded-2xl border border-default bg-surface p-4">
<div
v-if="isDirectTaskRoute"
class="rounded-2xl border border-default bg-surface p-4"
data-testid="my-todos-direct-task-entry"
>
<div v-if="detailLoading" class="py-16 text-center text-sm text-muted">
{{ $t('workspace.shippingNotice.loading') }}
</div>
<div v-else-if="!detail" class="py-16 text-center text-sm text-muted">
{{ $t('workspace.shippingNotice.selectCase') }}
</div>
<div v-else class="space-y-3">
<div class="flex flex-wrap items-center justify-between gap-2">
<div class="font-mono text-lg font-bold text-primary">{{ detail.task_no }}</div>
<div v-else class="space-y-4">
<div class="font-mono text-lg font-bold text-primary">{{ detail.task_no }}</div>
<p class="text-sm text-secondary">
{{ detail.ui_state?.summary?.message || detail.ui_state?.summary?.current_todo || $t('workspace.shippingNotice.myTodos.openProcessingHint') }}
</p>
<p class="text-xs text-muted">
{{ $t('workspace.shippingNotice.myTodos.openProcessingHint') }}
</p>
<div class="flex flex-wrap gap-2">
<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="!canOpenOrderProcessing(detail)"
data-testid="my-todos-open-order-processing"
@click="openOrderProcessing(detail)"
>
<ExternalLink class="h-3.5 w-3.5" />
{{ $t('workspace.shippingNotice.myTodos.openReview') }}
</button>
<button
v-if="chatAgentId"
type="button"
class="inline-flex items-center gap-1 rounded-xl border border-default px-3 py-1.5 text-xs font-medium text-secondary hover:bg-surface-soft"
@click="openInChat"
@click="openInChat(detail)"
>
<ExternalLink class="h-3.5 w-3.5" />
{{ $t('workspace.shippingNotice.openChat') }}
</button>
</div>
<ShippingTaskWorkbench :detail="detail" :can-handle="canHandle" @refreshed="() => refreshAll()" />
<p
v-if="!canOpenOrderProcessing(detail)"
class="text-xs text-amber-700 dark:text-amber-300"
data-testid="my-todos-open-processing-unavailable"
>
{{ $t('workspace.shippingNotice.myTodos.openProcessingUnavailable') }}
</p>
</div>
</div>
<ShippingRunProgressTable v-else-if="surface === 'runs'" />
<template v-else>
<div class="flex flex-wrap gap-2">
<button
v-for="key in (['pending', 'processing', 'done'] as const)"
:key="key"
type="button"
class="rounded-xl px-3 py-1.5 text-sm font-medium"
:class="bucket === key ? 'bg-brand-600 text-white' : 'border border-default text-secondary hover:bg-surface-soft'"
@click="bucket = key"
>
{{ $t(`workspace.shippingNotice.myTodos.buckets.${key}`) }}
<span class="ml-1 opacity-80">({{ bucketCounts[key] }})</span>
</button>
</div>
<div class="flex flex-wrap items-end gap-3 rounded-2xl border border-default bg-surface px-4 py-3">
<label v-if="bucket === 'pending'" class="space-y-1">
<span class="text-xs font-medium text-muted">{{ $t('workspace.shippingNotice.myTodos.filters.todoCategory') }}</span>
<select v-model="filterTodoCategory" class="input-field text-sm min-w-[9rem]">
<option value="all">{{ $t('workspace.shippingNotice.myTodos.filters.all') }}</option>
<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]">
<span class="text-xs font-medium text-muted">{{ $t('workspace.shippingNotice.myTodos.filters.customer') }}</span>
<input
v-model="filterCustomer"
type="text"
class="input-field text-sm w-full"
:placeholder="$t('workspace.shippingNotice.myTodos.filters.customerPlaceholder')"
@keyup.enter="applyFilters"
/>
</label>
<label class="space-y-1 flex-1 min-w-[10rem]">
<span class="text-xs font-medium text-muted">{{ $t('workspace.shippingNotice.myTodos.filters.taskNo') }}</span>
<input
v-model="filterTaskNo"
type="text"
class="input-field text-sm w-full font-mono uppercase"
:placeholder="$t('workspace.shippingNotice.myTodos.filters.taskNoPlaceholder')"
@keyup.enter="applyFilters"
/>
</label>
<div class="flex gap-2">
<div class="flex flex-wrap gap-2">
<button
v-for="key in (['pending', 'processing', 'done'] as const)"
:key="key"
type="button"
class="rounded-xl bg-brand-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50"
:disabled="loading"
@click="applyFilters"
class="rounded-xl px-3 py-1.5 text-sm font-medium"
:class="bucket === key ? 'bg-brand-600 text-white' : 'border border-default text-secondary hover:bg-surface-soft'"
@click="bucket = key"
>
{{ $t('workspace.shippingNotice.myTodos.filters.apply') }}
</button>
<button
type="button"
class="rounded-xl border border-default px-3 py-1.5 text-sm font-medium text-secondary hover:bg-surface-soft disabled:opacity-50"
:disabled="loading"
@click="resetFilters"
>
{{ $t('workspace.shippingNotice.myTodos.filters.reset') }}
{{ $t(`workspace.shippingNotice.myTodos.buckets.${key}`) }}
<span class="ml-1 opacity-80">({{ bucketCounts[key] }})</span>
</button>
</div>
</div>
<div class="grid gap-5 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,2.15fr)]">
<div class="space-y-2">
<div v-if="loading" class="rounded-2xl border border-dashed border-default py-10 text-center text-sm text-muted">
{{ $t('workspace.shippingNotice.loading') }}
</div>
<div v-else-if="!tasks.length" class="rounded-2xl border border-dashed border-default py-10 text-center text-sm text-muted">
{{ $t('workspace.shippingNotice.myTodos.empty') }}
</div>
<button
v-for="item in tasks"
:key="todoItemKey(item)"
type="button"
class="w-full rounded-2xl border px-4 py-3 text-left transition-colors"
:class="selectedRef === todoItemKey(item) ? 'border-brand-400 bg-brand-50/60' : 'border-default hover:bg-surface-soft/70'"
@click="selectTodo(item)"
>
<div class="flex items-center justify-between gap-2">
<span class="font-mono text-sm font-semibold text-primary">{{ todoDisplayNo(item) }}</span>
<span
v-if="item.todo_category === 'review' || item.item_kind === 'review_case'"
class="rounded-full bg-amber-50 px-2 py-0.5 text-[10px] text-amber-700"
>
{{ $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"
>
{{ $t('workspace.shippingNotice.todo.adminViewOnlyShort') }}
</span>
</div>
<div class="mt-1 truncate text-sm text-secondary">
{{ item.ui_state?.summary?.current_todo || item.ui_state?.summary?.title || item.process_status }}
</div>
<div class="mt-1 truncate text-xs text-muted">
{{ item.customer_name || item.source_file_name || item.review_run_no || '—' }}
</div>
</button>
<div v-if="totalPages > 1" class="flex items-center justify-between gap-2 pt-2 text-xs text-muted">
<div class="flex flex-wrap items-end gap-3 rounded-2xl border border-default bg-surface px-4 py-3">
<label v-if="bucket === 'pending'" class="space-y-1">
<span class="text-xs font-medium text-muted">{{ $t('workspace.shippingNotice.myTodos.filters.todoCategory') }}</span>
<select v-model="filterTodoCategory" class="input-field text-sm min-w-[9rem]">
<option value="all">{{ $t('workspace.shippingNotice.myTodos.filters.all') }}</option>
<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]">
<span class="text-xs font-medium text-muted">{{ $t('workspace.shippingNotice.myTodos.filters.customer') }}</span>
<input
v-model="filterCustomer"
type="text"
class="input-field text-sm w-full"
:placeholder="$t('workspace.shippingNotice.myTodos.filters.customerPlaceholder')"
@keyup.enter="applyFilters"
/>
</label>
<label class="space-y-1 flex-1 min-w-[10rem]">
<span class="text-xs font-medium text-muted">{{ $t('workspace.shippingNotice.myTodos.filters.taskNo') }}</span>
<input
v-model="filterTaskNo"
type="text"
class="input-field text-sm w-full font-mono uppercase"
:placeholder="$t('workspace.shippingNotice.myTodos.filters.taskNoPlaceholder')"
@keyup.enter="applyFilters"
/>
</label>
<div class="flex gap-2">
<button
type="button"
class="rounded-lg border border-default px-2 py-1 disabled:opacity-50"
:disabled="currentPage <= 1 || loading"
@click="currentPage -= 1; loadTodos()"
class="rounded-xl bg-brand-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50"
:disabled="loading"
@click="applyFilters"
>
{{ $t('workspace.shippingNotice.pagination.previous') }}
{{ $t('workspace.shippingNotice.myTodos.filters.apply') }}
</button>
<span>{{ currentPage }}/{{ totalPages }}</span>
<button
type="button"
class="rounded-lg border border-default px-2 py-1 disabled:opacity-50"
:disabled="currentPage >= totalPages || loading"
@click="currentPage += 1; loadTodos()"
class="rounded-xl border border-default px-3 py-1.5 text-sm font-medium text-secondary hover:bg-surface-soft disabled:opacity-50"
:disabled="loading"
@click="resetFilters"
>
{{ $t('workspace.shippingNotice.pagination.next') }}
{{ $t('workspace.shippingNotice.myTodos.filters.reset') }}
</button>
</div>
</div>
<div>
<div
v-if="isReviewSelection && selectedItem"
class="space-y-4 rounded-2xl border border-default bg-surface p-6"
>
<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.review_run_no"> · {{ selectedItem.review_run_no }}</span>
</p>
<div class="grid gap-5 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,2.15fr)]">
<div class="space-y-2">
<div v-if="loading" class="rounded-2xl border border-dashed border-default py-10 text-center text-sm text-muted">
{{ $t('workspace.shippingNotice.loading') }}
</div>
<div v-else-if="!tasks.length" class="rounded-2xl border border-dashed border-default py-10 text-center text-sm text-muted">
{{ $t('workspace.shippingNotice.myTodos.empty') }}
</div>
<button
v-for="item in tasks"
:key="todoItemKey(item)"
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.review_run_no || !(selectedItem.owner_agent_id || chatAgentId)"
@click="openReview(selectedItem)"
class="w-full rounded-2xl border px-4 py-3 text-left transition-colors"
:class="selectedRef === todoItemKey(item) ? 'border-brand-400 bg-brand-50/60' : 'border-default hover:bg-surface-soft/70'"
@click="selectTodo(item)"
>
<ExternalLink class="h-3.5 w-3.5" />
{{ $t('workspace.shippingNotice.myTodos.openReview') }}
<div class="flex items-center justify-between gap-2">
<span class="font-mono text-sm font-semibold text-primary">{{ todoDisplayNo(item) }}</span>
<span
v-if="item.todo_category === 'review' || item.item_kind === 'review_case'"
class="rounded-full bg-amber-50 px-2 py-0.5 text-[10px] text-amber-700"
>
{{ $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"
>
{{ $t('workspace.shippingNotice.todo.adminViewOnlyShort') }}
</span>
</div>
<div class="mt-1 truncate text-sm text-secondary">
{{ item.ui_state?.summary?.current_todo || item.ui_state?.summary?.title || item.process_status }}
</div>
<div class="mt-1 truncate text-xs text-muted">
{{ item.customer_name || item.source_file_name || item.review_run_no || '—' }}
</div>
</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>
<div v-else-if="!detail" class="rounded-2xl border border-dashed border-default py-16 text-center text-sm text-muted">
{{ $t('workspace.shippingNotice.selectCase') }}
</div>
<div v-else class="space-y-3">
<div class="flex flex-wrap items-center justify-between gap-2">
<div class="font-mono text-lg font-bold text-primary">{{ detail.task_no }}</div>
<div v-if="totalPages > 1" class="flex items-center justify-between gap-2 pt-2 text-xs text-muted">
<button
v-if="chatAgentId"
type="button"
class="inline-flex items-center gap-1 rounded-xl border border-default px-3 py-1.5 text-xs font-medium text-secondary hover:bg-surface-soft"
@click="openInChat"
class="rounded-lg border border-default px-2 py-1 disabled:opacity-50"
:disabled="currentPage <= 1 || loading"
@click="currentPage -= 1; loadTodos()"
>
<ExternalLink class="h-3.5 w-3.5" />
{{ $t('workspace.shippingNotice.openChat') }}
{{ $t('workspace.shippingNotice.pagination.previous') }}
</button>
<span>{{ currentPage }}/{{ totalPages }}</span>
<button
type="button"
class="rounded-lg border border-default px-2 py-1 disabled:opacity-50"
:disabled="currentPage >= totalPages || loading"
@click="currentPage += 1; loadTodos()"
>
{{ $t('workspace.shippingNotice.pagination.next') }}
</button>
</div>
<ShippingTaskWorkbench
:detail="detail"
:can-handle="canHandle"
@refreshed="() => refreshAll()"
/>
</div>
<div>
<div
v-if="isReviewSelection && selectedItem"
class="space-y-4 rounded-2xl border border-default bg-surface p-6"
data-testid="my-todos-review-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.review_run_no"> · {{ selectedItem.review_run_no }}</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="!canOpenOrderProcessing(selectedItem)"
data-testid="my-todos-open-order-processing"
@click="openOrderProcessing(selectedItem)"
>
<ExternalLink class="h-3.5 w-3.5" />
{{ $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="isTaskSelection && entryItem"
class="space-y-4 rounded-2xl border border-default bg-surface p-6"
data-testid="my-todos-task-selection"
>
<div class="font-mono text-lg font-bold text-primary">
{{ 'task_no' in entryItem ? entryItem.task_no : todoDisplayNo(entryItem as ShippingTaskSummary) }}
<span
v-if="entryProgressSummary?.poNumber"
class="ml-2 font-sans text-sm font-medium text-secondary"
>· PO {{ entryProgressSummary.poNumber }}</span>
</div>
<p
v-if="entryProgressSummary"
class="text-sm font-medium text-primary"
data-testid="my-todos-progress-summary"
>
{{ $t('workspace.shippingNotice.myTodos.progressSummary', {
stage: entryProgressSummary.stageLabel,
current: entryProgressSummary.index || '—',
total: entryProgressSummary.total,
}) }}
</p>
<p
v-if="entryProgressSummary?.blocker"
class="text-xs text-amber-700 dark:text-amber-300"
data-testid="my-todos-progress-blocker"
>
{{ $t('workspace.shippingNotice.myTodos.progressBlocker', { reason: entryProgressSummary.blocker }) }}
</p>
<p class="text-sm text-secondary">
{{ entryItem.ui_state?.summary?.message || entryItem.ui_state?.summary?.current_todo || $t('workspace.shippingNotice.myTodos.openProcessingHint') }}
</p>
<p class="text-xs text-muted">
{{ $t('workspace.shippingNotice.myTodos.openProcessingHint') }}
</p>
<div class="flex flex-wrap gap-2">
<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="!canOpenOrderProcessing(entryItem)"
data-testid="my-todos-open-order-processing"
@click="openOrderProcessing(entryItem)"
>
<ExternalLink class="h-3.5 w-3.5" />
{{ $t('workspace.shippingNotice.myTodos.openReview') }}
</button>
<button
v-if="chatAgentId"
type="button"
class="inline-flex items-center gap-1 rounded-xl border border-default px-3 py-1.5 text-xs font-medium text-secondary hover:bg-surface-soft"
@click="openInChat(entryItem)"
>
<ExternalLink class="h-3.5 w-3.5" />
{{ $t('workspace.shippingNotice.openChat') }}
</button>
</div>
<p
v-if="!canOpenOrderProcessing(entryItem)"
class="text-xs text-amber-700 dark:text-amber-300"
data-testid="my-todos-open-processing-unavailable"
>
{{ $t('workspace.shippingNotice.myTodos.openProcessingUnavailable') }}
</p>
</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>
<div v-else class="rounded-2xl border border-dashed border-default py-16 text-center text-sm text-muted">
{{ $t('workspace.shippingNotice.selectCase') }}
</div>
</div>
</div>
</div>
</template>
</div>
</template>
@@ -2,9 +2,10 @@
* features/workspace/shipping-task-center/ShippingTaskWorkbench.vue
* 用途:发货任务处理主区——当前待办栏、统一 15 阶进度、最后活动/终止原因、STP 事实、订单概览、时间线。
* 依赖:TaskTodoPanel、StpProgressFactsPanel、TaskProgressTimeline、ShippingTaskParsedResultCard、
* useShippingProcessingWorkItem、UnifiedProgressTrack、listWorkspaceShippingTaskAuditTimeline。
* useShippingProcessingWorkItem、WorkbenchProgressGrouped、listWorkspaceShippingTaskAuditTimeline。
* 逻辑:由 ShippingTaskCenterPage 选中任务后挂载;OT 身份取 detail.order_task_no(禁止 WorkflowItem);
* 进度仅来自 ShippingProcessingProjection;时间线仅消费统一 ShippingAuditEvent。
* 进度仅来自 ShippingProcessingProjection(showActions=false,动作归 TaskTodoPanel,UI-05);
* 时间线仅消费统一 ShippingAuditEvent。
*/
<script setup lang="ts">
import { computed, ref, watch } from 'vue';
@@ -18,7 +19,9 @@ import {
import { useShippingProcessingWorkItem } from '@/features/chat/shipping/useShippingProcessingWorkItem';
import type { ShippingTaskAuditTimelineItem, ShippingTaskDetail } from '@/features/chat/types/shipping.api.types';
import { listWorkspaceShippingTaskAuditTimeline } from '@/features/chat/api/shipping.api';
import UnifiedProgressTrack from '@/features/shipping-progress/components/UnifiedProgressTrack.vue';
import WorkbenchProgressGrouped from '@/features/shipping-progress/components/WorkbenchProgressGrouped.vue';
import { resolveProcessingActionPresentation } from '@/features/shipping-progress/actionPresentation';
import type { ActionPresentationItem } from '@/features/shipping-progress/types';
import { formatLocalDateTime } from '@/shared/utils/dateTime';
import TaskTodoPanel from './TaskTodoPanel.vue';
import StpProgressFactsPanel from './StpProgressFactsPanel.vue';
@@ -67,6 +70,20 @@ const { projection: shippingProcessingProjection } = useShippingProcessingWorkIt
},
);
/** 动作栏已提供 download_excel 时隐藏下方重复按钮。 */
const actionBarOffersDownloadExcel = computed(() => {
const presentation = resolveProcessingActionPresentation(
shippingProcessingProjection.value,
{ surface: 'workbench' },
);
const all = [
presentation.primary,
presentation.secondary,
...presentation.overflow,
].filter(Boolean);
return all.some((item) => item?.intent === 'download_excel');
});
/** 最后活动:统一投影优先,否则 Notice.updated_at。 */
const lastActivityAt = computed(() =>
shippingProcessingProjection.value?.lastActivityAt
@@ -110,6 +127,24 @@ const taskMatchStatusLabel = computed(() => {
return te(key) ? t(key) : t('workspace.shippingNotice.matchStatus.unknown');
});
/**
* 任务台统一动作栏:刷新投影;其余 intent 由 TaskTodoPanel 承载。
*/
function onTaskUnifiedAction(item: ActionPresentationItem) {
if (item.intent === 'refresh') {
emit('refreshed');
return;
}
if (item.intent === 'download_excel') {
void downloadExcel();
return;
}
if (item.intent === 'open_manual_upload') {
// 已在任务台,无需跳转。
return;
}
}
/**
* 拉取任务统一审计时间线(ShippingAuditEvent 单源)。
*/
@@ -181,10 +216,11 @@ async function downloadExcel() {
>
{{ $t('workspace.shippingNotice.todo.progressUnavailable') }}
</p>
<UnifiedProgressTrack
<WorkbenchProgressGrouped
v-if="shippingProcessingProjection"
:projection="shippingProcessingProjection"
density="workbench"
:show-actions="false"
@action="onTaskUnifiedAction"
/>
<dl class="mt-3 grid gap-2 text-xs sm:grid-cols-2">
<div>
@@ -196,7 +232,7 @@ async function downloadExcel() {
<dd class="text-secondary">{{ terminateReason || '—' }}</dd>
</div>
</dl>
<div v-if="hasExcelArtifact" class="mt-3">
<div v-if="hasExcelArtifact && !actionBarOffersDownloadExcel" class="mt-3">
<button
type="button"
class="rounded-xl border border-default px-3 py-1.5 text-sm font-medium text-secondary hover:bg-surface-soft"
@@ -1,9 +1,9 @@
/**
* features/workspace/shipping-task-center/TaskTodoPanel.vue
* 用途:渲染统一 Gate 恢复卡片与 STP 履约待办动作(ui_state.action_buttons)。
* 用途:渲染统一 Gate 恢复卡片与 STP 履约待办说明(表单/弹窗入口)。
* 依赖:ProcessGateRecoveryCard、shipping.api、shipping-tasks.api、ManualUploadEvidenceDialog。
* 逻辑:优先展示 ui_state.process_gate 阻断信息与 next_action_code;禁止按 workflow_item.lifecycle
* 或 process_status 推断人工上传;存在 current_blocking_gate 时不渲染旧 action_buttons。
* 逻辑:优先展示 ui_state.process_gate 阻断信息;hidePrimaryActions=true 时不渲染平级主按钮
* (由订单处理工作台统一 ActionBar 输出,UI-01 / BE-05);对话框与登记表单仍由此面板承接。
*/
<script setup lang="ts">
import { computed, ref } from 'vue';
@@ -35,10 +35,14 @@ import ProcessGateRecoveryCard from '@/features/shipping-process-gates/component
import type { ShippingProcessGateUserSummary } from '@/features/chat/types/shipping.api.types';
import { gateSummaryIndicatesManualUpload } from '@/features/chat/shipping/shippingProcessingFulfillment';
const props = defineProps<{
const props = withDefaults(defineProps<{
detail: ShippingTaskDetail;
canHandle: boolean;
}>();
/** 为 true 时隐藏主按钮区与 Gate 卡内主操作(统一进度 ActionBar 已输出)。 */
hidePrimaryActions?: boolean;
}>(), {
hidePrimaryActions: false,
});
const emit = defineEmits<{
refreshed: [];
@@ -155,11 +159,28 @@ const allowedIds = computed(() => {
});
const hasBlockingGate = computed(() => Boolean(processGateSummary.value?.current_blocking_gate));
const UNIFIED_OWNED_ACTION_IDS = new Set([
'retry',
'refresh',
'download_excel',
'export',
'open_manual_upload',
'mark_manual_uploaded',
'regenerate_excel',
'view_result',
'open_order_review',
'open_order_processing',
]);
const visibleActions = computed(() => {
// [STEP] Gate 阻断时后端已清零 action_buttons;前端再兜底隐藏,避免双真相。
if (hasBlockingGate.value) return [];
return actionButtons.value.filter((action) => {
const id = String(action.id || '');
// [UI-01 / BE-05] 统一 ActionBar 已表达的动作不再重复渲染;未映射的履约动作仍由本面板承接。
if (props.hidePrimaryActions && UNIFIED_OWNED_ACTION_IDS.has(id)) {
return false;
}
if (!allowedIds.value.has(id) || !isActionAllowedForCheckpoint(id, checkpointKind.value)) {
return false;
}
@@ -169,6 +190,8 @@ const visibleActions = computed(() => {
return true;
});
});
/** Gate 卡在统一进度存在时仍可执行业务恢复(客户确认等),但避免与 ActionBar 重复的 next_action。 */
const gateCanHandle = computed(() => props.canHandle);
/**
* 动作成功后刷新详情并更新导航徽标。
*/
@@ -371,12 +394,34 @@ async function runAction(action: ShippingChatAction) {
busyId.value = null;
}
}
/**
* 供订单处理工作台统一 ActionBar 委托履约动作(库存源/匹配/上传登记等)。
*
* @param actionId - ui_state / Gate 动作码
*/
async function invokeActionByCode(actionId: string) {
const id = String(actionId || '').trim();
if (!id) return;
const fromButtons = actionButtons.value.find((item) => String(item.id || '') === id);
await runAction(fromButtons || {
id,
label: id,
message: '',
variant: 'primary',
});
}
defineExpose({
invokeActionByCode,
openCustomerDialog,
});
</script>
<template>
<div class="space-y-3">
<ProcessGateRecoveryCard
:summary="processGateSummary"
:can-handle="canHandle"
:can-handle="gateCanHandle"
:navigation-context="{
agentId: detail.owner_agent_id != null ? String(detail.owner_agent_id) : undefined,
conversationId: detail.conversation_id || undefined,