feat(shipping-notice): 增强订单文档 Profile 管理功能,新增复核与草稿管理

- 添加订单复核相关模型及 API,支持复核案例的创建、更新和确认
- 实现复核草稿的管理功能,允许用户对复核内容进行编辑和保存
- 引入复核事件审计,确保复核过程的可追溯性
- 更新数据库模型以支持复核和草稿的关系管理
- 完善相关服务逻辑,确保复核与草稿的状态管理和数据一致性
- 增强文档模板的管理能力,支持更复杂的业务场景
This commit is contained in:
hugo committed 2026-07-29 09:50:25 +08:00
1 parent 61ac6403c4
commit b7307fc573
147 files changed
+15108 -1522

No files matched your search

@@ -5,7 +5,7 @@
* 逻辑:附件卡片位于文本框上方;订单审核结果随对应聊天消息展示,输入区只保留附件处理状态。
*/
<script setup lang="ts">
import { nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import type { Ref } from 'vue';
import {
@@ -82,7 +82,6 @@ const emit = defineEmits<{
'retry-shipping-notice-attachment': [id: string];
'resolve-shipping-notice-duplicate': [id: string];
'select-shipping-candidate': [candidateNo: string, selected: boolean];
'update-shipping-candidate': [candidateNo: string, businessSummary: Record<string, unknown>, done: (success: boolean) => void];
'resolve-shipping-candidate-duplicate': [candidateNo: string, action: import('../types/shipping.types').ShippingDuplicateAction, targetTaskNo: string | undefined, reason: string | undefined, done: (success: boolean) => void];
'local-files-selected': [event: Event];
'add-remote-url': [url: string];
@@ -104,6 +103,16 @@ const showAttachmentUrlPanel = ref(false);
const showKbDropdown = ref(false);
const attachmentUrlInput = ref('');
/** 当前发货通知是否仍在上传或预解析,决定输入框下方的操作提示。 */
const hasShippingNoticeInProgress = computed(() => props.attachments.some(
(attachment) => attachment.kind === 'shipping_notice'
&& (
attachment.uploadStatus === 'waiting'
|| attachment.uploadStatus === 'uploading'
|| ['waiting', 'queued', 'parsing'].includes(attachment.parseStatus)
),
));
/**
* 汇总 EML 附件解析进度,供输入栏徽标展示。
* 核心逻辑:阶段 1 仅展示快览结果;优先说明发现了多少附件,技术失败/目录不完整再退化为问题提示。
@@ -464,14 +473,7 @@ watch(
v-if="isShippingNoticeAgent && attachments.length > 0"
class="flex flex-wrap items-center gap-2 px-3 pb-1 text-xs text-muted"
>
<button
type="button"
class="rounded-full border border-default bg-surface-soft px-3 py-1 font-medium text-secondary transition-colors hover:bg-surface-soft/70"
@click="emit('use-shipping-suggested-prompt')"
>
{{ shippingSuggestedPrompt || '推荐问题' }}
</button>
<span>{{ t('chat.shippingNoticeConfirmBatchHint') }}</span>
<span>{{ hasShippingNoticeInProgress ? t('chat.shippingNoticeWaitingForParse') : t('chat.shippingNoticeConfirmBatchHint') }}</span>
</div>
<div class="mt-1.5 flex items-center justify-between px-1.5 pb-0.5">
@@ -6,6 +6,7 @@
*/
<script setup lang="ts">
import { computed, ref, watch } from 'vue';
import { useRoute } from 'vue-router';
import { Maximize2, Minimize2, Loader2 } from 'lucide-vue-next';
import ChatShell from '@/shared/layouts/ChatShell.vue';
import ChatSidebar from '@/features/chat/components/ChatSidebar.vue';
@@ -18,6 +19,7 @@ import ShippingBatchWorkspaceDrawer from '@/features/chat/components/ShippingBat
import TrainingWorkspacePanel from '@/features/chat/components/TrainingWorkspacePanel.vue';
import LedgerConfigPanel from '@/features/maintenance/components/LedgerConfigPanel.vue';
import MaintenanceRecordManagerPanel from '@/features/maintenance/components/MaintenanceRecordManagerPanel.vue';
import ShippingOrderReviewView from '@/features/chat/views/ShippingOrderReviewView.vue';
import { useChatPageContext } from '@/features/chat/composables/chat.context';
import { matchesTrainingAgent } from '@/features/chat/training/trainingWorkspace.utils';
import { agentHasIntentUiProfile } from '@/shared/utils/agent-registry.utils';
@@ -36,6 +38,8 @@ type MaintenanceRecordPanelCommand = {
};
const page = useChatPageContext();
const route = useRoute();
const isOrderReviewMode = computed(() => route.query.mode === 'order-review' && typeof route.query.run_no === 'string' && route.query.run_no.length > 0);
const isTrainingAgentPage = computed(() => matchesTrainingAgent(page.currentAgent));
const isMaintenanceAgentPage = computed(() => agentHasIntentUiProfile(page.currentAgent, 'maintenance'));
const embeddedIframeSrc = computed(() => {
@@ -195,7 +199,8 @@ watch(() => page.currentAgentId, () => {
</div>
<template v-else>
<div class="flex min-h-0 min-w-0 flex-1">
<ShippingOrderReviewView v-if="isOrderReviewMode" />
<div v-else class="flex min-h-0 min-w-0 flex-1">
<div class="flex min-h-0 min-w-0 flex-1 flex-col">
<TrainingWorkspacePanel
:current-agent="page.currentAgent"
@@ -291,7 +296,6 @@ watch(() => page.currentAgentId, () => {
@retry-shipping-notice-attachment="page.retryShippingNoticeAttachment"
@resolve-shipping-notice-duplicate="page.openShippingDuplicateDialog"
@select-shipping-candidate="page.setShippingCandidateSelected"
@update-shipping-candidate="page.updateShippingCandidateSummary"
@resolve-shipping-candidate-duplicate="page.resolveShippingCandidateDuplicate"
@local-files-selected="page.handleLocalFilesSelected"
@add-remote-url="page.addRemoteUrlAttachment"
@@ -1,344 +0,0 @@
<!--
features/chat/components/ShippingNoticeCandidateReview.vue
用途:展示一封 EML 下的订单候选,并提供选择、结构化修订与重复决策入口。
依赖:shipping.types、Vue I18n。
逻辑:组件维护 PO 与订单行编辑草稿,持久化操作通过事件交给 useShippingNoticeIntakes。
-->
<script setup lang="ts">
import { computed, reactive, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import type { ShippingDuplicateAction, ShippingNoticePendingAttachment } from '../types/shipping.types';
interface EditableCandidateLine {
source: Record<string, unknown>;
part_number: string;
customer_part_number: string;
aws_part_number: string;
qty: string;
reservation_id: string;
inventory_source_hint: string;
uom: string;
}
const props = defineProps<{
attachment: ShippingNoticePendingAttachment;
canForceCreate: boolean;
}>();
const emit = defineEmits<{
update: [candidateNo: string, businessSummary: Record<string, unknown>, done: (success: boolean) => void];
resolveDuplicate: [candidateNo: string, action: ShippingDuplicateAction, targetTaskNo: string | undefined, reason: string | undefined, done: (success: boolean) => void];
promote: [candidateNo: string, done: (success: boolean) => void];
reject: [candidateNo: string, done: (success: boolean) => void];
}>();
const { t } = useI18n();
const editingCandidateNo = ref('');
const editError = ref('');
const editPoNumber = ref('');
const editLines = reactive<EditableCandidateLine[]>([]);
const forceReasonCandidateNo = ref('');
const forceReason = ref('');
const submittingCandidateNo = ref('');
const candidates = computed(() => props.attachment.candidates || []);
watch(() => props.attachment.candidates, () => {
if (editingCandidateNo.value && !candidates.value.some((item) => item.candidateNo === editingCandidateNo.value)) {
editingCandidateNo.value = '';
}
});
/**
* 将 Candidate 摘要投影为可编辑的 PO 与订单行。
* 核心逻辑:保留原始扩展字段,并显式映射三类料号、数量、Reservation ID、库存源线索与单位。
* @param candidateNo - 待编辑的 Candidate 编号
* @returns 无返回值;Candidate 不存在时保持当前编辑状态
*/
function startEdit(candidateNo: string): void {
const candidate = candidates.value.find((item) => item.candidateNo === candidateNo);
if (!candidate) return;
const sourceLines = Array.isArray(candidate.businessSummary.lines)
? candidate.businessSummary.lines.filter((item): item is Record<string, unknown> => !!item && typeof item === 'object')
: [];
editingCandidateNo.value = candidateNo;
editPoNumber.value = String(candidate.businessSummary.po_number || candidate.poNumber || '');
editLines.splice(0, editLines.length, ...sourceLines.map((line) => ({
source: { ...line },
part_number: String(line.part_number || ''),
customer_part_number: String(line.customer_part_number || ''),
aws_part_number: String(line.aws_part_number || ''),
qty: String(line.qty ?? ''),
reservation_id: String(line.reservation_id || ''),
inventory_source_hint: String(line.inventory_source_hint || ''),
uom: String(line.uom || 'EA'),
})));
if (!editLines.length) addLine();
editError.value = '';
}
/**
* 新增一条待修订订单行。
* 核心逻辑:创建带三类料号和可选库存源线索的空白草稿。
* @returns 无返回值
*/
function addLine(): void {
editLines.push({
source: {},
part_number: '',
customer_part_number: '',
aws_part_number: '',
qty: '',
reservation_id: '',
inventory_source_hint: '',
uom: 'EA',
});
}
/**
* 校验并提交 Candidate 修订。
* 核心逻辑:保留原始扩展字段,并按 v2 契约提交三类料号与唯一库存源线索。
* @returns 无返回值;校验失败时写入本地错误提示
*/
function saveEdit(): void {
const candidate = candidates.value.find((item) => item.candidateNo === editingCandidateNo.value);
if (!candidate || !editLines.length) return;
const normalizedLines = editLines.map((line) => {
const source = { ...line.source };
return {
...source,
part_number: line.part_number.trim(),
customer_part_number: line.customer_part_number.trim() || undefined,
aws_part_number: line.aws_part_number.trim() || undefined,
qty: Number(line.qty),
reservation_id: line.reservation_id.trim() || undefined,
inventory_source_hint: line.inventory_source_hint.trim() || undefined,
uom: line.uom.trim() || 'EA',
};
});
if (normalizedLines.some((line) => !line.part_number || !Number.isFinite(line.qty) || line.qty <= 0)) {
editError.value = t('chat.shippingCandidateInvalidLine');
return;
}
submittingCandidateNo.value = candidate.candidateNo;
emit('update', candidate.candidateNo, {
...candidate.businessSummary,
po_number: editPoNumber.value.trim() || null,
lines: normalizedLines,
}, (success) => {
submittingCandidateNo.value = '';
if (success) {
editingCandidateNo.value = '';
editError.value = '';
}
});
}
/**
* 非编辑态展示 Candidate 订单行摘要。
* @param candidate - 当前 Candidate
*/
function readonlyLines(candidate: typeof candidates.value[number]): Array<Record<string, unknown>> {
const lines = candidate.businessSummary?.lines;
return Array.isArray(lines)
? lines.filter((item): item is Record<string, unknown> => !!item && typeof item === 'object')
: [];
}
/** 将未知值格式化为表格占位文本。 */
function displayCell(value: unknown): string {
const text = String(value ?? '').trim();
return text || '—';
}
/** 将客户匹配状态转换为面向业务用户的文案。 */
function customerMatchStatus(status: string): string {
return t(`chat.shippingCustomerMatch.status.${status}`);
}
/** 对当前首个重复目标应用决策;强制新建时要求填写原因。 */
function resolveDuplicate(candidateNo: string, action: ShippingDuplicateAction): void {
const candidate = candidates.value.find((item) => item.candidateNo === candidateNo);
const target = candidate?.duplicate?.matches?.[0]?.taskNo;
if (action === 'force_create') {
forceReasonCandidateNo.value = candidateNo;
forceReason.value = '';
return;
}
submittingCandidateNo.value = candidateNo;
emit('resolveDuplicate', candidateNo, action, target, undefined, () => {
submittingCandidateNo.value = '';
});
}
/** 提交内联强制新建原因,避免浏览器 prompt 丢失上下文或不可访问。 */
function submitForceCreate(candidateNo: string): void {
const candidate = candidates.value.find((item) => item.candidateNo === candidateNo);
const reason = forceReason.value.trim();
if (!candidate || !reason) return;
submittingCandidateNo.value = candidateNo;
emit(
'resolveDuplicate',
candidateNo,
'force_create',
candidate.duplicate?.matches?.[0]?.taskNo,
reason,
(success) => {
submittingCandidateNo.value = '';
if (success) forceReasonCandidateNo.value = '';
},
);
}
/** 发起后端决定的人工采纳或驳回;UI 不自行推导履约资格。 */
function decideCandidate(candidateNo: string, action: 'promote' | 'reject'): void {
submittingCandidateNo.value = candidateNo;
const done = () => { submittingCandidateNo.value = ''; };
if (action === 'promote') emit('promote', candidateNo, done);
else emit('reject', candidateNo, done);
}
</script>
<template>
<div v-if="candidates.length" class="w-full space-y-2 rounded-xl border border-default bg-surface px-3 py-2">
<div class="flex items-center justify-between text-xs">
<span class="font-semibold text-primary">{{ t('chat.shippingCandidateTitle') }}</span>
<span class="text-muted">{{ t('chat.shippingCandidateCount', { count: candidates.length }) }}</span>
</div>
<div v-for="candidate in candidates" :key="candidate.candidateNo" class="rounded-lg border border-default bg-surface-soft p-2 text-xs">
<div class="flex flex-wrap items-center gap-2">
<span class="font-mono text-primary">{{ candidate.candidateNo }}</span>
<span class="font-medium text-secondary">PO {{ candidate.poNumber || '-' }}</span>
<span v-if="candidate.documentFilename" class="max-w-40 truncate text-muted">{{ candidate.documentFilename }}</span>
<span :class="candidate.candidateStatus === 'accepted' ? 'text-emerald-700' : 'text-amber-700'">
{{ candidate.candidateStatus === 'accepted' ? (candidate.acceptanceMode === 'automatic' ? t('chat.shippingCandidateAutoAccepted') : t('chat.shippingCandidateAccepted')) : (candidate.candidateStatus === 'rejected' ? t('chat.shippingCandidateRejected') : t('chat.shippingCandidateNeedsReview')) }}
</span>
<button v-if="candidate.actionButtons.includes('edit')" type="button" class="ml-auto text-brand-700 hover:underline" @click="startEdit(candidate.candidateNo)">
{{ t('chat.shippingCandidateEdit') }}
</button>
</div>
<div v-if="candidate.conflicts.length" class="mt-1 text-amber-700">
{{ t('chat.shippingCandidateConflictCount', { count: candidate.conflicts.length }) }}
</div>
<div
v-if="candidate.customerMatches?.length"
class="mt-2 overflow-x-auto rounded-lg border border-default bg-surface"
>
<div class="border-b border-default bg-surface-soft px-2 py-1.5 font-semibold text-primary">
{{ t('chat.shippingCustomerMatch.title') }}
</div>
<table class="min-w-full text-[11px]">
<thead class="text-left text-muted">
<tr>
<th class="px-2 py-1">{{ t('chat.shippingCustomerMatch.role') }}</th>
<th class="px-2 py-1">{{ t('chat.shippingCustomerMatch.rawName') }}</th>
<th class="px-2 py-1">{{ t('chat.shippingCustomerMatch.standardName') }}</th>
<th class="px-2 py-1">{{ t('chat.shippingCustomerMatch.shortCode') }}</th>
<th class="px-2 py-1">{{ t('chat.shippingCustomerMatch.site') }}</th>
<th class="px-2 py-1">{{ t('chat.shippingCustomerMatch.statusLabel') }}</th>
</tr>
</thead>
<tbody>
<tr v-for="match in candidate.customerMatches" :key="match.role" class="border-t border-default/60">
<td class="px-2 py-1 font-medium">{{ t(`chat.shippingCustomerMatch.roles.${match.role}`) }}</td>
<td class="px-2 py-1">{{ displayCell(match.raw_name) }}</td>
<td class="px-2 py-1">{{ displayCell(match.standard_name) }}</td>
<td class="px-2 py-1 font-mono">{{ displayCell(match.short_code) }}</td>
<td class="px-2 py-1">{{ displayCell(match.candidates?.find((item) => item.site_id === match.site_id)?.site_name) }}</td>
<td class="px-2 py-1">{{ customerMatchStatus(match.status) }}</td>
</tr>
</tbody>
</table>
</div>
<div
v-if="editingCandidateNo !== candidate.candidateNo && readonlyLines(candidate).length"
class="mt-2 overflow-x-auto rounded-lg border border-default bg-surface"
>
<table class="min-w-full text-[11px]">
<thead class="bg-surface-soft text-left text-muted">
<tr>
<th class="px-2 py-1">{{ t('chat.shippingNoticeUi.partNumber') }}</th>
<th class="px-2 py-1">{{ t('chat.shippingNoticeUi.customerPartNumber') }}</th>
<th class="px-2 py-1">{{ t('chat.shippingNoticeUi.awsPartNumber') }}</th>
<th class="px-2 py-1">{{ t('chat.shippingCandidateQty') }}</th>
<th class="px-2 py-1">{{ t('chat.shippingCandidateReservation') }}</th>
<th class="px-2 py-1">{{ t('chat.shippingNoticeUi.inventorySourceHint') }}</th>
</tr>
</thead>
<tbody>
<tr
v-for="(line, index) in readonlyLines(candidate)"
:key="`${candidate.candidateNo}-line-${index}`"
class="border-t border-default/60"
>
<td class="px-2 py-1 font-mono">{{ displayCell(line.part_number) }}</td>
<td class="px-2 py-1 font-mono">{{ displayCell(line.customer_part_number) }}</td>
<td class="px-2 py-1 font-mono">{{ displayCell(line.aws_part_number) }}</td>
<td class="px-2 py-1">{{ displayCell(line.qty) }}</td>
<td class="px-2 py-1 font-mono">{{ displayCell(line.reservation_id) }}</td>
<td class="px-2 py-1">{{ displayCell(line.inventory_source_hint) }}</td>
</tr>
</tbody>
</table>
</div>
<div v-if="(candidate.missingFields || []).length" class="mt-1 text-amber-700">
{{ t('chat.shippingCandidateMissingFields', { fields: (candidate.missingFields || []).join(', ') }) }}
</div>
<div v-if="candidate.duplicate?.blocking && !candidate.duplicateResolution" class="mt-2 flex flex-wrap items-center gap-2 text-amber-700">
<span>{{ t('chat.shippingCandidateDuplicate', { task: candidate.duplicate.matches[0]?.taskNo || '-' }) }}</span>
<button
v-if="candidate.duplicate.allowedActions.includes('open_existing')"
type="button"
class="rounded border border-default bg-surface px-2 py-0.5"
@click="resolveDuplicate(candidate.candidateNo, 'open_existing')"
>{{ t('chat.shippingNoticeDuplicateOpenExisting') }}</button>
<button
v-if="candidate.duplicate.allowedActions.includes('create_revision')"
type="button"
class="rounded border border-default bg-surface px-2 py-0.5"
@click="resolveDuplicate(candidate.candidateNo, 'create_revision')"
>{{ t('chat.shippingNoticeDuplicateCreateRevision') }}</button>
<button
v-if="canForceCreate && candidate.duplicate.allowedActions.includes('force_create')"
type="button"
class="rounded border border-amber-300 bg-surface px-2 py-0.5"
@click="resolveDuplicate(candidate.candidateNo, 'force_create')"
>{{ t('chat.shippingNoticeDuplicateForceCreate') }}</button>
</div>
<div v-if="forceReasonCandidateNo === candidate.candidateNo" class="mt-2 flex gap-2">
<input v-model="forceReason" :placeholder="t('chat.shippingCandidateForceReasonPrompt')" class="min-w-0 flex-1 rounded border border-default bg-surface px-2 py-1" />
<button type="button" class="rounded bg-amber-600 px-2 py-1 text-white disabled:opacity-50" :disabled="!forceReason.trim() || submittingCandidateNo === candidate.candidateNo" @click="submitForceCreate(candidate.candidateNo)">{{ t('chat.shippingNoticeDuplicateConfirm') }}</button>
<button type="button" class="text-muted" @click="forceReasonCandidateNo = ''">{{ t('common.cancel') }}</button>
</div>
<div v-else-if="candidate.duplicateResolution" class="mt-1 text-muted">
{{ t('chat.shippingCandidateDuplicateResolved', { action: candidate.duplicateResolution.action }) }}
</div>
<div v-if="candidate.actionButtons.includes('promote') || candidate.actionButtons.includes('reject')" class="mt-2 flex gap-2">
<button v-if="candidate.actionButtons.includes('promote')" type="button" class="rounded bg-brand-600 px-2 py-1 text-white disabled:opacity-50" :disabled="submittingCandidateNo === candidate.candidateNo" @click="decideCandidate(candidate.candidateNo, 'promote')">{{ t('chat.shippingCandidatePromote') }}</button>
<button v-if="candidate.actionButtons.includes('reject')" type="button" class="rounded border border-default px-2 py-1 text-secondary disabled:opacity-50" :disabled="submittingCandidateNo === candidate.candidateNo" @click="decideCandidate(candidate.candidateNo, 'reject')">{{ t('chat.shippingCandidateReject') }}</button>
</div>
<div v-if="editingCandidateNo === candidate.candidateNo" class="mt-2 space-y-2">
<label class="block">
<span class="text-muted">{{ t('chat.shippingCandidatePoNumber') }}</span>
<input v-model="editPoNumber" class="mt-1 w-full rounded border border-default bg-surface px-2 py-1 text-primary" />
</label>
<div v-for="(line, index) in editLines" :key="index" class="grid grid-cols-2 gap-2 rounded border border-default bg-surface p-2 md:grid-cols-4">
<input v-model="line.part_number" :placeholder="t('chat.shippingNoticeUi.partNumber')" class="rounded border border-default px-2 py-1" />
<input v-model="line.customer_part_number" :placeholder="t('chat.shippingNoticeUi.customerPartNumber')" class="rounded border border-default px-2 py-1" />
<input v-model="line.aws_part_number" :placeholder="t('chat.shippingNoticeUi.awsPartNumber')" class="rounded border border-default px-2 py-1" />
<input v-model="line.qty" type="number" min="0.0001" step="any" :placeholder="t('chat.shippingCandidateQty')" class="rounded border border-default px-2 py-1" />
<input v-model="line.reservation_id" :placeholder="t('chat.shippingCandidateReservation')" class="rounded border border-default px-2 py-1" />
<input v-model="line.inventory_source_hint" :placeholder="t('chat.shippingNoticeUi.inventorySourceHint')" class="rounded border border-default px-2 py-1" />
<div class="flex gap-1">
<input v-model="line.uom" :placeholder="t('chat.shippingCandidateUom')" class="min-w-0 flex-1 rounded border border-default px-2 py-1" />
<button v-if="editLines.length > 1" type="button" class="text-red-600" @click="editLines.splice(index, 1)">×</button>
</div>
</div>
<button type="button" class="text-brand-700 hover:underline" @click="addLine">{{ t('chat.shippingCandidateAddLine') }}</button>
<div v-if="editError" class="text-red-600">{{ editError }}</div>
<div class="flex justify-end gap-2">
<button type="button" class="rounded px-2 py-1 text-secondary" @click="editingCandidateNo = ''">{{ t('common.cancel') }}</button>
<button type="button" class="rounded bg-brand-600 px-2 py-1 text-white disabled:opacity-50" :disabled="submittingCandidateNo === candidate.candidateNo" @click="saveEdit">{{ t('chat.shippingCandidateSave') }}</button>
</div>
</div>
</div>
</div>
</template>
@@ -23,7 +23,6 @@ import ChatMessageAttachmentList from './ChatMessageAttachmentList.vue';
import MaintenanceDeviceResultCard from './MaintenanceDeviceResultCard.vue';
import ShippingMatchResultCard from './ShippingMatchResultCard.vue';
import ShippingParseReviewMessage, { type ShippingParseReviewHandlers } from './ShippingParseReviewMessage.vue';
import ShippingNoticeCandidateReview from '../ShippingNoticeCandidateReview.vue';
import type { ShippingMessageHandlers } from './shippingMessageHandlers';
import TrainingExamQuestionMessage, { type TrainingHandlers } from './TrainingExamQuestionMessage.vue';
import TrainingVideoMessage from './TrainingVideoMessage.vue';
@@ -32,8 +31,6 @@ import TrainingResultCard from './TrainingResultCard.vue';
import ShippingOrderExtractionCard from '../shipping/ShippingOrderExtractionCard.vue';
import type { ChatMessage, InlineDownloadFile, SourceFileLink } from '../../types/chat.types';
import type { ShippingMatchResultPayload } from '../../types/shipping.types';
import type { ShippingNoticePendingAttachment } from '../../types/shipping.types';
import type { ShippingOrderExtractionReviewAttachment } from '../../types/chat.types';
import type { MaintenanceDevice } from '@/features/maintenance/types/ledger.types';
import type { MaintenanceRecord } from '@/features/maintenance/types/record.types';
@@ -137,60 +134,12 @@ const showShippingActionsPanel = computed(() =>
);
const shippingOrderExtractionState = computed(() => message.shipping_order_extraction_state);
const retryingOrderExtraction = ref(false);
const reviewAttachmentsSection = ref<HTMLElement | null>(null);
const shippingOrderExtractionRunNo = computed(() => {
const payload = message.payload && typeof message.payload === 'object'
? message.payload as Record<string, unknown>
: {};
return String(payload.order_extraction_run_no || '').trim();
});
const shippingOrderExtractionReviewAttachments = computed<ShippingNoticePendingAttachment[]>(() => {
const payload = message.payload && typeof message.payload === 'object' ? message.payload as Record<string, unknown> : {};
const reviews = Array.isArray(payload.shipping_order_extraction_review)
? payload.shipping_order_extraction_review as ShippingOrderExtractionReviewAttachment[]
: [];
return reviews
.filter((item) => item && Array.isArray(item.candidates) && item.candidates.length)
.map((item) => ({
id: `shipping-order-extraction-review-${item.intakeNo}`,
kind: 'shipping_notice' as const,
type: 'document' as const,
intakeNo: item.intakeNo,
uploadStatus: 'uploaded' as const,
parseStatus: 'parsed' as const,
uploadProgress: 100,
originalFilename: item.originalFilename,
fileSize: 0,
candidates: item.candidates,
}));
});
const updateOrderExtractionCandidate = async (
candidateNo: string,
businessSummary: Record<string, unknown>,
done: (success: boolean) => void,
) => {
await shippingHandlers.updateCandidate(candidateNo, businessSummary, done);
};
const promoteOrderExtractionCandidate = async (candidateNo: string, done: (success: boolean) => void) => {
await shippingHandlers.promoteCandidate(candidateNo, done);
};
const rejectOrderExtractionCandidate = async (candidateNo: string, done: (success: boolean) => void) => {
await shippingHandlers.rejectCandidate(candidateNo, done);
};
const resolveOrderExtractionCandidateDuplicate = async (
candidateNo: string,
action: import('../../types/shipping.types').ShippingDuplicateAction,
targetTaskNo: string | undefined,
reason: string | undefined,
done: (success: boolean) => void,
) => {
await shippingHandlers.resolveCandidateDuplicate(candidateNo, action, targetTaskNo, reason, done);
};
/** 失败卡片复用原 Run 重试;按钮本地防重,成功后状态卡由 Run 轮询原位更新。 */
const retryShippingOrderExtraction = async () => {
if (!shippingOrderExtractionRunNo.value || retryingOrderExtraction.value) return;
@@ -201,11 +150,6 @@ const retryShippingOrderExtraction = async () => {
retryingOrderExtraction.value = false;
}
};
const enterOrderExtractionManualReview = async () => {
if (!shippingOrderExtractionReviewAttachments.value.length) return;
await nextTick();
reviewAttachmentsSection.value?.scrollIntoView({ behavior: 'smooth', block: 'start' });
};
const isLastMessage = computed(() => index === messageCount - 1 || (message.role === 'assistant' && isLatestAssistantMessage));
const isCopied = computed(() => copiedIndex === index);
const renderedMarkdown = computed(() => (
@@ -732,26 +676,8 @@ function handleInlineDownload(file: InlineDownloadFile): void {
v-if="shippingOrderExtractionState"
:state="shippingOrderExtractionState"
:run-no="shippingOrderExtractionRunNo"
:has-review-attachments="shippingOrderExtractionReviewAttachments.length > 0"
@retry="retryShippingOrderExtraction"
@enter-manual-review="enterOrderExtractionManualReview"
/>
<div
v-if="shippingOrderExtractionReviewAttachments.length"
ref="reviewAttachmentsSection"
class="mb-3 space-y-2"
>
<ShippingNoticeCandidateReview
v-for="attachment in shippingOrderExtractionReviewAttachments"
:key="attachment.intakeNo"
:attachment="attachment"
:can-force-create="false"
@update="updateOrderExtractionCandidate"
@resolve-duplicate="resolveOrderExtractionCandidateDuplicate"
@promote="promoteOrderExtractionCandidate"
@reject="rejectOrderExtractionCandidate"
/>
</div>
<LeaveMessageBlock
v-if="isLeaveMessage"
:message="message"
@@ -17,7 +17,6 @@ export interface ShippingMessageHandlers {
removeLine: (msg: ChatMessage, lineIndex: number) => Promise<boolean>;
retryOrderExtractionRun: (runNo: string) => Promise<boolean>;
reparseOrderExtractionRun: (runNo: string, reason: 'rule_updated' | 'field_mapping_error' | 'document_quality' | 'other') => Promise<boolean>;
updateCandidate: (candidateNo: string, businessSummary: Record<string, unknown>, done: (success: boolean) => void) => Promise<void>;
resolveCandidateDuplicate: (candidateNo: string, action: import('../../types/shipping.types').ShippingDuplicateAction, targetTaskNo: string | undefined, reason: string | undefined, done: (success: boolean) => void) => Promise<void>;
promoteCandidate: (candidateNo: string, done: (success: boolean) => void) => Promise<void>;
rejectCandidate: (candidateNo: string, done: (success: boolean) => void) => Promise<void>;
@@ -0,0 +1,73 @@
<!--
用途:渲染受控 PDF Blob,并仅为服务端验证的 bbox 绘制证据高亮。
依赖:pdfjs-dist、Review Evidence DTO。
逻辑:预览失败独立显示,不影响同页草稿编辑;缺少可靠 bbox 时只保留页码定位。
-->
<script setup lang="ts">
import { nextTick, ref, watch } from 'vue';
import * as pdfjs from 'pdfjs-dist';
import workerUrl from 'pdfjs-dist/build/pdf.worker.min.mjs?url';
import type { ShippingOrderReviewEvidence } from '../../types/shipping.api.types';
pdfjs.GlobalWorkerOptions.workerSrc = workerUrl;
const props = defineProps<{
src: string;
evidence?: ShippingOrderReviewEvidence | null;
title: string;
loadingText: string;
unavailableText: string;
}>();
const canvas = ref<HTMLCanvasElement | null>(null);
const loading = ref(false);
const failed = ref(false);
/** 将当前页渲染到 canvas;高亮以 PDF viewport 为基准,绝不猜测不可靠坐标。 */
const render = async () => {
if (!props.src) return;
loading.value = true;
failed.value = false;
try {
const document = await pdfjs.getDocument(props.src).promise;
const pageNo = Math.min(Math.max(props.evidence?.page_no || 1, 1), document.numPages);
const page = await document.getPage(pageNo);
const viewport = page.getViewport({ scale: 1.4 });
await nextTick();
if (!canvas.value) return;
canvas.value.width = Math.ceil(viewport.width);
canvas.value.height = Math.ceil(viewport.height);
const context = canvas.value.getContext('2d');
if (!context) return;
await page.render({ canvas: canvas.value, canvasContext: context, viewport }).promise;
const bbox = props.evidence?.bbox;
if (bbox) {
context.save();
context.fillStyle = 'rgba(250, 204, 21, 0.35)';
context.strokeStyle = 'rgba(202, 138, 4, 0.95)';
context.lineWidth = 2;
const x = bbox.x0 * viewport.width;
const y = bbox.y0 * viewport.height;
const width = (bbox.x1 - bbox.x0) * viewport.width;
const height = (bbox.y1 - bbox.y0) * viewport.height;
context.fillRect(x, y, width, height);
context.strokeRect(x, y, width, height);
context.restore();
}
} catch {
failed.value = true;
} finally {
loading.value = false;
}
};
watch(() => [props.src, props.evidence?.evidence_id], () => { void render(); }, { immediate: true });
</script>
<template>
<div class="relative flex min-h-[360px] items-center justify-center overflow-auto bg-slate-100 p-3 dark:bg-slate-950">
<!-- Keep the canvas mounted while PDF.js is loading; otherwise nextTick cannot obtain a render target. -->
<canvas ref="canvas" :aria-label="title" class="max-w-full bg-white shadow" :class="{ invisible: loading || failed }" />
<span v-if="loading" class="absolute text-sm text-slate-500">{{ loadingText }}</span>
<span v-else-if="failed" class="absolute text-sm text-rose-600">{{ unavailableText }}</span>
</div>
</template>
@@ -3,7 +3,7 @@
* features/chat/components/shipping/ShippingOrderDocumentResultItem.vue
* 用途:渲染单个 PDF 的订单抽取结果摘要,供详情抽屉按文档逐项展示。
* 依赖:订单抽取文档 DTO、vue-i18n。
* 逻辑:只显示用户可理解的业务字段;人工复核入口复用现有候选审核区,不直接暴露内部证据细节。
* 逻辑:只显示用户可理解的业务字段;人工复核由上层统一跳转独立工作台。
*/
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
@@ -12,14 +12,13 @@ import type { ShippingOrderExtractionDocumentResult } from '../../types/shipping
const props = defineProps<{
document: ShippingOrderExtractionDocumentResult;
hasReviewAttachments?: boolean;
}>();
const emit = defineEmits<{
enterManualReview: [];
}>();
const { t, te } = useI18n();
const { t, te, locale } = useI18n();
const statusTone = computed(() => {
switch (props.document.status) {
@@ -36,6 +35,23 @@ const statusTone = computed(() => {
});
const statusLabel = computed(() => t(`chat.shippingOrderExtractionDocumentStatus.${props.document.status}`));
const statusActivityLabel = computed(() => {
const key = `chat.shippingOrderExtractionActivity.${props.document.activity_event_code || props.document.status}`;
return te(key) ? t(key) : statusLabel.value;
});
const formatTime = (value: string | null | undefined): string => {
const date = new Date(String(value || ''));
if (Number.isNaN(date.getTime())) return '';
return new Intl.DateTimeFormat(String(locale.value || 'zh-CN'), {
hour: '2-digit', minute: '2-digit', hour12: false,
}).format(date);
};
const activityTimeLabel = computed(() => {
if (props.document.finished_at) return t('chat.shippingOrderExtractionDocumentTiming.finished', { time: formatTime(props.document.finished_at) });
if (props.document.last_activity_at) return t('chat.shippingOrderExtractionDocumentTiming.updated', { time: formatTime(props.document.last_activity_at) });
if (props.document.started_at) return t('chat.shippingOrderExtractionDocumentTiming.started', { time: formatTime(props.document.started_at) });
return '';
});
const reasonLabel = computed(() => (
props.document.reason_code
? t(`chat.shippingOrderExtractionReason.${props.document.reason_code}`)
@@ -81,13 +97,9 @@ const reviewFieldLabel = (fieldCode: string | null | undefined): string => {
};
const canEnterManualReview = computed(() => (
props.hasReviewAttachments
&& props.document.available_actions.some((action) => action === 'review_candidate' || action === 'manual_review')
));
const canViewEvidence = computed(() => (
props.hasReviewAttachments
&& props.document.available_actions.includes('view_evidence')
props.document.available_actions.some((action) => action === 'review_candidate' || action === 'manual_review')
));
const canViewEvidence = computed(() => props.document.available_actions.includes('view_evidence'));
</script>
<template>
@@ -105,7 +117,11 @@ const canViewEvidence = computed(() => (
<div class="truncate text-sm font-semibold">{{ document.file_name || t('chat.shippingOrderExtractionUnknownDocument') }}</div>
<span class="rounded-full bg-black/10 px-2 py-0.5 text-[11px] dark:bg-white/10">{{ statusLabel }}</span>
</div>
<div v-if="['pending', 'routing', 'matching_profile', 'extracting', 'merging_supplement'].includes(document.status) || document.activity_event_code" class="mt-1 text-xs font-medium opacity-85">
{{ statusActivityLabel }}
</div>
<div class="mt-2 flex flex-wrap gap-x-4 gap-y-1 text-xs opacity-85">
<span v-if="activityTimeLabel">{{ activityTimeLabel }}</span>
<span v-if="document.selection_batch">
{{ t('chat.shippingOrderExtractionSelectionBatch', { batch: document.selection_batch }) }}
</span>
@@ -8,6 +8,7 @@ import { nextTick } from 'vue';
import { mount } from '@vue/test-utils';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { createI18n } from 'vue-i18n';
import { createMemoryHistory, createRouter } from 'vue-router';
import chatZhCn from '@/locales/zh-CN/chat.json';
import ShippingOrderDocumentResultItem from './ShippingOrderDocumentResultItem.vue';
import ShippingOrderExtractionCard from './ShippingOrderExtractionCard.vue';
@@ -43,6 +44,14 @@ const flushUi = async () => {
await nextTick();
};
const makeRouter = () => createRouter({
history: createMemoryHistory(),
routes: [
{ path: '/chat/:agentId', name: 'Chat', component: { template: '<div />' } },
{ path: '/chat/:agentId/order-review/:runNo', name: 'ShippingOrderReview', component: { template: '<div />' } },
],
});
const buildState = (patch: Partial<ShippingOrderExtractionState> = {}): ShippingOrderExtractionState => ({
status: 'processing',
summary: {
@@ -116,7 +125,7 @@ describe('ShippingOrderExtractionCard', () => {
document.body.innerHTML = '';
});
it('loads documents once when opening details from server actions', async () => {
it('refreshes documents whenever the details drawer is opened', async () => {
api.listDocuments.mockResolvedValue({ items: [buildDocument()] });
api.listProgressEvents.mockResolvedValue({ items: [buildProgressEvent()] });
const wrapper = mount(ShippingOrderExtractionCard, {
@@ -189,21 +198,24 @@ describe('ShippingOrderExtractionCard', () => {
await detailButton!.trigger('click');
await flushUi();
expect(api.listDocuments).toHaveBeenCalledTimes(1);
expect(api.listProgressEvents).toHaveBeenCalledTimes(1);
expect(api.listDocuments).toHaveBeenCalledTimes(2);
expect(api.listProgressEvents).toHaveBeenCalledTimes(2);
});
it('emits manual review directly when attachments are already available', async () => {
it('routes manual review directly to the dedicated workspace', async () => {
const router = makeRouter();
await router.push({ name: 'Chat', params: { agentId: 'agent-1' } });
await router.isReady();
const pushSpy = vi.spyOn(router, 'push');
const wrapper = mount(ShippingOrderExtractionCard, {
props: {
state: buildState({
availableActions: ['enter_manual_review'],
}),
runNo: 'SNER-002',
hasReviewAttachments: true,
},
global: {
plugins: [i18n],
plugins: [i18n, router],
stubs: {
teleport: true,
},
@@ -215,10 +227,37 @@ describe('ShippingOrderExtractionCard', () => {
await reviewButton!.trigger('click');
expect(wrapper.emitted('enterManualReview')).toHaveLength(1);
await vi.waitFor(() => expect(pushSpy).toHaveBeenCalled());
expect(pushSpy).toHaveBeenCalledWith({
name: 'Chat',
params: { agentId: 'agent-1' },
query: { mode: 'order-review', run_no: 'SNER-002' },
});
expect(api.listDocuments).not.toHaveBeenCalled();
});
it('preserves the originating conversation when entering manual review', async () => {
const router = makeRouter();
await router.push({ name: 'Chat', params: { agentId: 'agent-1' }, query: { conversation_id: 'conv-123' } });
await router.isReady();
const pushSpy = vi.spyOn(router, 'push');
const wrapper = mount(ShippingOrderExtractionCard, {
props: { state: buildState({ availableActions: ['enter_manual_review'] }), runNo: 'SNER-003' },
global: { plugins: [i18n, router], stubs: { teleport: true } },
});
const reviewButton = wrapper.findAll('button').find((item) => item.text().includes('进入人工复核'));
expect(reviewButton).toBeTruthy();
await reviewButton!.trigger('click');
await vi.waitFor(() => expect(pushSpy).toHaveBeenCalled());
expect(pushSpy).toHaveBeenCalledWith({
name: 'Chat',
params: { agentId: 'agent-1' },
query: { conversation_id: 'conv-123', mode: 'order-review', run_no: 'SNER-003' },
});
});
it('emits retry for failed attachments without mutating state locally', async () => {
const wrapper = mount(ShippingOrderExtractionCard, {
props: {
@@ -305,7 +344,6 @@ describe('ShippingOrderExtractionDetailsDrawer', () => {
loadFailed: false,
progressLoading: false,
progressLoadFailed: false,
hasReviewAttachments: true,
},
global: {
plugins: [i18n],
@@ -369,7 +407,6 @@ describe('ShippingOrderDocumentResultItem', () => {
},
available_actions: ['view_evidence', 'manual_review'],
}),
hasReviewAttachments: true,
},
global: {
plugins: [i18n],
@@ -5,7 +5,8 @@
* 依赖:订单抽取 Run 状态卡 DTO、documents API、详情抽屉。
* 逻辑:卡片只显示 Run 汇总、当前活动和下一步动作;逐 PDF 结果与 Run 事实时间线延迟到抽屉内按需加载。
*/
import { computed, ref, watch } from 'vue';
import { computed, onBeforeUnmount, ref, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { CircleCheck, CircleX, LoaderCircle, TriangleAlert } from 'lucide-vue-next';
import {
@@ -22,7 +23,6 @@ import ShippingOrderExtractionDetailsDrawer from './ShippingOrderExtractionDetai
const props = defineProps<{
state: ShippingOrderExtractionState;
runNo?: string;
hasReviewAttachments?: boolean;
}>();
const emit = defineEmits<{
@@ -31,6 +31,8 @@ const emit = defineEmits<{
}>();
const { t, te } = useI18n();
const route = useRoute();
const router = useRouter();
const detailsOpen = ref(false);
const documents = ref<ShippingOrderExtractionDocumentResult[]>([]);
@@ -41,6 +43,17 @@ const documentsLoadedForRun = ref('');
const loadingProgressEvents = ref(false);
const progressEventsLoadFailed = ref(false);
const progressEventsLoadedForRun = ref('');
let detailsRefreshTimer: ReturnType<typeof setInterval> | null = null;
const detailsFreshnessKey = computed(() => JSON.stringify({
runNo: props.runNo || '',
status: props.state.status,
phase: props.state.currentActivity?.eventCode || '',
total: props.state.summary.totalDocuments,
completed: props.state.summary.completedDocuments,
reviewRequired: props.state.summary.reviewRequiredDocuments,
failed: props.state.summary.failedDocuments,
}));
watch(
() => props.runNo,
@@ -152,11 +165,16 @@ const currentActivityContextSummary = computed(() => {
return parts.join(' · ');
});
const openDetails = async () => {
/**
* 刷新抽屉中的 Run 详情。
*
* 文档列表可能在布局 Job 完成后才落库;抽屉绝不能缓存首次打开时的空结果,
* 否则聊天卡已显示新状态而详情仍停留在旧的“暂无结果”。
*/
const refreshDetails = async () => {
if (!props.runNo) return;
detailsOpen.value = true;
const tasks: Promise<void>[] = [];
if (documentsLoadedForRun.value !== props.runNo && !loadingDocuments.value) {
if (!loadingDocuments.value) {
loadingDocuments.value = true;
documentsLoadFailed.value = false;
tasks.push(
@@ -173,7 +191,7 @@ const openDetails = async () => {
}),
);
}
if (progressEventsLoadedForRun.value !== props.runNo && !loadingProgressEvents.value) {
if (!loadingProgressEvents.value) {
loadingProgressEvents.value = true;
progressEventsLoadFailed.value = false;
tasks.push(
@@ -195,17 +213,55 @@ const openDetails = async () => {
}
};
const openDetails = async () => {
if (!props.runNo) return;
detailsOpen.value = true;
await refreshDetails();
};
/** 详情打开期间独立刷新,避免长任务只在聊天卡状态变更时才显示新阶段。 */
const stopDetailsRefresh = () => {
if (detailsRefreshTimer) clearInterval(detailsRefreshTimer);
detailsRefreshTimer = null;
};
watch(detailsOpen, (open) => {
stopDetailsRefresh();
if (!open || !props.runNo || !['queued', 'processing'].includes(props.state.status)) return;
detailsRefreshTimer = setInterval(() => void refreshDetails(), 2000);
});
watch(() => props.state.status, (status) => {
if (!['queued', 'processing'].includes(status)) stopDetailsRefresh();
});
onBeforeUnmount(stopDetailsRefresh);
watch(detailsFreshnessKey, () => {
if (detailsOpen.value) void refreshDetails();
});
/** 新建单前复核统一进入独立工作台,不能再落入聊天内旧 Candidate 编辑区。 */
const openReviewWorkspace = async () => {
if (!props.runNo) return;
await router.push({
name: 'Chat',
params: { agentId: String(route.params.agentId || '') },
query: {
...route.query,
mode: 'order-review',
run_no: props.runNo,
},
});
};
const handleActionClick = async (action: string) => {
switch (action) {
case 'view_details':
await openDetails();
return;
case 'enter_manual_review':
if (props.hasReviewAttachments) {
emit('enterManualReview');
} else {
await openDetails();
}
await openReviewWorkspace();
return;
case 'retry_failed_attachments':
emit('retry');
@@ -235,7 +291,6 @@ const handleActionClick = async (action: string) => {
<div class="mt-2 flex flex-wrap gap-x-3 gap-y-1 text-xs opacity-90">
<span>{{ t('chat.shippingOrderExtractionSummary.total', { count: state.summary.totalDocuments }) }}</span>
<span>{{ t('chat.shippingOrderExtractionSummary.completedProgress', { value: completedLabel }) }}</span>
<span>{{ t('chat.shippingOrderExtractionSummary.candidates', { count: state.summary.candidateCount }) }}</span>
<span>{{ t('chat.shippingOrderExtractionSummary.reviewRequired', { count: state.summary.reviewRequiredDocuments }) }}</span>
<span v-if="state.summary.failedDocuments > 0">
{{ t('chat.shippingOrderExtractionSummary.failed', { count: state.summary.failedDocuments }) }}
@@ -294,9 +349,8 @@ const handleActionClick = async (action: string) => {
:load-failed="documentsLoadFailed"
:progress-loading="loadingProgressEvents"
:progress-load-failed="progressEventsLoadFailed"
:has-review-attachments="hasReviewAttachments"
@close="detailsOpen = false"
@enter-manual-review="emit('enterManualReview')"
@enter-manual-review="openReviewWorkspace"
/>
</div>
</template>
@@ -5,7 +5,7 @@
* 依赖:订单抽取状态卡、文档结果项、订单抽取 progress-events DTO、vue-i18n。
* 逻辑:聊天摘要卡只显示概览;需要查看逐文档结果和每轮事件原因时由本抽屉承接新的 Run 级事实时间线。
*/
import { onBeforeUnmount, watch } from 'vue';
import { onBeforeUnmount, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { X } from 'lucide-vue-next';
import type { ShippingOrderExtractionState } from '../../types/chat.types';
@@ -25,7 +25,6 @@ const props = defineProps<{
loadFailed: boolean;
progressLoading: boolean;
progressLoadFailed: boolean;
hasReviewAttachments?: boolean;
}>();
const emit = defineEmits<{
@@ -35,6 +34,7 @@ const emit = defineEmits<{
const { t, te, locale } = useI18n();
let removeKeydownListener: (() => void) | null = null;
const timelineOpen = ref(false);
const translateReasonCodes = (codes: string[] | undefined): string[] => (
(codes || [])
@@ -155,37 +155,27 @@ onBeforeUnmount(() => {
</header>
<div class="flex-1 space-y-3 overflow-y-auto px-4 py-4">
<div
v-if="state.selectionPlan?.totalAttachmentCount || state.unitSummary?.technicalFailureReasonCodes?.length"
class="rounded-lg border border-slate-200 bg-slate-50 px-3 py-3 text-xs text-slate-700 dark:border-slate-700 dark:bg-slate-900/60 dark:text-slate-200"
>
<div v-if="state.selectionPlan?.totalAttachmentCount">
{{ t('chat.shippingOrderExtractionPlanSummary', {
total: state.selectionPlan.totalAttachmentCount,
groups: state.selectionPlan.groupCount || 0,
attachments: state.selectionPlan.maxInitialAttachments || 0,
concurrency: state.selectionPlan.maxInitialConcurrency || 0,
}) }}
</div>
<div v-if="state.unitSummary?.reviewRequiredReasonCodes?.length" class="mt-1">
{{ t('chat.shippingOrderExtractionReviewReasonCodes', {
codes: translateReasonCodes(state.unitSummary.reviewRequiredReasonCodes).join(' / '),
}) }}
</div>
<div v-if="state.unitSummary?.expansionTriggerReasonCodes?.length" class="mt-1">
{{ t('chat.shippingOrderExtractionExpansionTriggerCodes', {
codes: translateReasonCodes(state.unitSummary.expansionTriggerReasonCodes).join(' / '),
}) }}
</div>
<div v-if="state.unitSummary?.technicalFailureReasonCodes?.length" class="mt-1">
{{ t('chat.shippingOrderExtractionTechnicalFailureCodes', {
codes: state.unitSummary.technicalFailureReasonCodes.join(', '),
}) }}
</div>
<div v-if="loading" class="rounded-lg border border-dashed border-slate-300 px-3 py-4 text-sm text-slate-600 dark:border-slate-700 dark:text-slate-300">
{{ t('chat.shippingOrderExtractionDocumentsLoading') }}
</div>
<div class="rounded-lg border border-slate-200 bg-white px-3 py-3 dark:border-slate-700 dark:bg-slate-950/40">
<div class="text-xs font-semibold text-slate-900 dark:text-slate-100">
{{ t('chat.shippingOrderExtractionTimelineTitle') }}
<div v-else-if="loadFailed" class="rounded-lg border border-amber-300 bg-amber-50 px-3 py-4 text-sm text-amber-900 dark:border-amber-700 dark:bg-amber-950/30 dark:text-amber-100">
{{ t('chat.shippingOrderExtractionDocumentsUnavailable') }}
</div>
<div v-else-if="documents.length === 0" class="rounded-lg border border-dashed border-slate-300 px-3 py-4 text-sm text-slate-600 dark:border-slate-700 dark:text-slate-300">
{{ t('chat.shippingOrderExtractionNoDocuments') }}
</div>
<ShippingOrderDocumentResultItem
v-for="document in documents"
:key="document.unit_id"
:document="document"
@enter-manual-review="emit('enterManualReview')"
/>
<details :open="timelineOpen" class="rounded-lg border border-slate-200 bg-white px-3 py-3 dark:border-slate-700 dark:bg-slate-950/40" @toggle="timelineOpen = ($event.currentTarget as HTMLDetailsElement).open">
<summary class="cursor-pointer text-xs font-semibold text-slate-900 dark:text-slate-100">{{ t('chat.shippingOrderExtractionTimelineTitle') }}</summary>
<div v-if="state.selectionPlan?.totalAttachmentCount || state.unitSummary?.technicalFailureReasonCodes?.length" class="mt-3 rounded-lg bg-slate-50 px-3 py-3 text-xs text-slate-700 dark:bg-slate-900/60 dark:text-slate-200">
<div v-if="state.selectionPlan?.totalAttachmentCount">{{ t('chat.shippingOrderExtractionPlanSummary', { total: state.selectionPlan.totalAttachmentCount, groups: state.selectionPlan.groupCount || 0, attachments: state.selectionPlan.maxInitialAttachments || 0, concurrency: state.selectionPlan.maxInitialConcurrency || 0 }) }}</div>
<div v-if="state.unitSummary?.reviewRequiredReasonCodes?.length" class="mt-1">{{ t('chat.shippingOrderExtractionReviewReasonCodes', { codes: translateReasonCodes(state.unitSummary.reviewRequiredReasonCodes).join(' / ') }) }}</div>
<div v-if="state.unitSummary?.technicalFailureReasonCodes?.length" class="mt-1">{{ t('chat.shippingOrderExtractionTechnicalFailureCodes', { codes: state.unitSummary.technicalFailureReasonCodes.join(', ') }) }}</div>
</div>
<div
v-if="progressLoading"
@@ -227,23 +217,7 @@ onBeforeUnmount(() => {
</div>
</li>
</ol>
</div>
<div v-if="loading" class="rounded-lg border border-dashed border-slate-300 px-3 py-4 text-sm text-slate-600 dark:border-slate-700 dark:text-slate-300">
{{ t('chat.shippingOrderExtractionDocumentsLoading') }}
</div>
<div v-else-if="loadFailed" class="rounded-lg border border-amber-300 bg-amber-50 px-3 py-4 text-sm text-amber-900 dark:border-amber-700 dark:bg-amber-950/30 dark:text-amber-100">
{{ t('chat.shippingOrderExtractionDocumentsUnavailable') }}
</div>
<div v-else-if="documents.length === 0" class="rounded-lg border border-dashed border-slate-300 px-3 py-4 text-sm text-slate-600 dark:border-slate-700 dark:text-slate-300">
{{ t('chat.shippingOrderExtractionNoDocuments') }}
</div>
<ShippingOrderDocumentResultItem
v-for="document in documents"
:key="document.unit_id"
:document="document"
:has-review-attachments="hasReviewAttachments"
@enter-manual-review="emit('enterManualReview')"
/>
</details>
</div>
</aside>
</div>