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

@@ -1,651 +1,30 @@
<script setup lang="ts">
/**
* features/workspace/views/ShippingNoticeView.vue
* 用途:遗留货代任务列表视图;主写入口已迁至 shipping-task-center 工作台。
* 依赖:ShippingWorkflowStepper、ShippingMatchResultCard、ShippingTaskParsedResultCard、shipping.api。
* 逻辑:保留只读审计浏览;履约写操作请使用 ShippingTaskCenterPage / ShippingTaskWorkbench。
* 用途:遗留货代任务列表入口;重定向到统一任务中心,禁止再维护独立 Stepper 进度。
* 依赖:vue-router。
* 逻辑:挂载即 replace 到 workspace-shipping-my-tasks;保留 query.task_no。
*/
import { computed, onMounted, ref, watch } from 'vue';
import { useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { ArrowLeft, ExternalLink, RefreshCw } from 'lucide-vue-next';
import ShippingWorkflowStepper from '@/features/chat/components/ShippingWorkflowStepper.vue';
import ShippingMatchResultCard from '@/features/chat/components/messages/ShippingMatchResultCard.vue';
import ShippingTaskParsedResultCard from '@/features/chat/components/ShippingTaskParsedResultCard.vue';
import { formatLocalDateTime } from '@/shared/utils/dateTime';
import {
getWorkspaceShippingTask,
listShippingChatAgents,
listWorkspaceShippingTasks,
SHIPPING_NOTICE_AGENT_CODE,
type ShippingCurrentStepProgress,
type ShippingTaskDetail,
type ShippingTaskSummary,
} from '@/features/chat/api/shipping.api';
import { resolveShippingWorkflowSteps } from '@/features/chat/shipping';
import { sanitizeShippingRuntimeStatusText } from '@/features/chat/shipping/shippingText';
import { SHIPPING_TASK_STATUS_FILTERS } from '../shippingTaskStatuses';
const props = defineProps<{
embedded?: boolean;
}>();
<script setup lang="ts">
import { onMounted } from 'vue';
import { useRoute, useRouter } from 'vue-router';
const route = useRoute();
const router = useRouter();
const { t, te } = useI18n();
const loading = ref(false);
const detailLoading = ref(false);
const tasks = ref<ShippingTaskSummary[]>([]);
const selectedTaskNo = ref<string | null>(null);
const detail = ref<ShippingTaskDetail | null>(null);
const statusFilter = ref('all');
const lifecycleFilter = ref('active');
const chatAgentId = ref<number | null>(null);
const currentPage = ref(1);
const pageSize = 10;
const totalTasks = ref(0);
const totalPages = computed(() => Math.max(1, Math.ceil(totalTasks.value / pageSize)));
const pageStart = computed(() => (totalTasks.value === 0 ? 0 : (currentPage.value - 1) * pageSize + 1));
const pageEnd = computed(() => Math.min(currentPage.value * pageSize, totalTasks.value));
const batchProgressLabel = computed(() => {
if (!detail.value?.batch_index || !detail.value?.batch_total) return '';
return t('chat.shippingNoticeUi.batchProgress', {
index: detail.value.batch_index,
total: detail.value.batch_total,
});
});
const statusOptions = computed(() => [
{ value: 'all', label: t('workspace.shippingNotice.status.all') },
...SHIPPING_TASK_STATUS_FILTERS.map(([value, labelKey]) => ({
value,
label: t(`workspace.shippingNotice.status.${labelKey}`),
})),
]);
const lifecycleOptions = computed(() => [
{ value: 'active', label: t('workspace.shippingNotice.lifecycle.active') },
{ value: 'deleted', label: t('workspace.shippingNotice.lifecycle.deleted') },
{ value: 'voided', label: t('workspace.shippingNotice.lifecycle.voided') },
{ value: 'archived', label: t('workspace.shippingNotice.lifecycle.archived') },
]);
type ShippingStatusSource = Pick<
ShippingTaskSummary,
'process_status' | 'review_status' | 'pending_human_reason' | 'match_status'
>;
const displayStatusCode = (source: ShippingStatusSource | string) => {
if (typeof source === 'string') return source;
const reason = String(source.pending_human_reason || '').trim();
const reviewStatus = String(source.review_status || '').trim();
if (reason === 'shortage' || reason === 'shortage_review' || reviewStatus === 'shortage_review') return 'shortage_review';
return String(source.process_status || '').trim();
};
const statusBadge = (source: ShippingStatusSource | string) => {
const status = displayStatusCode(source);
const map: Record<string, { cls: string; label: string }> = {
created: { cls: 'bg-slate-100 text-secondary', label: t('workspace.shippingNotice.status.created') },
parsed: { cls: 'bg-blue-100 text-blue-700', label: t('workspace.shippingNotice.status.parsed') },
pending_review: { cls: 'bg-amber-100 text-amber-700', label: t('workspace.shippingNotice.status.pendingReview') },
shortage_review: { cls: 'bg-rose-100 text-rose-700', label: t('workspace.shippingNotice.status.shortageReview') },
waiting_inventory: { cls: 'bg-amber-100 text-amber-700', label: t('workspace.shippingNotice.status.waitingInventory') },
inventory_ready: { cls: 'bg-blue-100 text-blue-700', label: t('workspace.shippingNotice.status.inventoryReady') },
matched: { cls: 'bg-emerald-100 text-emerald-700', label: t('workspace.shippingNotice.status.matched') },
waiting_upload: { cls: 'bg-amber-100 text-amber-700', label: t('workspace.shippingNotice.status.waitingUpload') },
uploaded: { cls: 'bg-emerald-100 text-emerald-700', label: t('workspace.shippingNotice.status.uploaded') },
upload_failed: { cls: 'bg-rose-100 text-rose-700', label: t('workspace.shippingNotice.status.uploadFailed') },
rejected: { cls: 'bg-slate-100 text-secondary', label: t('workspace.shippingNotice.status.rejected') },
closed: { cls: 'bg-slate-100 text-secondary', label: t('workspace.shippingNotice.status.closed') },
};
return map[status] || { cls: 'bg-slate-100 text-secondary', label: t('workspace.shippingNotice.status.unknown') };
};
const matchStatusLabel = (status?: string | null) => {
const key = String(status || '').trim();
const map: Record<string, string> = {
fulfillable: t('workspace.shippingNotice.matchStatus.fulfillable'),
partial: t('workspace.shippingNotice.matchStatus.partial'),
unfulfillable: t('workspace.shippingNotice.matchStatus.unfulfillable'),
};
return map[key] || (key ? t('workspace.shippingNotice.matchStatus.unknown') : '—');
};
const eventLabel = (eventType: string) => {
const normalized = String(eventType || '').trim().replace(/[^a-zA-Z0-9_]/g, '');
const key = `workspace.shippingNotice.eventTypes.${normalized}`;
return te(key) ? t(key) : t('workspace.shippingNotice.eventTypes.system');
};
const detailWorkflowSteps = computed(() => (
resolveShippingWorkflowSteps(detail.value)
));
const detailStepProgress = computed<ShippingCurrentStepProgress | null>(() => {
const payload = detail.value?.step_payload;
if (!payload || typeof payload !== 'object') return null;
const progress = (payload as Record<string, unknown>).current_step_progress;
return progress && typeof progress === 'object' ? progress as ShippingCurrentStepProgress : null;
});
const detailStepMessage = computed(() =>
sanitizeShippingRuntimeStatusText(String(detailStepProgress.value?.message || '').trim()),
);
const detailStepDetail = computed(() =>
sanitizeShippingRuntimeStatusText(String(detailStepProgress.value?.detail || '').trim()),
);
const detailErrorMessage = computed(() =>
sanitizeShippingRuntimeStatusText(String(detail.value?.error_message || '').trim()),
);
const detailIssues = computed(() => (
Array.isArray(detail.value?.ui_state?.summary?.issues)
? detail.value.ui_state.summary.issues
.map((item) => sanitizeShippingRuntimeStatusText(String(item || '').trim()))
.filter(Boolean)
: []
));
const detailTodoTitle = computed(() => (
sanitizeShippingRuntimeStatusText(String(detail.value?.ui_state?.summary?.title || '').trim())
|| t('workspace.shippingNotice.todo.noActionTitle')
));
const detailTodoMessage = computed(() => (
sanitizeShippingRuntimeStatusText(String(detail.value?.ui_state?.summary?.message || '').trim())
|| detailIssues.value[0]
|| t('workspace.shippingNotice.todo.noActionMessage')
));
const inventorySnapshotLabel = (triggerType?: string | null) => {
const key = String(triggerType || 'on_demand');
const map: Record<string, string> = {
scheduled: t('workspace.shippingNotice.inventorySnapshot.sourceScheduled'),
on_demand: t('workspace.shippingNotice.inventorySnapshot.sourceOnDemand'),
manual_upload: t('workspace.shippingNotice.inventorySnapshot.sourceManual'),
};
return map[key] || map.on_demand;
};
const inventorySourceStatusLabel = (status?: string | null) => {
const key = String(status || '').trim();
if (!key) return '—';
const i18nKey = `workspace.shippingNotice.inventorySource.statusLabels.${key}`;
return te(i18nKey) ? t(i18nKey) : key;
};
const inventorySourceMethodLabel = (method?: string | null) => {
const key = String(method || '').trim();
if (!key) return '—';
const i18nKey = `workspace.shippingNotice.inventorySource.methodLabels.${key}`;
return te(i18nKey) ? t(i18nKey) : key;
};
const hasInventorySourceFields = computed(() => {
const item = detail.value;
if (!item) return false;
return !!(
item.inventory_source_code
|| item.inventory_warehouse_id
|| item.inventory_source_status
);
});
/** 拉取当前筛选条件的一页任务;筛选/刷新时重置页码以避免落入空页。 */
const loadCases = async (resetPage = false) => {
if (resetPage) currentPage.value = 1;
loading.value = true;
try {
let result = await listWorkspaceShippingTasks({
process_status: statusFilter.value === 'all' ? undefined : statusFilter.value,
lifecycle_status: lifecycleFilter.value,
page: currentPage.value,
page_size: pageSize,
});
// 删除当前页最后一条后可能出现空页;回退一页重新查询,避免显示误导性的空结果。
if (result.items.length === 0 && result.total > 0 && currentPage.value > 1) {
currentPage.value = Math.ceil(result.total / pageSize);
result = await listWorkspaceShippingTasks({
process_status: statusFilter.value === 'all' ? undefined : statusFilter.value,
lifecycle_status: lifecycleFilter.value,
page: currentPage.value,
page_size: pageSize,
});
}
tasks.value = result.items;
totalTasks.value = result.total;
selectedTaskNo.value = null;
} catch {
tasks.value = [];
totalTasks.value = 0;
} finally {
loading.value = false;
}
};
/** 切换页码并重新读取只读任务列表。 */
const changePage = async (page: number) => {
const normalized = Math.max(1, Math.min(page, totalPages.value));
if (normalized === currentPage.value || loading.value) return;
currentPage.value = normalized;
await loadCases();
};
const loadDetail = async (taskNo: string) => {
detailLoading.value = true;
try {
detail.value = await getWorkspaceShippingTask(taskNo);
} catch {
detail.value = null;
} finally {
detailLoading.value = false;
}
};
const resolveChatAgent = async () => {
try {
const agents = await listShippingChatAgents();
const found = agents.find((a) => String(a.agent_code || '').trim() === SHIPPING_NOTICE_AGENT_CODE);
if (found) chatAgentId.value = found.id;
} catch {
/* ignore */
}
};
/**
* 可选深链:打开 Chat 会话查看上下文(非履约写入口)。
* 将遗留发货详情页重定向到任务中心(统一进度消费面)。
*/
const openInChat = (taskNo: string, conversationId?: string | null, batchNo?: string | null) => {
if (!chatAgentId.value) return;
const query: Record<string, string> = { task_id: taskNo };
const normalizedBatchNo = String(batchNo || '').trim();
if (normalizedBatchNo) query.batch_no = normalizedBatchNo;
const cid = String(conversationId || '').trim();
if (/^[0-9a-f]{32}$/i.test(cid)) query.conversation_id = cid;
router.push({ path: `/chat/${chatAgentId.value}`, query });
};
const shortageLines = computed(() => detail.value?.shortage?.lines || []);
const hasMatchCard = computed(() =>
!!detail.value && (
(Array.isArray(detail.value.line_results) && detail.value.line_results.length > 0)
|| shortageLines.value.length > 0
),
);
watch(selectedTaskNo, (val) => {
if (val) loadDetail(val);
else detail.value = null;
});
onMounted(async () => {
await Promise.all([loadCases(), resolveChatAgent()]);
onMounted(() => {
const taskNo = String(route.query.task_no || route.params.taskNo || '').trim();
void router.replace({
name: 'workspace-shipping-my-tasks',
query: taskNo ? { task_no: taskNo } : undefined,
});
});
</script>
<template>
<div class="space-y-5 animate-fade-in-up">
<div class="flex items-center justify-between gap-3">
<div class="flex items-center gap-3">
<button
v-if="!embedded"
type="button"
class="inline-flex h-9 w-9 items-center justify-center rounded-xl border border-default text-secondary hover:bg-surface-soft"
@click="router.push('/workspace')"
>
<ArrowLeft class="h-4 w-4" />
</button>
<div>
<h2 class="text-2xl font-bold text-primary">{{ $t('workspace.shippingNotice.title') }}</h2>
<p class="text-sm text-muted">{{ $t('workspace.shippingNotice.subtitle') }}</p>
</div>
</div>
<div class="flex gap-2">
<button
type="button"
class="inline-flex items-center gap-1.5 rounded-xl border border-default px-3 py-1.5 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft"
@click="loadCases(true)"
>
<RefreshCw class="h-3.5 w-3.5" />
{{ $t('workspace.shippingNotice.refresh') }}
</button>
</div>
</div>
<div class="flex flex-wrap items-end gap-3 rounded-2xl border border-default/80 bg-surface/70 px-4 py-3 shadow-sm">
<div>
<label class="mb-1 block text-xs font-medium text-muted">{{ $t('workspace.shippingNotice.filters.status') }}</label>
<select v-model="statusFilter" class="rounded-xl border border-default bg-surface px-3 py-2 text-sm">
<option v-for="opt in statusOptions" :key="opt.value" :value="opt.value">{{ opt.label }}</option>
</select>
</div>
<div>
<label class="mb-1 block text-xs font-medium text-muted">{{ $t('workspace.shippingNotice.filters.lifecycle') }}</label>
<select v-model="lifecycleFilter" class="rounded-xl border border-default bg-surface px-3 py-2 text-sm">
<option v-for="opt in lifecycleOptions" :key="opt.value" :value="opt.value">{{ opt.label }}</option>
</select>
</div>
<button
type="button"
class="rounded-xl bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700"
@click="loadCases(true)"
>
{{ $t('workspace.shippingNotice.search') }}
</button>
</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 === 0" class="rounded-2xl border border-dashed border-default py-10 text-center text-sm text-muted">
{{ $t('workspace.shippingNotice.empty') }}
</div>
<article
v-for="item in tasks"
:key="item.task_no"
class="flex w-full items-start gap-3 rounded-2xl border px-4 py-3 transition-colors"
:class="selectedTaskNo === item.task_no ? 'border-brand-400 bg-brand-50/60' : 'border-default hover:bg-surface-soft/70'"
>
<button type="button" class="min-w-0 flex-1 text-left" @click="selectedTaskNo = item.task_no">
<div class="flex items-center justify-between gap-2">
<span class="font-mono text-sm font-semibold text-primary">{{ item.task_no }}</span>
<span
class="rounded-full px-2 py-0.5 text-xs font-medium"
:class="statusBadge(item).cls"
:title="item.process_status"
>
{{ statusBadge(item).label }}
</span>
</div>
<div class="mt-1 truncate text-sm text-secondary">{{ item.customer_name || '—' }}</div>
<div
v-if="item.ui_state?.summary?.title"
class="mt-1 truncate text-xs font-medium text-brand-700"
>
{{ sanitizeShippingRuntimeStatusText(item.ui_state.summary.title) }}
</div>
<div class="mt-1 flex flex-wrap items-center gap-2 text-xs text-muted">
<span>{{ formatLocalDateTime(item.created_at) }}</span>
<span v-if="item.batch_index && item.batch_total" class="rounded-full bg-sky-50 px-2 py-0.5 font-medium text-sky-700">
{{ t('chat.shippingNoticeUi.batchProgress', { index: item.batch_index, total: item.batch_total }) }}
</span>
</div>
</button>
</article>
<div
v-if="totalTasks > 0"
class="flex items-center justify-between gap-2 pt-2 text-sm text-muted"
>
<span>{{ $t('workspace.shippingNotice.pagination.summary', { start: pageStart, end: pageEnd, total: totalTasks }) }}</span>
<div class="flex items-center gap-2">
<button
type="button"
class="rounded-lg border border-default px-2.5 py-1.5 text-secondary hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-50"
:disabled="currentPage <= 1 || loading"
@click="changePage(currentPage - 1)"
>
{{ $t('workspace.shippingNotice.pagination.previous') }}
</button>
<span class="whitespace-nowrap">{{ $t('workspace.shippingNotice.pagination.page', { page: currentPage, total: totalPages }) }}</span>
<button
type="button"
class="rounded-lg border border-default px-2.5 py-1.5 text-secondary hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-50"
:disabled="currentPage >= totalPages || loading"
@click="changePage(currentPage + 1)"
>
{{ $t('workspace.shippingNotice.pagination.next') }}
</button>
</div>
</div>
</div>
<div class="rounded-2xl border border-default bg-surface/50 p-5">
<div v-if="!selectedTaskNo" class="py-16 text-center text-sm text-muted">
{{ $t('workspace.shippingNotice.selectCase') }}
</div>
<div v-else-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.loadFailed') }}
</div>
<div v-else class="space-y-4">
<div class="flex flex-wrap items-center justify-between gap-3">
<div>
<div class="font-mono text-lg font-bold text-primary">{{ detail.task_no }}</div>
<div class="flex flex-wrap items-center gap-2 text-sm text-muted">
<span>{{ detail.customer_name }} · {{ detail.customer_code || '—' }}</span>
<span v-if="batchProgressLabel" class="rounded-full bg-sky-50 px-2 py-0.5 text-xs font-medium text-sky-700">
{{ batchProgressLabel }}
</span>
</div>
</div>
<div class="flex flex-wrap gap-2">
<button
v-if="chatAgentId"
type="button"
class="inline-flex items-center gap-1 rounded-xl border border-brand-300 bg-brand-50 px-3 py-1.5 text-sm font-medium text-brand-700 hover:bg-brand-100"
@click="openInChat(detail.task_no, detail.conversation_id, detail.batch_no)"
>
<ExternalLink class="h-3.5 w-3.5" />
{{ $t('workspace.shippingNotice.openChat') }}
</button>
</div>
</div>
<section class="rounded-2xl border border-brand-200 bg-brand-50/50 p-4">
<div class="min-w-0">
<div class="text-xs font-semibold uppercase tracking-wide text-brand-700">
{{ $t('workspace.shippingNotice.todo.currentTodo') }}
</div>
<h3 class="mt-1 text-base font-semibold text-primary">{{ detailTodoTitle }}</h3>
<p class="mt-1 text-sm text-secondary">{{ detailTodoMessage }}</p>
<p class="mt-2 text-xs text-muted">
{{ $t('workspace.shippingNotice.myTodos.openTask') }}:
{{ $t('workspace.shippingNotice.subtitle') }}
</p>
</div>
</section>
<section class="rounded-2xl border border-default/80 bg-surface px-4 py-3">
<div class="mb-3 text-xs font-semibold uppercase tracking-wide text-muted">
{{ $t('workspace.shippingNotice.todo.workflow') }}
</div>
<ShippingWorkflowStepper :steps="detailWorkflowSteps" />
</section>
<div
v-if="detailStepProgress && (detailStepMessage || detailStepDetail)"
class="rounded-2xl border border-default/80 bg-surface px-4 py-3"
>
<div class="text-xs font-medium text-primary">
{{ detailStepProgress.step_title || t('chat.shippingNoticeUi.stepDetail.title') }}
</div>
<div v-if="detailStepMessage" class="mt-1 text-sm text-secondary">
{{ detailStepMessage }}
</div>
<div v-if="detailStepDetail" class="mt-1 text-xs text-muted">
{{ detailStepDetail }}
</div>
</div>
<section class="rounded-2xl border border-default/80 bg-surface px-4 py-3">
<h3 class="mb-3 text-sm font-semibold text-secondary">{{ $t('workspace.shippingNotice.todo.orderOverview') }}</h3>
<dl class="grid gap-3 sm:grid-cols-2 text-sm">
<div>
<dt class="text-muted">{{ $t('workspace.shippingNotice.fields.status') }}</dt>
<dd :title="detail.process_status">{{ statusBadge(detail).label }}</dd>
</div>
<div>
<dt class="text-muted">{{ $t('workspace.shippingNotice.fields.match') }}</dt>
<dd :title="detail.match_status || ''">{{ matchStatusLabel(detail.match_status) }}</dd>
</div>
<div><dt class="text-muted">{{ $t('workspace.shippingNotice.fields.shipTo') }}</dt><dd>{{ detail.ship_to || '—' }}</dd></div>
<div><dt class="text-muted">{{ $t('workspace.shippingNotice.fields.freightRef') }}</dt><dd>{{ detail.freight_ref_no || '—' }}</dd></div>
</dl>
</section>
<div
v-if="hasInventorySourceFields"
class="rounded-2xl border border-default/80 bg-surface px-4 py-3 text-sm"
>
<h3 class="mb-2 text-sm font-semibold text-secondary">
{{ $t('workspace.shippingNotice.inventorySource.title') }}
</h3>
<dl class="grid gap-2 sm:grid-cols-2">
<div>
<dt class="text-xs text-muted">{{ $t('workspace.shippingNotice.inventorySource.sourceCode') }}</dt>
<dd class="font-mono">{{ detail.inventory_source_code || '—' }}</dd>
</div>
<div>
<dt class="text-xs text-muted">{{ $t('workspace.shippingNotice.inventorySource.status') }}</dt>
<dd>{{ inventorySourceStatusLabel(detail.inventory_source_status) }}</dd>
</div>
<div>
<dt class="text-xs text-muted">{{ $t('workspace.shippingNotice.inventorySource.warehouseId') }}</dt>
<dd class="font-mono">{{ detail.inventory_warehouse_id || '—' }}</dd>
</div>
<div>
<dt class="text-xs text-muted">{{ $t('workspace.shippingNotice.inventorySource.method') }}</dt>
<dd>{{ inventorySourceMethodLabel(detail.inventory_source_method) }}</dd>
</div>
<div>
<dt class="text-xs text-muted">{{ $t('workspace.shippingNotice.inventorySource.configVersion') }}</dt>
<dd class="font-mono text-xs">{{ detail.inventory_source_config_version || '—' }}</dd>
</div>
<div>
<dt class="text-xs text-muted">{{ $t('workspace.shippingNotice.inventorySource.confirmedBy') }}</dt>
<dd class="font-mono">{{ detail.inventory_source_confirmed_by ?? '—' }}</dd>
</div>
</dl>
</div>
<div
v-if="detail.inventory_snapshot"
class="rounded-2xl border border-default/80 bg-surface px-4 py-3 text-sm"
>
<h3 class="mb-2 text-sm font-semibold text-secondary">
{{ $t('workspace.shippingNotice.inventorySnapshot.title') }}
</h3>
<dl class="grid gap-2 sm:grid-cols-2">
<div>
<dt class="text-xs text-muted">{{ $t('workspace.shippingNotice.inventorySnapshot.warehouseId') }}</dt>
<dd class="font-mono">{{ detail.inventory_snapshot.warehouse_id || '—' }}</dd>
</div>
<div>
<dt class="text-xs text-muted">{{ $t('workspace.shippingNotice.inventorySnapshot.source') }}</dt>
<dd>{{ inventorySnapshotLabel(detail.inventory_snapshot.trigger_type) }}</dd>
</div>
<div>
<dt class="text-xs text-muted">{{ $t('workspace.shippingNotice.inventorySnapshot.exportedAt') }}</dt>
<dd>{{ detail.inventory_snapshot.exported_at || '—' }}</dd>
</div>
<div>
<dt class="text-xs text-muted">{{ $t('workspace.shippingNotice.inventorySnapshot.fileNo') }}</dt>
<dd class="font-mono text-xs">{{ detail.inventory_snapshot.inventory_file_no || '—' }}</dd>
</div>
</dl>
<div
v-if="detail.inventory_snapshot.is_fresh === false"
class="mt-2 text-xs text-amber-700"
>
{{ $t('workspace.shippingNotice.inventorySnapshot.expired') }}
</div>
</div>
<div v-if="detailErrorMessage" class="rounded-xl border border-rose-200 bg-rose-50 px-3 py-2 text-sm text-rose-700">
{{ detailErrorMessage }}
</div>
<div v-if="detailIssues.length" class="rounded-xl border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-800">
<div v-for="issue in detailIssues" :key="issue" class="py-0.5">{{ issue }}</div>
</div>
<ShippingMatchResultCard
v-if="hasMatchCard"
:task-id="detail.task_no"
:match-status="detail.match_status"
:line-results="detail.line_results"
:shortage-lines="shortageLines"
:action-buttons="[]"
:action-busy="false"
/>
<section
v-if="detail.inventory_verifications?.length"
class="rounded-2xl border border-default/80 bg-surface px-4 py-3 text-sm"
>
<h3 class="mb-2 text-sm font-semibold text-secondary">{{ $t('workspace.shippingNotice.fulfillmentTimeline.inventoryTitle') }}</h3>
<div v-for="verification in detail.inventory_verifications" :key="verification.id" class="border-t border-default/70 py-2 first:border-t-0 first:pt-0">
<div class="flex flex-wrap gap-x-3 gap-y-1 text-xs">
<span class="font-medium text-secondary">#{{ verification.id }} · {{ verification.status }}</span>
<span>{{ formatLocalDateTime(verification.created_at) }}</span>
</div>
<div class="mt-1 text-xs text-muted">
<span v-for="line in verification.lines" :key="line.reservation_id" class="mr-3 inline-block">
{{ $t('workspace.shippingNotice.fulfillmentTimeline.verificationLine', { reservationId: line.reservation_id, availableQty: line.available_qty, requiredQty: line.required_qty, status: line.status }) }}
</span>
</div>
</div>
</section>
<section
v-if="detail.export_artifacts?.length"
class="rounded-2xl border border-default/80 bg-surface px-4 py-3 text-sm"
>
<h3 class="mb-2 text-sm font-semibold text-secondary">{{ $t('workspace.shippingNotice.fulfillmentTimeline.artifactTitle') }}</h3>
<div v-for="artifact in detail.export_artifacts" :key="artifact.id" class="border-t border-default/70 py-2 first:border-t-0 first:pt-0">
<div class="flex flex-wrap gap-x-3 gap-y-1 text-xs">
<span class="font-mono font-medium text-secondary">{{ artifact.artifact_no }}</span>
<span>{{ artifact.status }}</span>
<span>{{ artifact.file_name }}</span>
<span>{{ formatLocalDateTime(artifact.created_at) }}</span>
</div>
<p class="mt-1 text-xs text-muted">{{ $t('workspace.shippingNotice.fulfillmentTimeline.reservationIds', { reservationIds: artifact.reservation_ids.join(', ') || '—' }) }}</p>
</div>
</section>
<section
v-if="detail.upload_attempts?.length"
class="rounded-2xl border border-default/80 bg-surface px-4 py-3 text-sm"
>
<h3 class="mb-2 text-sm font-semibold text-secondary">{{ $t('workspace.shippingNotice.fulfillmentTimeline.uploadTitle') }}</h3>
<div v-for="attempt in detail.upload_attempts" :key="attempt.id" class="border-t border-default/70 py-2 first:border-t-0 first:pt-0">
<div class="flex flex-wrap gap-x-3 gap-y-1 text-xs">
<span class="font-medium text-secondary">{{ $t('workspace.shippingNotice.fulfillmentTimeline.uploadAttempt', { artifactId: attempt.artifact_id, attemptNo: attempt.attempt_no }) }}</span>
<span>{{ attempt.mode }}</span><span>{{ attempt.status }}</span>
<span>{{ formatLocalDateTime(attempt.finished_at || attempt.created_at) }}</span>
</div>
<p v-if="attempt.freight_ref_no || attempt.error_message || attempt.evidence_asset_id" class="mt-1 text-xs text-muted">
{{ attempt.freight_ref_no ? $t('workspace.shippingNotice.fulfillmentTimeline.freightRef', { freightRefNo: attempt.freight_ref_no }) : '' }}
{{ attempt.error_message ? ` ${attempt.error_message}` : '' }}
{{ attempt.evidence_asset_id ? ` ${$t('workspace.shippingNotice.fulfillmentTimeline.evidenceAsset', { assetId: attempt.evidence_asset_id })}` : '' }}
</p>
</div>
</section>
<ShippingTaskParsedResultCard
v-if="detail.lines?.length || detail.process_field_gate || detail.parse_validation || detail.source_candidate || detail.field_conflicts?.length"
class="mt-3"
:task-no="detail.task_no"
:po-number="detail.po_number"
:lines="detail.lines"
:parse-validation="detail.parse_validation || detail.step_payload?.parse_validation || null"
:process-field-gate="detail.process_field_gate || null"
:source-candidate="detail.source_candidate || null"
:field-conflicts="detail.field_conflicts || []"
:order-data-version="detail.order_data_version"
:default-expanded="true"
@refreshed="detail?.task_no && loadDetail(detail.task_no)"
/>
<div v-if="detail.events?.length">
<h3 class="mb-2 text-sm font-semibold text-secondary">{{ $t('workspace.shippingNotice.events') }}</h3>
<ul class="max-h-48 space-y-1 overflow-y-auto text-xs text-muted">
<li v-for="(ev, idx) in [...detail.events].reverse()" :key="idx">
<span class="font-medium text-secondary" :title="ev.event_type">{{ eventLabel(ev.event_type) }}</span>
<span class="ml-2">{{ formatLocalDateTime(ev.created_at) }}</span>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="flex min-h-[12rem] items-center justify-center text-sm text-secondary" data-testid="shipping-notice-view-redirect">
Redirecting…
</div>
</template>