feat(shipping-notice): 新增发货通知重复检测与处理接口,支持重复决策保存与重新执行检测
This commit is contained in:
1 parent
729546a7b7
commit
ceb49461e8
72 files changed
+14270
-460
No files matched your search
@@ -515,6 +515,31 @@ export const cancelShippingNoticeIntake = (intakeNo: string) =>
|
||||
{ method: 'DELETE' },
|
||||
);
|
||||
|
||||
export const resolveShippingNoticeDuplicate = (
|
||||
intakeNo: string,
|
||||
action: string,
|
||||
targetTaskNo?: string | null,
|
||||
reason?: string | null,
|
||||
) =>
|
||||
requestJson<ShippingNoticeIntakeResponse>(
|
||||
`/api/workspace/shipping-notice/intakes/${encodeURIComponent(intakeNo)}/duplicate-resolution`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
action,
|
||||
target_task_no: targetTaskNo || undefined,
|
||||
reason: reason || undefined,
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
export const refreshShippingNoticeDuplicate = (intakeNo: string) =>
|
||||
requestJson<ShippingNoticeIntakeResponse>(
|
||||
`/api/workspace/shipping-notice/intakes/${encodeURIComponent(intakeNo)}/duplicate-refresh`,
|
||||
{ method: 'POST' },
|
||||
);
|
||||
|
||||
export const createWorkspaceShippingBatchFromIntakes = (
|
||||
intakeNos: string[],
|
||||
conversationId?: string | null,
|
||||
|
||||
@@ -20,7 +20,11 @@ import {
|
||||
Square,
|
||||
X,
|
||||
} from 'lucide-vue-next';
|
||||
import type { PendingAttachment } from '../types/shipping.types';
|
||||
import type { PendingAttachment, ShippingNoticePendingAttachment } from '../types/shipping.types';
|
||||
import {
|
||||
isBlockingWarning,
|
||||
isShippingNoticeAttachmentParseIncomplete,
|
||||
} from '../shipping/shippingNoticeAttachmentIntegrity';
|
||||
|
||||
export interface ChatInputAttachmentPolicy {
|
||||
anyEnabled: boolean;
|
||||
@@ -60,6 +64,7 @@ const emit = defineEmits<{
|
||||
'voice-click': [];
|
||||
'remove-attachment': [id: string];
|
||||
'retry-shipping-notice-attachment': [id: string];
|
||||
'resolve-shipping-notice-duplicate': [id: string];
|
||||
'local-files-selected': [event: Event];
|
||||
'add-remote-url': [url: string];
|
||||
'shipping-inventory-selected': [event: Event];
|
||||
@@ -79,6 +84,73 @@ const showAttachmentMenu = ref(false);
|
||||
const showAttachmentUrlPanel = ref(false);
|
||||
const showKbDropdown = ref(false);
|
||||
const attachmentUrlInput = ref('');
|
||||
|
||||
/**
|
||||
* 汇总 EML 附件解析进度,供输入栏徽标展示。
|
||||
* 核心逻辑:failed/empty/skipped/超限/文本预算耗尽计为问题;duplicate 单独提示,不记为失败。
|
||||
*/
|
||||
function shippingNoticeAttachmentHint(attachment: ShippingNoticePendingAttachment): string {
|
||||
const summary = attachment.parseSummary;
|
||||
const total = Number(summary?.attachment_count || 0);
|
||||
const rows = summary?.attachments || [];
|
||||
const warnings = summary?.warnings || [];
|
||||
const hasBlockingWarning = warnings.some((w) => isBlockingWarning(String(w || '')));
|
||||
if (!total && !hasBlockingWarning && !rows.length) return '';
|
||||
|
||||
const effectiveTotal = total || rows.length;
|
||||
const ok = rows.filter((item) => item.parse_status === 'parsed').length;
|
||||
const problematic = rows.filter((item) =>
|
||||
['failed', 'empty', 'skipped'].includes(String(item.parse_status || '')),
|
||||
).length;
|
||||
const duplicates = rows.filter((item) => item.parse_status === 'duplicate').length;
|
||||
const overflow = Math.max(0, effectiveTotal - rows.length);
|
||||
const issues = problematic + overflow + (hasBlockingWarning && problematic === 0 && overflow === 0 ? 1 : 0);
|
||||
|
||||
if (issues > 0) {
|
||||
return t('chat.shippingNoticeAttachmentHintPartial', {
|
||||
ok,
|
||||
total: effectiveTotal || Math.max(ok + issues, 1),
|
||||
failed: issues,
|
||||
});
|
||||
}
|
||||
if (duplicates > 0) {
|
||||
return t('chat.shippingNoticeAttachmentHintWithDup', { ok, total: effectiveTotal, duplicates });
|
||||
}
|
||||
if (!effectiveTotal) return '';
|
||||
return t('chat.shippingNoticeAttachmentHint', { ok, total: effectiveTotal });
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否展示「重试解析」:顶层失败,或已 parsed 但附件不完整。
|
||||
*/
|
||||
function canRetryShippingNoticeParse(attachment: ShippingNoticePendingAttachment): boolean {
|
||||
if (attachment.kind !== 'shipping_notice') return false;
|
||||
if (attachment.parseStatus === 'failed') return true;
|
||||
return (
|
||||
attachment.parseStatus === 'parsed'
|
||||
&& isShippingNoticeAttachmentParseIncomplete(attachment.parseSummary)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成附件明细 title(文件名 + 状态 + 关键警告),便于悬停查看完整性。
|
||||
*/
|
||||
function shippingNoticeAttachmentTitle(attachment: ShippingNoticePendingAttachment): string {
|
||||
const rows = attachment.parseSummary?.attachments || [];
|
||||
const warnings = attachment.parseSummary?.warnings || [];
|
||||
const lines: string[] = [];
|
||||
for (const item of rows) {
|
||||
const name = item.filename || item.attachment_key || 'attachment';
|
||||
const status = item.parse_status || 'unknown';
|
||||
lines.push(`${name}: ${status}`);
|
||||
}
|
||||
for (const warning of warnings) {
|
||||
const text = String(warning || '').trim();
|
||||
if (text) lines.push(`warning: ${text}`);
|
||||
}
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
const closeAttachmentMenu = () => {
|
||||
showAttachmentMenu.value = false;
|
||||
showAttachmentUrlPanel.value = false;
|
||||
@@ -246,7 +318,36 @@ watch(
|
||||
{{ a.originalFilename }}
|
||||
<span v-if="a.uploadStatus === 'uploading'" class="text-muted"> · {{ t('chat.shippingNoticeUploading') }}</span>
|
||||
<span v-else-if="a.parseStatus === 'queued' || a.parseStatus === 'parsing'" class="text-muted"> · {{ t('chat.shippingNoticeParsing') }}</span>
|
||||
<span v-else-if="a.parseStatus === 'parsed'" class="text-muted"> · {{ t('chat.shippingNoticeParsed') }}</span>
|
||||
<span
|
||||
v-else-if="a.parseStatus === 'parsed' && a.duplicate?.status === 'possible_duplicate' && !a.duplicateResolution?.action"
|
||||
class="font-medium text-amber-700"
|
||||
> · {{ t('chat.shippingNoticeDuplicatePossibleBadge') }}</span>
|
||||
<span
|
||||
v-else-if="a.parseStatus === 'parsed' && a.duplicate?.blocking && !a.duplicateResolution?.action"
|
||||
class="font-medium text-amber-700"
|
||||
> · {{ t('chat.shippingNoticeDuplicateBlockingBadge') }}</span>
|
||||
<span
|
||||
v-else-if="a.parseStatus === 'parsed' && a.duplicateResolution?.action === 'create_revision'"
|
||||
class="text-brand-700"
|
||||
> · {{ t('chat.shippingNoticeDuplicateRevisionChosen') }}</span>
|
||||
<span
|
||||
v-else-if="a.parseStatus === 'parsed' && a.duplicateResolution?.action === 'force_create'"
|
||||
class="text-amber-700"
|
||||
> · {{ t('chat.shippingNoticeDuplicateForceChosen') }}</span>
|
||||
<span
|
||||
v-else-if="a.parseStatus === 'parsed' && a.duplicateResolution?.action === 'open_existing'"
|
||||
class="text-muted"
|
||||
> · {{ t('chat.shippingNoticeDuplicateOpenChosen') }}</span>
|
||||
<span
|
||||
v-else-if="a.parseStatus === 'parsed'"
|
||||
class="text-muted"
|
||||
:title="shippingNoticeAttachmentTitle(a)"
|
||||
>
|
||||
· {{ t('chat.shippingNoticeParsed') }}
|
||||
<template v-if="shippingNoticeAttachmentHint(a)">
|
||||
· {{ shippingNoticeAttachmentHint(a) }}
|
||||
</template>
|
||||
</span>
|
||||
<span v-else-if="a.parseStatus === 'failed'" class="text-muted"> · {{ t('chat.shippingNoticeParseFailed') }}</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
@@ -254,7 +355,16 @@ watch(
|
||||
</template>
|
||||
</span>
|
||||
<button
|
||||
v-if="a.kind === 'shipping_notice' && a.parseStatus === 'failed'"
|
||||
v-if="a.kind === 'shipping_notice' && a.duplicate?.blocking && !a.duplicateResolution?.action"
|
||||
type="button"
|
||||
class="text-amber-700 hover:text-amber-800"
|
||||
:title="t('chat.shippingNoticeDuplicateHandle')"
|
||||
@click="emit('resolve-shipping-notice-duplicate', a.id)"
|
||||
>
|
||||
{{ t('chat.shippingNoticeDuplicateHandle') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="a.kind === 'shipping_notice' && canRetryShippingNoticeParse(a)"
|
||||
type="button"
|
||||
class="text-muted hover:text-primary"
|
||||
:title="t('chat.shippingNoticeRetryParse')"
|
||||
|
||||
@@ -287,6 +287,7 @@ watch(() => page.currentAgentId, () => {
|
||||
@voice-click="page.handleVoiceFeatureClick"
|
||||
@remove-attachment="page.removeAttachment"
|
||||
@retry-shipping-notice-attachment="page.retryShippingNoticeAttachment"
|
||||
@resolve-shipping-notice-duplicate="page.openShippingDuplicateDialog"
|
||||
@local-files-selected="page.handleLocalFilesSelected"
|
||||
@add-remote-url="page.addRemoteUrlAttachment"
|
||||
@shipping-inventory-selected="page.handleShippingInventorySelected"
|
||||
|
||||
@@ -10,6 +10,7 @@ import ChatQueryPreviewDialog from '@/features/chat/components/ChatQueryPreviewD
|
||||
import ChatLeaveAgentDialog from '@/features/chat/components/ChatLeaveAgentDialog.vue';
|
||||
import ChatOALoginDialog from '@/features/chat/components/ChatOALoginDialog.vue';
|
||||
import ChatGuideModal from '@/features/chat/components/ChatGuideModal.vue';
|
||||
import ShippingNoticeDuplicateDialog from '@/features/chat/components/ShippingNoticeDuplicateDialog.vue';
|
||||
import { Check, Loader2, X } from 'lucide-vue-next';
|
||||
import { nextTick } from 'vue';
|
||||
import { useChatPageContext } from '@/features/chat/composables/chat.context';
|
||||
@@ -145,4 +146,13 @@ async function handleQueryPreviewAssetImage(assetId: string, assetName: string)
|
||||
:guides="page.agentGuides"
|
||||
:active-guide="page.activeGuide"
|
||||
/>
|
||||
<ShippingNoticeDuplicateDialog
|
||||
:open="!!page.showShippingDuplicateDialog"
|
||||
:attachment="page.shippingDuplicateAttachment || null"
|
||||
:can-force-create="!!page.canForceCreateShippingDuplicate"
|
||||
@update:open="(v) => { if (!v) page.closeShippingDuplicateDialog?.(); }"
|
||||
@resolve="(payload) => void page.resolveShippingDuplicateDialog?.(payload)"
|
||||
@remove="() => void page.removeShippingDuplicateDialogAttachment?.()"
|
||||
@cancel="page.closeShippingDuplicateDialog?.()"
|
||||
/>
|
||||
</template>
|
||||
@@ -4,7 +4,7 @@
|
||||
* 用途:发货通知 Agent 的右侧批次工作台抽屉,承载多批次切换、任务筛选、步骤诊断与统一动作入口。
|
||||
* 依赖:shippingStepper、shippingMenu、shipping.api.types、vue-i18n、lucide-vue-next。
|
||||
* 逻辑:上游传入会话级 workspace 与当前批次任务;本组件只渲染后端 `ui_state.action_buttons` 和查看类辅助入口。
|
||||
* 「重试所有失败」仅 emit `retry-pending`,由父级打开确认弹窗后再调用 useChatShipping 执行。
|
||||
* 解析阶段诊断优先展示 `ui_state.summary.issues` 完整问题列表;「重试所有失败」仅 emit `retry-pending`,由父级打开确认弹窗后再调用 useChatShipping 执行。
|
||||
*/
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { RefreshCw, Target, X } from 'lucide-vue-next';
|
||||
@@ -247,12 +247,42 @@ const currentStepProgress = (task: ShippingTaskSummary | ShippingTaskDetail) =>
|
||||
const sanitizeDiagnosisCopy = (text: string | null | undefined) =>
|
||||
sanitizeShippingRuntimeStatusText(String(text || '').trim());
|
||||
|
||||
/**
|
||||
* 读取任务诊断卡要展示的全部问题列表。
|
||||
* 核心逻辑:优先消费后端 `ui_state.summary.issues`(解析阶段已汇总库存源+warnings);
|
||||
* 若缺失则回退到单一 error_message,保证旧数据仍有可读文案。
|
||||
*/
|
||||
const resolveTaskDiagnosisIssues = (task: ShippingTaskSummary | ShippingTaskDetail): string[] => {
|
||||
const uiIssues = task.ui_state?.summary?.issues;
|
||||
if (Array.isArray(uiIssues) && uiIssues.length) {
|
||||
return uiIssues
|
||||
.map((item) => sanitizeDiagnosisCopy(item))
|
||||
.filter(Boolean);
|
||||
}
|
||||
const fallback = sanitizeDiagnosisCopy(task.ui_state?.summary?.error_message || task.error_message);
|
||||
return fallback ? [fallback] : [];
|
||||
};
|
||||
|
||||
/**
|
||||
* 解析右侧工作台诊断标题/建议/问题列表。
|
||||
* 核心逻辑:解析阶段若 issues 多于 1 条,使用「发现问题」标题并列出全部条目,避免只显示库存源一条。
|
||||
*/
|
||||
const resolveTaskDiagnosis = (task: ShippingTaskSummary | ShippingTaskDetail) => {
|
||||
const uiSummary = task.ui_state?.summary;
|
||||
if (uiSummary?.title || uiSummary?.message || uiSummary?.error_message) {
|
||||
const issues = resolveTaskDiagnosisIssues(task);
|
||||
if (uiSummary?.title || uiSummary?.message || uiSummary?.error_message || issues.length) {
|
||||
const multiIssue = issues.length > 1;
|
||||
return {
|
||||
title: sanitizeDiagnosisCopy(uiSummary.error_message || uiSummary.title) || t('chat.shippingNoticeUi.diagnosisStepWaitingTitle', { step: taskStepNumber(task) }),
|
||||
advice: sanitizeDiagnosisCopy(uiSummary.message) || t('chat.shippingNoticeUi.diagnosisStepWaitingAdvice'),
|
||||
title: multiIssue
|
||||
? t('chat.shippingNoticeUi.diagnosisIssuesTitle', { count: issues.length })
|
||||
: (
|
||||
sanitizeDiagnosisCopy(issues[0] || uiSummary?.error_message || uiSummary?.title)
|
||||
|| t('chat.shippingNoticeUi.diagnosisStepWaitingTitle', { step: taskStepNumber(task) })
|
||||
),
|
||||
advice: multiIssue
|
||||
? t('chat.shippingNoticeUi.diagnosisIssuesAdvice')
|
||||
: (sanitizeDiagnosisCopy(uiSummary?.message) || t('chat.shippingNoticeUi.diagnosisStepWaitingAdvice')),
|
||||
issues: multiIssue ? issues : [],
|
||||
};
|
||||
}
|
||||
const reason = String(task.pending_human_reason || '').trim();
|
||||
@@ -577,11 +607,24 @@ const handleSwitchBatch = (batchNo: string) => {
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-for="diagnosis in [resolveTaskDiagnosis(task)]"
|
||||
:key="`${task.task_no}-diagnosis`"
|
||||
class="mb-2 rounded-lg border p-2.5 text-xs font-medium leading-5"
|
||||
:class="isFailedTask(task) ? 'border-rose-100 bg-rose-50 text-rose-700' : isAbnormalTask(task) ? 'border-amber-100 bg-amber-50 text-amber-700' : 'border-emerald-100 bg-emerald-50 text-emerald-700'"
|
||||
>
|
||||
<div class="font-semibold">{{ resolveTaskDiagnosis(task).title }}</div>
|
||||
<div class="mt-1 font-normal text-slate-600">{{ resolveTaskDiagnosis(task).advice }}</div>
|
||||
<div class="font-semibold">{{ diagnosis.title }}</div>
|
||||
<ul
|
||||
v-if="(diagnosis.issues || []).length"
|
||||
class="mt-1.5 list-disc space-y-1 pl-4 font-normal text-slate-700"
|
||||
>
|
||||
<li
|
||||
v-for="(issue, issueIndex) in diagnosis.issues"
|
||||
:key="`${task.task_no}-issue-${issueIndex}`"
|
||||
>
|
||||
{{ issue }}
|
||||
</li>
|
||||
</ul>
|
||||
<div class="mt-1 font-normal text-slate-600">{{ diagnosis.advice }}</div>
|
||||
</div>
|
||||
<div v-if="!resolveWorkspaceActionButtons(task).length" class="mb-3 text-xs leading-5 text-muted">
|
||||
<span class="font-semibold text-secondary">{{ t('chat.shippingNoticeUi.suggestedAction') }}</span>
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
/**
|
||||
* features/chat/components/ShippingNoticeDuplicateDialog.vue
|
||||
* 用途:发货通知阻断型重复处理弹窗(打开已有 / 修订 / 强制新建)。
|
||||
* 依赖:shipping.types Duplicate 类型、vue-i18n。
|
||||
* 逻辑:ChatViewOverlays 展示;确认后回写 resolveDuplicateAttachment,再允许确认建单。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type {
|
||||
ShippingDuplicateAction,
|
||||
ShippingNoticePendingAttachment,
|
||||
} from '../types/shipping.types';
|
||||
|
||||
const props = defineProps<{
|
||||
open: boolean;
|
||||
attachment: ShippingNoticePendingAttachment | null;
|
||||
canForceCreate: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:open': [value: boolean];
|
||||
resolve: [payload: { action: ShippingDuplicateAction; targetTaskNo?: string; reason?: string }];
|
||||
remove: [];
|
||||
cancel: [];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
const reason = ref('');
|
||||
const selectedAction = ref<ShippingDuplicateAction>('open_existing');
|
||||
const submitting = ref(false);
|
||||
const localError = ref('');
|
||||
|
||||
const match = computed(() => props.attachment?.duplicate?.matches?.[0] || null);
|
||||
const allowed = computed(() => new Set(props.attachment?.duplicate?.allowedActions || []));
|
||||
|
||||
watch(
|
||||
() => props.open,
|
||||
(open) => {
|
||||
if (!open) return;
|
||||
reason.value = '';
|
||||
localError.value = '';
|
||||
submitting.value = false;
|
||||
const actions = props.attachment?.duplicate?.allowedActions || [];
|
||||
selectedAction.value = (actions[0] as ShippingDuplicateAction) || 'open_existing';
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* 关闭弹窗。
|
||||
*/
|
||||
function close() {
|
||||
emit('update:open', false);
|
||||
emit('cancel');
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交所选重复处理动作。
|
||||
*/
|
||||
async function confirm() {
|
||||
if (!props.attachment?.duplicate || !match.value) return;
|
||||
const action = selectedAction.value;
|
||||
if (!allowed.value.has(action)) {
|
||||
localError.value = t('chat.shippingNoticeDuplicateActionUnavailable');
|
||||
return;
|
||||
}
|
||||
if (action === 'force_create') {
|
||||
if (!props.canForceCreate) {
|
||||
localError.value = t('chat.shippingNoticeDuplicateForceForbidden');
|
||||
return;
|
||||
}
|
||||
if (!reason.value.trim()) {
|
||||
localError.value = t('chat.shippingNoticeDuplicateReasonRequired');
|
||||
return;
|
||||
}
|
||||
}
|
||||
submitting.value = true;
|
||||
localError.value = '';
|
||||
try {
|
||||
emit('resolve', {
|
||||
action,
|
||||
targetTaskNo: match.value.taskNo,
|
||||
reason: action === 'force_create' ? reason.value.trim() : undefined,
|
||||
});
|
||||
emit('update:open', false);
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
const statusLabel = computed(() => {
|
||||
const status = props.attachment?.duplicate?.status;
|
||||
if (status === 'exact_file') return t('chat.shippingNoticeDuplicateExactFile');
|
||||
if (status === 'same_active_task') return t('chat.shippingNoticeDuplicateSameActive');
|
||||
if (status === 'same_completed_task') return t('chat.shippingNoticeDuplicateSameCompleted');
|
||||
if (status === 'possible_duplicate') return t('chat.shippingNoticeDuplicatePossible');
|
||||
return t('chat.shippingNoticeDuplicateNeedsResolution');
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="open && attachment"
|
||||
class="fixed inset-0 z-[160] flex items-center justify-center bg-black/40 px-4"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
>
|
||||
<div class="w-full max-w-lg rounded-xl border border-default bg-surface p-5 shadow-xl">
|
||||
<h3 class="text-base font-semibold text-primary">
|
||||
{{ t('chat.shippingNoticeDuplicateTitle') }}
|
||||
</h3>
|
||||
<p class="mt-2 text-sm text-secondary">{{ statusLabel }}</p>
|
||||
<p class="mt-1 text-xs text-muted">
|
||||
{{ attachment.originalFilename }}
|
||||
</p>
|
||||
|
||||
<div
|
||||
v-if="match"
|
||||
class="mt-4 rounded-lg border border-default bg-surface-soft px-3 py-2 text-sm text-secondary"
|
||||
>
|
||||
<div>{{ t('chat.shippingNoticeDuplicateMatchTask', { taskNo: match.taskNo }) }}</div>
|
||||
<div class="mt-1 text-xs text-muted">
|
||||
{{ t('chat.shippingNoticeDuplicateMatchStatus', { status: match.processStatus }) }}
|
||||
· v{{ match.documentVersion }}
|
||||
</div>
|
||||
<div v-if="match.matchedFields?.length" class="mt-1 text-xs text-muted">
|
||||
{{ t('chat.shippingNoticeDuplicateMatchFields', { fields: match.matchedFields.join(', ') }) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 space-y-2">
|
||||
<label
|
||||
v-if="allowed.has('open_existing')"
|
||||
class="flex cursor-pointer items-start gap-2 rounded-lg border border-default px-3 py-2 text-sm"
|
||||
:class="selectedAction === 'open_existing' ? 'border-brand-500 bg-brand-50/40' : ''"
|
||||
>
|
||||
<input v-model="selectedAction" type="radio" value="open_existing" class="mt-1" />
|
||||
<span>
|
||||
<span class="font-medium text-primary">{{ t('chat.shippingNoticeDuplicateOpenExisting') }}</span>
|
||||
<span class="mt-0.5 block text-xs text-muted">{{ t('chat.shippingNoticeDuplicateOpenExistingHint') }}</span>
|
||||
</span>
|
||||
</label>
|
||||
<label
|
||||
v-if="allowed.has('create_revision')"
|
||||
class="flex cursor-pointer items-start gap-2 rounded-lg border border-default px-3 py-2 text-sm"
|
||||
:class="selectedAction === 'create_revision' ? 'border-brand-500 bg-brand-50/40' : ''"
|
||||
>
|
||||
<input v-model="selectedAction" type="radio" value="create_revision" class="mt-1" />
|
||||
<span>
|
||||
<span class="font-medium text-primary">{{ t('chat.shippingNoticeDuplicateCreateRevision') }}</span>
|
||||
<span class="mt-0.5 block text-xs text-muted">{{ t('chat.shippingNoticeDuplicateCreateRevisionHint') }}</span>
|
||||
</span>
|
||||
</label>
|
||||
<label
|
||||
v-if="allowed.has('force_create') && canForceCreate"
|
||||
class="flex cursor-pointer items-start gap-2 rounded-lg border border-default px-3 py-2 text-sm"
|
||||
:class="selectedAction === 'force_create' ? 'border-amber-500 bg-amber-50/50' : ''"
|
||||
>
|
||||
<input v-model="selectedAction" type="radio" value="force_create" class="mt-1" />
|
||||
<span>
|
||||
<span class="font-medium text-primary">{{ t('chat.shippingNoticeDuplicateForceCreate') }}</span>
|
||||
<span class="mt-0.5 block text-xs text-muted">{{ t('chat.shippingNoticeDuplicateForceCreateHint') }}</span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div v-if="selectedAction === 'force_create'" class="mt-3">
|
||||
<label class="text-xs font-medium text-secondary">{{ t('chat.shippingNoticeDuplicateReasonLabel') }}</label>
|
||||
<textarea
|
||||
v-model="reason"
|
||||
rows="2"
|
||||
class="mt-1 w-full rounded-lg border border-default bg-surface px-3 py-2 text-sm"
|
||||
:placeholder="t('chat.shippingNoticeDuplicateReasonPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<p v-if="localError" class="mt-2 text-xs text-red-600">{{ localError }}</p>
|
||||
|
||||
<div class="mt-5 flex flex-wrap justify-end gap-2">
|
||||
<button type="button" class="rounded-lg px-3 py-1.5 text-sm text-muted hover:text-primary" @click="close">
|
||||
{{ t('common.cancel') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg px-3 py-1.5 text-sm text-red-600 hover:bg-red-50"
|
||||
@click="emit('remove'); emit('update:open', false)"
|
||||
>
|
||||
{{ t('chat.shippingNoticeDuplicateRemoveFile') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-brand-600 px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50"
|
||||
:disabled="submitting || !match"
|
||||
@click="confirm"
|
||||
>
|
||||
{{ t('chat.shippingNoticeDuplicateConfirm') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -551,6 +551,13 @@ export function useChatPage() {
|
||||
attachmentApi.removeAttachment(id);
|
||||
},
|
||||
retryShippingNoticeAttachment: shipping.retryShippingNoticeAttachment,
|
||||
showShippingDuplicateDialog: shipping.showShippingDuplicateDialog,
|
||||
shippingDuplicateAttachment: shipping.shippingDuplicateAttachment,
|
||||
canForceCreateShippingDuplicate: shipping.canForceCreateShippingDuplicate,
|
||||
openShippingDuplicateDialog: shipping.openShippingDuplicateDialog,
|
||||
resolveShippingDuplicateDialog: shipping.resolveShippingDuplicateDialog,
|
||||
removeShippingDuplicateDialogAttachment: shipping.removeShippingDuplicateDialogAttachment,
|
||||
closeShippingDuplicateDialog: shipping.closeShippingDuplicateDialog,
|
||||
filePreviewVisible,
|
||||
previewFile,
|
||||
previewFiles,
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
type ComputedRef,
|
||||
type Ref,
|
||||
} from 'vue';
|
||||
import { useAuthStore } from '@/features/auth/stores/auth.store';
|
||||
import { agentUsesWorkspaceStepperProgress, isShippingNoticeAgent as resolveShippingNoticeAgent } from '@/shared/utils/agent-registry.utils';
|
||||
import type { AgentRegistryFields } from '@/shared/utils/agent-registry.utils';
|
||||
import { hasActiveRunningChatRun } from '../shipping/shippingActionBusy';
|
||||
@@ -667,6 +668,68 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
t,
|
||||
});
|
||||
|
||||
const showShippingDuplicateDialog = ref(false);
|
||||
const shippingDuplicateAttachmentId = ref<string | null>(null);
|
||||
const shippingDuplicateAttachment = computed(() => {
|
||||
const id = shippingDuplicateAttachmentId.value;
|
||||
if (!id) return null;
|
||||
return shippingIntakes.noticeAttachments.value.find((item) => item.id === id) || null;
|
||||
});
|
||||
const canForceCreateShippingDuplicate = computed(() => {
|
||||
const user = useAuthStore().user;
|
||||
if (!user) return false;
|
||||
if (String(user.role || '') === 'admin') return true;
|
||||
return Boolean(user.feature_permissions?.shipping_notice_force_create);
|
||||
});
|
||||
|
||||
/**
|
||||
* 打开首个(或指定)阻断型重复附件的处理弹窗。
|
||||
*/
|
||||
const openShippingDuplicateDialog = (attachmentId?: string) => {
|
||||
const targetId =
|
||||
attachmentId
|
||||
|| shippingIntakes.noticeAttachments.value.find(
|
||||
(item) => item.duplicate?.blocking && !item.duplicateResolution?.action,
|
||||
)?.id
|
||||
|| null;
|
||||
if (!targetId) {
|
||||
msg.warning(t('chat.shippingNoticeDuplicateNeedsResolution'));
|
||||
return;
|
||||
}
|
||||
shippingDuplicateAttachmentId.value = targetId;
|
||||
showShippingDuplicateDialog.value = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* 提交重复决策并写回附件状态。
|
||||
*/
|
||||
const resolveShippingDuplicateDialog = async (payload: {
|
||||
action: import('../types/shipping.types').ShippingDuplicateAction;
|
||||
targetTaskNo?: string;
|
||||
reason?: string;
|
||||
}) => {
|
||||
const id = shippingDuplicateAttachmentId.value;
|
||||
if (!id) return;
|
||||
try {
|
||||
await shippingIntakes.resolveDuplicateAttachment(
|
||||
id,
|
||||
payload.action,
|
||||
payload.targetTaskNo,
|
||||
payload.reason,
|
||||
);
|
||||
msg.success(t('chat.shippingNoticeDuplicateResolved'));
|
||||
} catch (e: unknown) {
|
||||
msg.warning(e instanceof Error ? e.message : t('chat.shippingNoticeDuplicateResolveFailed'));
|
||||
}
|
||||
};
|
||||
|
||||
const removeShippingDuplicateDialogAttachment = async () => {
|
||||
const id = shippingDuplicateAttachmentId.value;
|
||||
if (!id) return;
|
||||
await shippingIntakes.removeNoticeAttachment(id);
|
||||
shippingDuplicateAttachmentId.value = null;
|
||||
};
|
||||
|
||||
const {
|
||||
handleShippingAutoUploadFile,
|
||||
handleShippingAutoUploadNoticeBatch,
|
||||
@@ -755,6 +818,8 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
isShippingNoticeBatchSubmitting,
|
||||
hasBlockingNoticeIntake: () => shippingIntakes.hasBlockingUploadOrParse.value,
|
||||
hasNoticeIntakeFailures: () => shippingIntakes.hasParseFailures.value,
|
||||
hasBlockingNoticeDuplicates: () => shippingIntakes.hasBlockingDuplicates.value,
|
||||
openShippingDuplicateDialog,
|
||||
getParsedIntakeNos: shippingIntakes.getParsedIntakeNos,
|
||||
refreshShippingActions,
|
||||
shippingSuggestedPrompt,
|
||||
@@ -1067,6 +1132,15 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
handleShippingLocalFilesSelected,
|
||||
removeShippingNoticeAttachment: shippingIntakes.removeNoticeAttachment,
|
||||
retryShippingNoticeAttachment: shippingIntakes.retryNoticeAttachment,
|
||||
showShippingDuplicateDialog,
|
||||
shippingDuplicateAttachment,
|
||||
canForceCreateShippingDuplicate,
|
||||
openShippingDuplicateDialog,
|
||||
resolveShippingDuplicateDialog,
|
||||
removeShippingDuplicateDialogAttachment,
|
||||
closeShippingDuplicateDialog: () => {
|
||||
showShippingDuplicateDialog.value = false;
|
||||
},
|
||||
tryHandleShippingAttachmentAutoFlow,
|
||||
tryHandleShippingSend,
|
||||
onConversationIdChanging,
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* features/chat/shipping/shippingNoticeAttachmentIntegrity.spec.ts
|
||||
* 用途:附件完整性门禁单测;阻断码与截断路径须能阻止建单判定。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import {
|
||||
BLOCKING_WARNING_PREFIXES,
|
||||
isShippingNoticeAttachmentParseIncomplete,
|
||||
} from './shippingNoticeAttachmentIntegrity';
|
||||
|
||||
describe('shippingNoticeAttachmentIntegrity', () => {
|
||||
it('treats each blocking warning prefix as incomplete', () => {
|
||||
for (const prefix of BLOCKING_WARNING_PREFIXES) {
|
||||
expect(
|
||||
isShippingNoticeAttachmentParseIncomplete({
|
||||
warnings: [`${prefix}demo`],
|
||||
attachments: [],
|
||||
}),
|
||||
).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it('treats per-attachment text truncation as incomplete', () => {
|
||||
expect(
|
||||
isShippingNoticeAttachmentParseIncomplete({
|
||||
attachment_count: 1,
|
||||
attachments: [
|
||||
{
|
||||
parse_status: 'parsed',
|
||||
warnings: ['eml_attachment_text_truncated:10'],
|
||||
},
|
||||
],
|
||||
warnings: [],
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('treats notice_text_truncated as incomplete', () => {
|
||||
expect(
|
||||
isShippingNoticeAttachmentParseIncomplete({
|
||||
warnings: ['notice_text_truncated:200000'],
|
||||
attachments: [],
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('allows clean parsed summary', () => {
|
||||
expect(
|
||||
isShippingNoticeAttachmentParseIncomplete({
|
||||
attachment_count: 1,
|
||||
attachments: [{ parse_status: 'parsed', warnings: [] }],
|
||||
warnings: [],
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* features/chat/shipping/shippingNoticeAttachmentIntegrity.ts
|
||||
* 用途:发货通知附件完整性门禁契约(阻断 warning 前缀与 incomplete 判定)。
|
||||
* 依赖:shipping.types(ParseSummary 形状)。
|
||||
* 逻辑:与后端 attachment_integrity.BLOCKING_WARNING_PREFIXES /
|
||||
* is_attachment_parse_incomplete 保持一致;契约测试校验两端前缀集合。
|
||||
*/
|
||||
|
||||
import type { ShippingNoticeParseSummary } from '../types/shipping.types';
|
||||
|
||||
/** 阻断 warning 前缀;须与 backend BLOCKING_WARNING_PREFIXES 完全一致(顺序可不同)。 */
|
||||
export const BLOCKING_WARNING_PREFIXES = [
|
||||
'eml_nesting_depth_exceeded:',
|
||||
'eml_attachment_limit_exceeded:',
|
||||
'eml_total_attachment_size_exceeded:',
|
||||
'eml_nested_message_unreadable',
|
||||
'eml_attachment_text_budget_exhausted:',
|
||||
'eml_attachment_text_truncated:',
|
||||
'notice_text_truncated:',
|
||||
] as const;
|
||||
|
||||
const INCOMPLETE_ATTACHMENT_STATUSES = new Set(['failed', 'empty', 'skipped']);
|
||||
|
||||
/**
|
||||
* 判定单条 warning 是否为完整性阻断项。
|
||||
*/
|
||||
export function isBlockingWarning(text: string): boolean {
|
||||
const normalized = String(text || '');
|
||||
return BLOCKING_WARNING_PREFIXES.some((prefix) => normalized.startsWith(prefix));
|
||||
}
|
||||
|
||||
/**
|
||||
* 判定 EML 等 intake 是否存在未完整解析的附件(含超深/超限/截断警告)。
|
||||
* 核心逻辑:阻断警告、登记数少于发现数、或 failed/empty/skipped 均视为不完整;
|
||||
* duplicate 仅为去重,不阻断建单。
|
||||
*/
|
||||
export function isShippingNoticeAttachmentParseIncomplete(
|
||||
summary?: ShippingNoticeParseSummary | null,
|
||||
): boolean {
|
||||
if (!summary) return false;
|
||||
const warnings = summary.warnings || [];
|
||||
if (warnings.some((item) => isBlockingWarning(String(item || '')))) {
|
||||
return true;
|
||||
}
|
||||
const rows = summary.attachments || [];
|
||||
const total = Number(summary.attachment_count || 0);
|
||||
if (total > rows.length) return true;
|
||||
return rows.some((item) => {
|
||||
if (INCOMPLETE_ATTACHMENT_STATUSES.has(String(item.parse_status || ''))) {
|
||||
return true;
|
||||
}
|
||||
return (item.warnings || []).some((w) => isBlockingWarning(String(w || '')));
|
||||
});
|
||||
}
|
||||
@@ -64,6 +64,8 @@ export interface ShippingSendHandlerContext {
|
||||
isShippingNoticeBatchSubmitting?: () => boolean;
|
||||
hasBlockingNoticeIntake?: () => boolean;
|
||||
hasNoticeIntakeFailures?: () => boolean;
|
||||
hasBlockingNoticeDuplicates?: () => boolean;
|
||||
openShippingDuplicateDialog?: (attachmentId?: string) => void;
|
||||
getParsedIntakeNos?: () => string[];
|
||||
refreshShippingActions: () => Promise<void>;
|
||||
shippingSuggestedPrompt: ComputedRef<string>;
|
||||
@@ -201,6 +203,11 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
ctx.msg.warning(ctx.t('chat.shippingNoticeParseFailedHint'));
|
||||
return true;
|
||||
}
|
||||
if (ctx.hasBlockingNoticeDuplicates?.()) {
|
||||
ctx.openShippingDuplicateDialog?.();
|
||||
ctx.msg.warning(ctx.t('chat.shippingNoticeDuplicateNeedsResolution'));
|
||||
return true;
|
||||
}
|
||||
const intakeNos = ctx.getParsedIntakeNos?.() || [];
|
||||
if (intakeNos.length && (!trimmed || ctx.shippingAutoFlowRequested.value)) {
|
||||
ctx.shippingAutoFlowRequested.value = false;
|
||||
|
||||
@@ -1,23 +1,31 @@
|
||||
/**
|
||||
* features/chat/shipping/useShippingNoticeIntakes.ts
|
||||
* 用途:发货通知选择即上传、创建 intake 与批量状态轮询编排。
|
||||
* 依赖:file-assets.api、shipping.api、shipping.types。
|
||||
* 逻辑:useChatShipping / useChatAttachments 在货代 Agent 下委托本 composable 管理预解析附件。
|
||||
* 依赖:file-assets.api、shipping.api、shipping.types、shippingNoticeAttachmentIntegrity。
|
||||
* 逻辑:useChatShipping / useChatAttachments 在货代 Agent 下委托本 composable 管理预解析附件;
|
||||
* 完整性判定委托 shippingNoticeAttachmentIntegrity(与后端契约对齐)。
|
||||
*/
|
||||
import { computed, onBeforeUnmount, ref, type Ref } from 'vue';
|
||||
import { uploadFileAsset } from '@/shared/api/file-assets.api';
|
||||
import type {
|
||||
PendingAttachment,
|
||||
ShippingDuplicateAction,
|
||||
ShippingDuplicateResult,
|
||||
ShippingNoticeParseSummary,
|
||||
ShippingNoticePendingAttachment,
|
||||
} from '../types/shipping.types';
|
||||
import type { ShippingNoticeIntakeResponse } from '../types/shipping.api.types';
|
||||
import {
|
||||
cancelShippingNoticeIntake,
|
||||
createShippingNoticeIntake,
|
||||
getShippingNoticeIntakeStatuses,
|
||||
listActiveShippingNoticeIntakes,
|
||||
resolveShippingNoticeDuplicate,
|
||||
retryShippingNoticeIntake,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
import type {
|
||||
PendingAttachment,
|
||||
ShippingNoticeParseSummary,
|
||||
ShippingNoticePendingAttachment,
|
||||
} from '../types/shipping.types';
|
||||
import { isShippingNoticeAttachmentParseIncomplete } from './shippingNoticeAttachmentIntegrity';
|
||||
|
||||
export { isShippingNoticeAttachmentParseIncomplete } from './shippingNoticeAttachmentIntegrity';
|
||||
|
||||
const TERMINAL_PARSE = new Set(['parsed', 'failed', 'parse_failed', 'consumed', 'cancelled', 'expired']);
|
||||
const ACTIVE_PARSE = new Set(['waiting', 'queued', 'parsing', 'created']);
|
||||
@@ -34,6 +42,46 @@ function mapServerParseStatus(status: string): ShippingNoticePendingAttachment['
|
||||
return 'waiting';
|
||||
}
|
||||
|
||||
/**
|
||||
* 将服务端 duplicate 结果映射为前端附件状态。
|
||||
*/
|
||||
function mapServerDuplicate(remote: ShippingNoticeIntakeResponse): {
|
||||
duplicate?: ShippingDuplicateResult;
|
||||
duplicateResolution?: ShippingNoticePendingAttachment['duplicateResolution'];
|
||||
} {
|
||||
const dup = remote.duplicate;
|
||||
if (!dup) return {};
|
||||
const duplicate: ShippingDuplicateResult = {
|
||||
status: dup.status,
|
||||
blocking: Boolean(dup.blocking),
|
||||
fingerprintStrength: dup.fingerprint_strength,
|
||||
matches: (dup.matches || []).map((item) => ({
|
||||
taskNo: item.task_no,
|
||||
processStatus: item.process_status,
|
||||
documentVersion: Number(item.document_version || 1),
|
||||
matchType: item.match_type,
|
||||
matchedFields: listSafe(item.matched_fields),
|
||||
createdAt: item.created_at,
|
||||
})),
|
||||
allowedActions: (dup.allowed_actions || []) as ShippingDuplicateAction[],
|
||||
};
|
||||
const resolution = remote.duplicate_resolution;
|
||||
return {
|
||||
duplicate,
|
||||
duplicateResolution: resolution
|
||||
? {
|
||||
action: resolution.action,
|
||||
targetTaskNo: resolution.target_task_no || undefined,
|
||||
reason: resolution.reason || undefined,
|
||||
}
|
||||
: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
function listSafe(value: unknown): string[] {
|
||||
return Array.isArray(value) ? value.map((item) => String(item)) : [];
|
||||
}
|
||||
|
||||
function createPendingAttachment(file: File): ShippingNoticePendingAttachment {
|
||||
return {
|
||||
id: `${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,
|
||||
@@ -76,12 +124,30 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
|
||||
);
|
||||
|
||||
const hasParseFailures = computed(() =>
|
||||
noticeAttachments.value.some((item) => item.parseStatus === 'failed'),
|
||||
noticeAttachments.value.some(
|
||||
(item) =>
|
||||
item.parseStatus === 'failed'
|
||||
|| isShippingNoticeAttachmentParseIncomplete(item.parseSummary),
|
||||
),
|
||||
);
|
||||
|
||||
const allParsedReady = computed(() =>
|
||||
noticeAttachments.value.length > 0
|
||||
&& noticeAttachments.value.every((item) => item.parseStatus === 'parsed'),
|
||||
&& noticeAttachments.value.every(
|
||||
(item) =>
|
||||
item.parseStatus === 'parsed'
|
||||
&& !isShippingNoticeAttachmentParseIncomplete(item.parseSummary),
|
||||
),
|
||||
);
|
||||
|
||||
const hasBlockingDuplicates = computed(() =>
|
||||
noticeAttachments.value.some(
|
||||
(item) => item.duplicate?.blocking && !item.duplicateResolution?.action,
|
||||
),
|
||||
);
|
||||
|
||||
const allReadyForConfirmation = computed(() =>
|
||||
allParsedReady.value && !hasBlockingDuplicates.value && !hasParseFailures.value,
|
||||
);
|
||||
|
||||
const stopPolling = () => {
|
||||
@@ -137,6 +203,7 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
|
||||
errorMessage: remote.error_message || undefined,
|
||||
expiresAt: remote.expires_at || undefined,
|
||||
assetNo: remote.asset_no || local.assetNo,
|
||||
...mapServerDuplicate(remote),
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -218,7 +285,12 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
|
||||
|
||||
const getParsedIntakeNos = () =>
|
||||
noticeAttachments.value
|
||||
.filter((item) => item.parseStatus === 'parsed' && item.intakeNo)
|
||||
.filter(
|
||||
(item) =>
|
||||
item.parseStatus === 'parsed'
|
||||
&& item.intakeNo
|
||||
&& !isShippingNoticeAttachmentParseIncomplete(item.parseSummary),
|
||||
)
|
||||
.map((item) => String(item.intakeNo));
|
||||
|
||||
const clearConsumedAttachments = () => {
|
||||
@@ -233,11 +305,11 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
|
||||
.filter((item) => item.parse_status !== 'consumed')
|
||||
.map((item) => ({
|
||||
id: `restored_${item.intake_no}`,
|
||||
kind: 'shipping_notice',
|
||||
type: 'document',
|
||||
kind: 'shipping_notice' as const,
|
||||
type: 'document' as const,
|
||||
assetNo: item.asset_no || undefined,
|
||||
intakeNo: item.intake_no,
|
||||
uploadStatus: 'uploaded',
|
||||
uploadStatus: 'uploaded' as const,
|
||||
parseStatus: mapServerParseStatus(item.parse_status),
|
||||
uploadProgress: 100,
|
||||
originalFilename: item.original_filename || item.intake_no,
|
||||
@@ -246,6 +318,7 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
|
||||
errorCode: item.error_code || undefined,
|
||||
errorMessage: item.error_message || undefined,
|
||||
expiresAt: item.expires_at || undefined,
|
||||
...mapServerDuplicate(item),
|
||||
}));
|
||||
const nonNotice = options.attachments.value.filter((item) => item.kind !== 'shipping_notice');
|
||||
options.attachments.value = [...nonNotice, ...restored];
|
||||
@@ -254,6 +327,26 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
|
||||
}
|
||||
};
|
||||
|
||||
const resolveDuplicateAttachment = async (
|
||||
id: string,
|
||||
action: ShippingDuplicateAction,
|
||||
targetTaskNo?: string,
|
||||
reason?: string,
|
||||
) => {
|
||||
const target = noticeAttachments.value.find((item) => item.id === id);
|
||||
if (!target?.intakeNo) return;
|
||||
const intake = await resolveShippingNoticeDuplicate(
|
||||
target.intakeNo,
|
||||
action,
|
||||
targetTaskNo,
|
||||
reason,
|
||||
);
|
||||
patchAttachment(target.id, {
|
||||
parseStatus: mapServerParseStatus(intake.parse_status),
|
||||
...mapServerDuplicate(intake),
|
||||
});
|
||||
};
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
stopPolling();
|
||||
});
|
||||
@@ -263,9 +356,12 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
|
||||
hasBlockingUploadOrParse,
|
||||
hasParseFailures,
|
||||
allParsedReady,
|
||||
hasBlockingDuplicates,
|
||||
allReadyForConfirmation,
|
||||
enqueueNoticeFiles,
|
||||
removeNoticeAttachment,
|
||||
retryNoticeAttachment,
|
||||
resolveDuplicateAttachment,
|
||||
getParsedIntakeNos,
|
||||
clearConsumedAttachments,
|
||||
restoreForConversation,
|
||||
|
||||
@@ -103,6 +103,15 @@ export interface ShippingTaskSummary {
|
||||
created_at?: string | null;
|
||||
updated_at?: string | null;
|
||||
ui_state?: ShippingTaskUiState;
|
||||
/** 业务版本号;修订建单时递增 */
|
||||
document_version?: number;
|
||||
supersedes_task_no?: string | null;
|
||||
superseded_by_task_no?: string | null;
|
||||
duplicate_source_task_no?: string | null;
|
||||
duplicate_resolution_type?: string | null;
|
||||
duplicate_override_reason?: string | null;
|
||||
business_fingerprint?: string | null;
|
||||
fingerprint_version?: string | null;
|
||||
}
|
||||
|
||||
export interface ShippingTaskEvent {
|
||||
@@ -205,6 +214,8 @@ export interface ShippingTaskUiState {
|
||||
title?: string | null;
|
||||
message?: string | null;
|
||||
error_message?: string | null;
|
||||
/** 文件解析阶段汇总的全部待处理问题(库存源 + 解析 warnings 等) */
|
||||
issues?: string[] | null;
|
||||
};
|
||||
action_buttons: ShippingChatAction[];
|
||||
updated_at?: string | null;
|
||||
@@ -310,6 +321,18 @@ export interface ShippingNoticeIntakeResponse {
|
||||
parse_status: string;
|
||||
parser_version?: string;
|
||||
parse_summary?: Record<string, unknown> | null;
|
||||
business_summary?: Record<string, unknown> | null;
|
||||
business_fingerprint?: string | null;
|
||||
fingerprint_strength?: ShippingDuplicateFingerprintStrength | null;
|
||||
fingerprint_version?: string | null;
|
||||
duplicate?: ShippingDuplicateResult | null;
|
||||
duplicate_resolution?: {
|
||||
action: ShippingDuplicateAction;
|
||||
reason?: string | null;
|
||||
resolved_by_id?: number | null;
|
||||
resolved_at?: string | null;
|
||||
target_task_no?: string | null;
|
||||
} | null;
|
||||
warnings?: string[];
|
||||
error_code?: string | null;
|
||||
error_message?: string | null;
|
||||
@@ -322,6 +345,36 @@ export interface ShippingNoticeIntakeResponse {
|
||||
content_hash?: string;
|
||||
}
|
||||
|
||||
export type ShippingDuplicateStatus =
|
||||
| 'unchecked'
|
||||
| 'none'
|
||||
| 'exact_file'
|
||||
| 'same_active_task'
|
||||
| 'same_completed_task'
|
||||
| 'possible_duplicate';
|
||||
|
||||
export type ShippingDuplicateAction = 'open_existing' | 'create_revision' | 'force_create';
|
||||
|
||||
export type ShippingDuplicateFingerprintStrength = 'strong' | 'medium' | 'weak' | 'unavailable';
|
||||
|
||||
export interface ShippingDuplicateMatch {
|
||||
task_no: string;
|
||||
process_status: string;
|
||||
document_version: number;
|
||||
match_type: string;
|
||||
matched_fields: string[];
|
||||
lifecycle?: string;
|
||||
created_at?: string;
|
||||
}
|
||||
|
||||
export interface ShippingDuplicateResult {
|
||||
status: ShippingDuplicateStatus;
|
||||
blocking: boolean;
|
||||
fingerprint_strength: ShippingDuplicateFingerprintStrength;
|
||||
matches: ShippingDuplicateMatch[];
|
||||
allowed_actions: ShippingDuplicateAction[];
|
||||
}
|
||||
|
||||
export interface ShippingCreateBatchFromIntakesResponse extends ShippingNoticeUploadResponse {}
|
||||
|
||||
export interface ShippingDecisionResponse {
|
||||
|
||||
@@ -22,6 +22,69 @@ export type ShippingNoticeParseStatus =
|
||||
| 'cancelled'
|
||||
| 'expired';
|
||||
|
||||
export type ShippingDuplicateAction = 'open_existing' | 'create_revision' | 'force_create';
|
||||
|
||||
export type ShippingDuplicateFingerprintStrength = 'strong' | 'medium' | 'weak' | 'unavailable';
|
||||
|
||||
export type ShippingDuplicateStatus =
|
||||
| 'unchecked'
|
||||
| 'none'
|
||||
| 'exact_file'
|
||||
| 'same_active_task'
|
||||
| 'same_completed_task'
|
||||
| 'possible_duplicate';
|
||||
|
||||
export interface ShippingDuplicateMatch {
|
||||
taskNo: string;
|
||||
processStatus: string;
|
||||
documentVersion: number;
|
||||
matchType: string;
|
||||
matchedFields: string[];
|
||||
createdAt?: string;
|
||||
}
|
||||
|
||||
export interface ShippingDuplicateResult {
|
||||
status: ShippingDuplicateStatus;
|
||||
blocking: boolean;
|
||||
fingerprintStrength: ShippingDuplicateFingerprintStrength;
|
||||
matches: ShippingDuplicateMatch[];
|
||||
allowedActions: ShippingDuplicateAction[];
|
||||
}
|
||||
|
||||
export interface ShippingDuplicateResolution {
|
||||
action: ShippingDuplicateAction;
|
||||
targetTaskNo?: string;
|
||||
reason?: string;
|
||||
}
|
||||
|
||||
export interface ShippingNoticeParseAttachmentSummary {
|
||||
attachment_key?: string;
|
||||
filename?: string;
|
||||
mime_type?: string;
|
||||
size?: number;
|
||||
content_hash?: string;
|
||||
parse_status?: string;
|
||||
/** 详情接口才有;状态轮询为瘦身摘要不含全文 */
|
||||
extracted_text?: string;
|
||||
/** 原始解析文本长度 */
|
||||
text_length?: number;
|
||||
/** 落库/截断后长度 */
|
||||
stored_text_length?: number;
|
||||
warnings?: string[];
|
||||
}
|
||||
|
||||
export interface ShippingNoticeParseEmailMeta {
|
||||
message_id?: string;
|
||||
subject?: string;
|
||||
from?: string;
|
||||
to?: string;
|
||||
date?: string;
|
||||
/** 详情接口才有完整正文;状态轮询通常省略 */
|
||||
body_text?: string;
|
||||
body_text_length?: number;
|
||||
stored_body_text_length?: number;
|
||||
}
|
||||
|
||||
export interface ShippingNoticeParseSummary {
|
||||
filename?: string;
|
||||
source_type?: string;
|
||||
@@ -29,6 +92,12 @@ export interface ShippingNoticeParseSummary {
|
||||
line_count?: number;
|
||||
warnings?: string[];
|
||||
parser_version?: string;
|
||||
email?: ShippingNoticeParseEmailMeta;
|
||||
/** 发现的真实附件总数(含因上限未登记的) */
|
||||
attachment_count?: number;
|
||||
/** 实际登记到 attachments[] 的数量 */
|
||||
attachment_registered_count?: number;
|
||||
attachments?: ShippingNoticeParseAttachmentSummary[];
|
||||
}
|
||||
|
||||
export type ShippingNoticePendingAttachment = {
|
||||
@@ -47,6 +116,8 @@ export type ShippingNoticePendingAttachment = {
|
||||
errorCode?: string;
|
||||
errorMessage?: string;
|
||||
expiresAt?: string;
|
||||
duplicate?: ShippingDuplicateResult;
|
||||
duplicateResolution?: ShippingDuplicateResolution;
|
||||
};
|
||||
|
||||
/** 待发送附件(本地文件、远程 URL 或货代通知预解析) */
|
||||
|
||||
Reference in new issue
Block a user