feat(shipping-notice): 新增货代客户管理功能,支持客户导入、识别证据管理与客户确认

This commit is contained in:
hugo committed 2026-07-16 08:16:19 +08:00
1 parent b595e157e9
commit 4fbaed2b4c
176 files changed
+14011 -994

No files matched your search

@@ -1,7 +1,8 @@
/**
* features/chat/components/ChatInputBar.vue
* 聊天输入栏:文本框、附件、语音、知识库选择与发送按钮。
* 逻辑:设备维保助手的管理入口(设备台账、登记维修)与语音按钮同侧排列,发送按钮独占右侧。
* 用途:承载聊天文本输入、附件预览、语音、知识库选择与发送操作。
* 依赖:lucide 图标、ShippingNoticeCandidateReview、附件完整性判断工具。
* 逻辑:附件卡片位于文本框上方;发货通知保留解析/重复处理能力,普通附件展示逐文件上传状态。
*/
<script setup lang="ts">
import { nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
@@ -10,7 +11,13 @@ import type { Ref } from 'vue';
import {
Check,
ChevronDown,
CircleAlert,
CircleCheck,
Database,
FileAudio,
FileImage,
FileText,
FileVideo,
Link2,
Loader2,
Mic,
@@ -26,6 +33,13 @@ import {
isBlockingWarning,
isShippingNoticeAttachmentParseIncomplete,
} from '../shipping/shippingNoticeAttachmentIntegrity';
import {
getAttachmentCardStatus,
getAttachmentExtension,
getAttachmentName,
getAttachmentSize,
isAttachmentRemoveDisabled,
} from '../utils/attachmentCard.utils';
export interface ChatInputAttachmentPolicy {
anyEnabled: boolean;
@@ -156,6 +170,15 @@ function shippingNoticeAttachmentTitle(attachment: ShippingNoticePendingAttachme
return lines.join('\n');
}
/** 根据附件业务类型选择文件图标,帮助用户快速区分媒体与文档。 */
function attachmentIcon(attachment: PendingAttachment) {
if (attachment.kind === 'remote') return Link2;
if (attachment.type === 'image') return FileImage;
if (attachment.type === 'audio') return FileAudio;
if (attachment.type === 'video') return FileVideo;
return FileText;
}
const closeAttachmentMenu = () => {
showAttachmentMenu.value = false;
showAttachmentUrlPanel.value = false;
@@ -293,6 +316,92 @@ watch(
@resolve-duplicate="(candidateNo, action, targetTaskNo, reason, done) => emit('resolve-shipping-candidate-duplicate', candidateNo, action, targetTaskNo, reason, done)"
/>
</div>
<div
v-if="attachments.length > 0"
data-testid="chat-attachment-list"
class="flex flex-wrap gap-2 px-2.5 pb-2 pt-1"
>
<article
v-for="a in attachments"
:key="a.id"
class="group relative flex min-w-0 basis-full items-center gap-3 rounded-xl border border-default bg-surface-soft px-3 py-2.5 transition-colors sm:basis-[calc(50%-0.25rem)] lg:max-w-[310px]"
:title="a.kind === 'shipping_notice' ? shippingNoticeAttachmentTitle(a) : getAttachmentName(a)"
>
<div
class="flex h-11 w-10 shrink-0 flex-col items-center justify-center rounded-lg bg-brand-50 text-brand-700 dark:bg-brand-900/30 dark:text-brand-300"
aria-hidden="true"
>
<component :is="attachmentIcon(a)" class="h-4.5 w-4.5" />
<span class="mt-0.5 max-w-9 truncate text-[9px] font-bold leading-none">{{ getAttachmentExtension(a) }}</span>
</div>
<div class="min-w-0 flex-1 pr-5">
<p class="truncate text-sm font-medium text-primary">{{ getAttachmentName(a) }}</p>
<div class="mt-1 flex min-w-0 items-center gap-1.5 text-[11px] leading-none">
<span v-if="getAttachmentSize(a)" class="shrink-0 text-muted">{{ getAttachmentSize(a) }}</span>
<span v-if="getAttachmentSize(a)" class="text-slate-300">·</span>
<span
class="flex min-w-0 items-center gap-1 truncate"
:class="{
'text-muted': getAttachmentCardStatus(a).state === 'pending',
'text-brand-600': ['uploading', 'processing'].includes(getAttachmentCardStatus(a).state),
'text-amber-700': getAttachmentCardStatus(a).state === 'attention',
'text-emerald-600': getAttachmentCardStatus(a).state === 'ready',
'text-red-500': getAttachmentCardStatus(a).state === 'failed',
}"
>
<Loader2
v-if="['uploading', 'processing'].includes(getAttachmentCardStatus(a).state)"
class="h-3 w-3 shrink-0 animate-spin"
/>
<CircleCheck v-else-if="getAttachmentCardStatus(a).state === 'ready'" class="h-3 w-3 shrink-0" />
<CircleAlert v-else-if="['attention', 'failed'].includes(getAttachmentCardStatus(a).state)" class="h-3 w-3 shrink-0" />
<span class="truncate">{{ t(getAttachmentCardStatus(a).labelKey) }}</span>
<template v-if="a.kind === 'shipping_notice' && shippingNoticeAttachmentHint(a)">
<span class="truncate">· {{ shippingNoticeAttachmentHint(a) }}</span>
</template>
</span>
</div>
</div>
<div
v-if="a.kind === 'shipping_notice' && (canRetryShippingNoticeParse(a) || (!a.candidates?.length && a.duplicate?.blocking && !a.duplicateResolution?.action))"
class="absolute bottom-1.5 right-2 flex items-center gap-1"
>
<button
v-if="!a.candidates?.length && a.duplicate?.blocking && !a.duplicateResolution?.action"
type="button"
class="rounded px-1.5 py-1 text-[10px] font-medium text-amber-700 hover:bg-amber-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-400"
:title="t('chat.shippingNoticeDuplicateHandle')"
@click="emit('resolve-shipping-notice-duplicate', a.id)"
>
{{ t('chat.shippingNoticeDuplicateHandle') }}
</button>
<button
v-if="canRetryShippingNoticeParse(a)"
type="button"
class="rounded p-1 text-muted hover:bg-surface hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-400"
:title="t('chat.shippingNoticeRetryParse')"
@click="emit('retry-shipping-notice-attachment', a.id)"
>
<RefreshCw class="h-3.5 w-3.5" />
</button>
</div>
<button
type="button"
class="absolute right-1.5 top-1.5 flex h-6 w-6 items-center justify-center rounded-full text-muted opacity-80 transition hover:bg-surface hover:text-red-500 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-400 disabled:cursor-not-allowed disabled:opacity-30"
:disabled="isAttachmentRemoveDisabled(a)"
:title="t('chat.attachment.remove')"
:aria-label="t('chat.attachment.removeNamed', { name: getAttachmentName(a) })"
@click="emit('remove-attachment', a.id)"
>
<X class="h-3.5 w-3.5" />
</button>
</article>
</div>
<textarea
ref="textareaRef"
v-model="inputValue"
@@ -324,77 +433,6 @@ watch(
@change="emit('local-files-selected', $event)"
/>
<div v-if="attachments.length > 0" class="flex flex-wrap gap-2 px-3 pb-1">
<div
v-for="a in attachments"
:key="a.id"
class="flex items-center gap-2 rounded-lg border border-default bg-surface-soft px-2 py-1 text-xs text-secondary"
>
<span class="max-w-[220px] truncate">
<template v-if="a.kind === 'shipping_notice'">
{{ 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' && !a.candidates?.length && 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.candidates?.length && 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>
{{ a.kind === 'local' ? a.file.name : a.url }}
</template>
</span>
<button
v-if="a.kind === 'shipping_notice' && !a.candidates?.length && 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')"
@click="emit('retry-shipping-notice-attachment', a.id)"
>
<RefreshCw class="h-3.5 w-3.5" />
</button>
<button type="button" class="text-muted hover:text-red-500" @click="emit('remove-attachment', a.id)">
<X class="h-3.5 w-3.5" />
</button>
</div>
</div>
<div
v-if="isShippingNoticeAgent && attachments.length > 0"
class="flex flex-wrap items-center gap-2 px-3 pb-1 text-xs text-muted"