feat(shipping, admin, workspace, docs): 迭代货代模块、补充文档并处理合并冲突问题
This commit is contained in:
1 parent
4587b56900
commit
3c0e08377c
94 files changed
+29222
-1218
No files matched your search
@@ -3,6 +3,7 @@
|
||||
* 用途:承载聊天文本输入、附件预览、语音、知识库选择与发送操作。
|
||||
* 依赖:lucide 图标、附件完整性判断工具。
|
||||
* 逻辑:附件卡片位于文本框上方;订单审核结果随对应聊天消息展示,输入区只保留附件处理状态。
|
||||
* 同时支持采购合同双文件输入控件:底部左区放附件/合同等工具,右区语音与发送并排;采购合同审查用专用上传按钮,不展示通用回形针附件入口。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
@@ -10,10 +11,8 @@ import { useI18n } from 'vue-i18n';
|
||||
import type { Ref } from 'vue';
|
||||
import {
|
||||
Check,
|
||||
ChevronDown,
|
||||
CircleAlert,
|
||||
CircleCheck,
|
||||
Database,
|
||||
FileAudio,
|
||||
FileImage,
|
||||
FileText,
|
||||
@@ -25,8 +24,10 @@ import {
|
||||
RefreshCw,
|
||||
Send,
|
||||
Square,
|
||||
Upload,
|
||||
X,
|
||||
} from 'lucide-vue-next';
|
||||
import type { ContractReviewMode } from '../composables/useProcurementContractChat';
|
||||
import type { PendingAttachment, ShippingNoticePendingAttachment } from '../types/shipping.types';
|
||||
import {
|
||||
isBlockingWarning,
|
||||
@@ -48,19 +49,19 @@ export interface ChatInputAttachmentPolicy {
|
||||
}
|
||||
|
||||
const inputValue = defineModel<string>({ required: true });
|
||||
const selectedKb = defineModel<string>('selectedKb', { required: true });
|
||||
const procurementReviewMode = defineModel<ContractReviewMode>('procurementReviewMode', { default: 'compare' });
|
||||
|
||||
const props = defineProps<{
|
||||
attachments: PendingAttachment[];
|
||||
attachmentPolicy: ChatInputAttachmentPolicy;
|
||||
availableKbOptions: string[];
|
||||
kbDropdownDisabled: boolean;
|
||||
isThinking: boolean;
|
||||
isVoiceRecording: boolean;
|
||||
isVoiceTranscribing: boolean;
|
||||
isUploadingAttachments: boolean;
|
||||
canSendMessage: boolean;
|
||||
isShippingNoticeAgent: boolean;
|
||||
isProcurementContractAgent?: boolean;
|
||||
procurementOriginalContractName?: string | null;
|
||||
isMaintenanceAgent?: boolean;
|
||||
canManageMaintenance?: boolean;
|
||||
canForceCreateShippingDuplicate?: boolean;
|
||||
@@ -70,7 +71,6 @@ const props = defineProps<{
|
||||
/** 用对象包裹 Ref,避免 template 自动解包 */
|
||||
shippingPickerRefHolder: { pickerRef: Ref<HTMLInputElement | null> };
|
||||
shippingNoticePickerRefHolder: { pickerRef: Ref<HTMLInputElement | null> };
|
||||
getKbLabel: (kb: string) => string;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -90,17 +90,18 @@ const emit = defineEmits<{
|
||||
'maintenance-ledger-config': [];
|
||||
'maintenance-create-record': [];
|
||||
'clear-shipping-focus': [];
|
||||
'procurement-original-contract-selected': [event: Event];
|
||||
'clear-procurement-original-contract': [];
|
||||
}>();
|
||||
|
||||
const filePickerRef = ref<HTMLInputElement | null>(null);
|
||||
const originalContractPickerRef = ref<HTMLInputElement | null>(null);
|
||||
const { t } = useI18n();
|
||||
const textareaRef = ref<HTMLTextAreaElement | null>(null);
|
||||
const attachmentMenuRef = ref<HTMLElement | null>(null);
|
||||
const kbMenuRef = ref<HTMLElement | null>(null);
|
||||
const attachmentUrlInputRef = ref<HTMLInputElement | null>(null);
|
||||
const showAttachmentMenu = ref(false);
|
||||
const showAttachmentUrlPanel = ref(false);
|
||||
const showKbDropdown = ref(false);
|
||||
const attachmentUrlInput = ref('');
|
||||
|
||||
/** 当前发货通知是否仍在上传或预解析,决定输入框下方的操作提示。 */
|
||||
@@ -113,6 +114,35 @@ const hasShippingNoticeInProgress = computed(() => props.attachments.some(
|
||||
),
|
||||
));
|
||||
|
||||
const hasProcurementContractAttachment = computed(() =>
|
||||
Boolean(props.isProcurementContractAgent)
|
||||
&& props.attachments.some((item) => item.kind === 'local'),
|
||||
);
|
||||
|
||||
const procurementQuickActions = computed(() => {
|
||||
const actions = [
|
||||
{
|
||||
label: 'chat.procurementContract.quickReview',
|
||||
prompt: 'chat.procurementContract.promptReview',
|
||||
},
|
||||
{
|
||||
label: 'chat.procurementContract.quickRisk',
|
||||
prompt: 'chat.procurementContract.promptRisk',
|
||||
},
|
||||
];
|
||||
if (procurementReviewMode.value === 'compare') {
|
||||
actions.push({
|
||||
label: 'chat.procurementContract.quickDiff',
|
||||
prompt: 'chat.procurementContract.promptDiff',
|
||||
});
|
||||
}
|
||||
actions.push({
|
||||
label: 'chat.procurementContract.quickSuggestion',
|
||||
prompt: 'chat.procurementContract.promptSuggestion',
|
||||
});
|
||||
return actions;
|
||||
});
|
||||
|
||||
/**
|
||||
* 汇总 EML 附件解析进度,供输入栏徽标展示。
|
||||
* 核心逻辑:阶段 1 仅展示快览结果;优先说明发现了多少附件,技术失败/目录不完整再退化为问题提示。
|
||||
@@ -232,6 +262,15 @@ const selectAttachmentLocal = () => {
|
||||
filePickerRef.value?.click();
|
||||
};
|
||||
|
||||
/**
|
||||
* 采购合同 Agent 的主上传入口:比对模式选择卖方回传合同,单份模式选择待审合同。
|
||||
*/
|
||||
const selectProcurementContractLocal = () => {
|
||||
if (!props.attachmentPolicy.canLocal || props.isThinking || props.isUploadingAttachments) return;
|
||||
closeAttachmentMenu();
|
||||
filePickerRef.value?.click();
|
||||
};
|
||||
|
||||
const selectAttachmentUrl = async () => {
|
||||
if (!props.attachmentPolicy.canRemote) return;
|
||||
showAttachmentMenu.value = true;
|
||||
@@ -240,20 +279,6 @@ const selectAttachmentUrl = async () => {
|
||||
attachmentUrlInputRef.value?.focus();
|
||||
};
|
||||
|
||||
const toggleKbDropdown = () => {
|
||||
if (props.kbDropdownDisabled) {
|
||||
showKbDropdown.value = false;
|
||||
return;
|
||||
}
|
||||
showKbDropdown.value = !showKbDropdown.value;
|
||||
};
|
||||
|
||||
const selectKb = (option: string) => {
|
||||
if (!props.availableKbOptions.includes(option)) return;
|
||||
selectedKb.value = option;
|
||||
showKbDropdown.value = false;
|
||||
};
|
||||
|
||||
const submitRemoteUrl = () => {
|
||||
const raw = attachmentUrlInput.value.trim();
|
||||
if (!raw) return;
|
||||
@@ -261,6 +286,16 @@ const submitRemoteUrl = () => {
|
||||
closeAttachmentMenu();
|
||||
};
|
||||
|
||||
/**
|
||||
* 上传合同后的快捷审查动作:写入审查方案并立即发送。
|
||||
*/
|
||||
const runProcurementQuickAction = async (promptKey: string) => {
|
||||
if (!hasProcurementContractAttachment.value || props.isThinking || props.isUploadingAttachments) return;
|
||||
inputValue.value = t(promptKey);
|
||||
await nextTick();
|
||||
emit('send');
|
||||
};
|
||||
|
||||
const bindShippingPickerRef = (el: unknown) => {
|
||||
props.shippingPickerRefHolder.pickerRef.value = (el as HTMLInputElement | null) ?? null;
|
||||
};
|
||||
@@ -274,12 +309,12 @@ const bindAttachmentPickerRef = (el: unknown) => {
|
||||
bindShippingNoticePickerRef(el);
|
||||
};
|
||||
|
||||
/**
|
||||
* 点击输入栏外部时收起附件菜单。
|
||||
*/
|
||||
const handleDocumentPointerDown = (event: MouseEvent | TouchEvent) => {
|
||||
const target = event.target as Node | null;
|
||||
if (!target) return;
|
||||
if (showKbDropdown.value && kbMenuRef.value && !kbMenuRef.value.contains(target)) {
|
||||
showKbDropdown.value = false;
|
||||
}
|
||||
if (showAttachmentMenu.value && attachmentMenuRef.value && !attachmentMenuRef.value.contains(target)) {
|
||||
closeAttachmentMenu();
|
||||
}
|
||||
@@ -319,6 +354,47 @@ watch(
|
||||
<template>
|
||||
<footer class="safe-bottom z-20 shrink-0 bg-transparent p-2 md:p-3">
|
||||
<div class="relative mx-auto max-w-4xl">
|
||||
<div
|
||||
v-if="isProcurementContractAgent"
|
||||
class="mb-2 flex flex-wrap items-center gap-2"
|
||||
>
|
||||
<div
|
||||
class="inline-flex items-center gap-1 rounded-full border border-[#d8e0ec] bg-[#eef2f7] p-[3px]"
|
||||
role="tablist"
|
||||
:aria-label="$t('chat.procurementContract.mode')"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
class="rounded-full px-3 py-1.5 text-xs font-bold transition-all"
|
||||
:class="procurementReviewMode === 'compare'
|
||||
? 'bg-white text-[#2f80d1] shadow-[0_1px_4px_rgba(23,32,51,0.08)]'
|
||||
: 'bg-transparent text-[#667792] hover:text-[#172033]'"
|
||||
:aria-selected="procurementReviewMode === 'compare'"
|
||||
@click="procurementReviewMode = 'compare'"
|
||||
>
|
||||
{{ $t('chat.procurementContract.modeCompare') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
class="rounded-full px-3 py-1.5 text-xs font-bold transition-all"
|
||||
:class="procurementReviewMode === 'solo'
|
||||
? 'bg-white text-[#2f80d1] shadow-[0_1px_4px_rgba(23,32,51,0.08)]'
|
||||
: 'bg-transparent text-[#667792] hover:text-[#172033]'"
|
||||
:aria-selected="procurementReviewMode === 'solo'"
|
||||
@click="procurementReviewMode = 'solo'"
|
||||
>
|
||||
{{ $t('chat.procurementContract.modeSolo') }}
|
||||
</button>
|
||||
</div>
|
||||
<span class="text-xs text-[#667792]">
|
||||
{{ $t(procurementReviewMode === 'compare'
|
||||
? 'chat.procurementContract.compareHint'
|
||||
: 'chat.procurementContract.soloHint') }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col rounded-2xl bg-surface p-1.5 shadow-[0_0_15px_rgba(0,0,0,0.05)] transition-all">
|
||||
<div
|
||||
v-if="isShippingNoticeAgent && shippingFocusTaskNo"
|
||||
@@ -345,7 +421,10 @@ watch(
|
||||
<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]"
|
||||
class="group relative flex min-w-0 basis-full items-center gap-3 rounded-xl px-3 py-2.5 transition-colors sm:basis-[calc(50%-0.25rem)] lg:max-w-[310px]"
|
||||
:class="isProcurementContractAgent && a.kind === 'local'
|
||||
? 'border border-[#9cc7f2] bg-[#eef6ff]'
|
||||
: 'border border-default bg-surface-soft'"
|
||||
:title="a.kind === 'shipping_notice' ? shippingNoticeAttachmentTitle(a) : getAttachmentName(a)"
|
||||
>
|
||||
<div
|
||||
@@ -357,7 +436,14 @@ watch(
|
||||
</div>
|
||||
|
||||
<div class="min-w-0 flex-1 pr-5">
|
||||
<p class="truncate text-sm font-medium text-primary">{{ getAttachmentName(a) }}</p>
|
||||
<p class="truncate text-sm font-medium text-primary">
|
||||
<span v-if="isProcurementContractAgent" class="mr-1 text-[#2f80d1]">
|
||||
{{ $t(procurementReviewMode === 'compare'
|
||||
? 'chat.procurementContract.sellerReturnedContractLabel'
|
||||
: 'chat.procurementContract.contractToReviewLabel') }}:
|
||||
</span>
|
||||
{{ 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>
|
||||
@@ -438,20 +524,6 @@ watch(
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<textarea
|
||||
ref="textareaRef"
|
||||
v-model="inputValue"
|
||||
rows="1"
|
||||
:placeholder="isVoiceTranscribing ? $t('chat.voiceTranscribing') : isVoiceRecording ? $t('chat.voiceListening') : shippingFocusTaskNo ? $t('chat.shippingNoticeUi.focusInputPlaceholder', { taskId: shippingFocusTaskNo }) : isMaintenanceAgent ? $t('maintenance.chat.inputPlaceholder') : $t('chat.askAnything')"
|
||||
class="w-full resize-none border-none bg-transparent px-2.5 py-1.5 text-[15px] leading-relaxed text-primary placeholder-slate-400 focus:border-transparent focus:outline-none focus:ring-0"
|
||||
style="min-height: 40px; max-height: 220px;"
|
||||
:disabled="isVoiceTranscribing"
|
||||
spellcheck="false"
|
||||
autocorrect="off"
|
||||
autocapitalize="off"
|
||||
@keydown.enter.prevent="emit('send')"
|
||||
/>
|
||||
|
||||
<input
|
||||
:ref="bindShippingPickerRef"
|
||||
type="file"
|
||||
@@ -469,32 +541,82 @@ watch(
|
||||
@change="emit('local-files-selected', $event)"
|
||||
/>
|
||||
|
||||
<input
|
||||
ref="originalContractPickerRef"
|
||||
type="file"
|
||||
class="hidden"
|
||||
accept=".pdf,.doc,.docx,.txt,.md"
|
||||
@change="emit('procurement-original-contract-selected', $event)"
|
||||
/>
|
||||
|
||||
<div
|
||||
v-if="isProcurementContractAgent && procurementReviewMode === 'compare' && procurementOriginalContractName"
|
||||
class="flex flex-wrap gap-2 px-3 pb-1"
|
||||
>
|
||||
<div class="flex items-center gap-2 rounded-lg border border-dashed border-[#8db8e6] bg-[#eef6ff] px-2 py-1 text-xs font-semibold text-[#1f5f99]">
|
||||
<FileText class="h-3.5 w-3.5" />
|
||||
<span class="max-w-[260px] truncate">{{ $t('chat.procurementContract.originalContractChip', { name: procurementOriginalContractName }) }}</span>
|
||||
<button type="button" class="text-[#1f5f99] hover:opacity-80" @click="emit('clear-procurement-original-contract')">
|
||||
<X class="h-3.5 w-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="hasProcurementContractAttachment"
|
||||
class="flex flex-wrap items-center gap-2 px-3 pb-1"
|
||||
>
|
||||
<button
|
||||
v-for="action in procurementQuickActions"
|
||||
:key="action.label"
|
||||
type="button"
|
||||
class="rounded-full border border-[#d8e0ec] bg-white px-3 py-1.5 text-xs font-semibold text-[#31445f] transition-colors hover:border-[#2f80d1] hover:bg-[#eef6ff] hover:text-[#1f5f99] disabled:cursor-not-allowed disabled:opacity-50"
|
||||
:disabled="isThinking || isUploadingAttachments"
|
||||
@click="runProcurementQuickAction(action.prompt)"
|
||||
>
|
||||
{{ $t(action.label) }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
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 || $t('chat.recommendedQuestion') }}
|
||||
</button>
|
||||
<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">
|
||||
<div class="flex items-center gap-3">
|
||||
<button
|
||||
type="button"
|
||||
:disabled="isThinking || isVoiceTranscribing"
|
||||
:title="isVoiceRecording ? $t('chat.voiceStop') : isVoiceTranscribing ? $t('chat.voiceTranscribing') : $t('chat.voiceFeature')"
|
||||
class="transition-colors disabled:cursor-not-allowed disabled:opacity-50"
|
||||
:class="isVoiceRecording ? 'animate-pulse text-red-500' : isVoiceTranscribing ? 'text-brand-500' : 'text-muted hover:text-brand-600'"
|
||||
@click="emit('voice-click')"
|
||||
>
|
||||
<Loader2 v-if="isVoiceTranscribing" class="h-5 w-5 animate-spin" />
|
||||
<Mic v-else class="h-5 w-5" />
|
||||
</button>
|
||||
<textarea
|
||||
ref="textareaRef"
|
||||
v-model="inputValue"
|
||||
rows="1"
|
||||
:placeholder="isVoiceTranscribing ? $t('chat.voiceTranscribing') : isVoiceRecording ? $t('chat.voiceListening') : shippingFocusTaskNo ? $t('chat.shippingNoticeUi.focusInputPlaceholder', { taskId: shippingFocusTaskNo }) : isMaintenanceAgent ? $t('maintenance.chat.inputPlaceholder') : $t('chat.askAnything')"
|
||||
class="w-full resize-none border-none bg-transparent px-2.5 py-1.5 text-[15px] leading-relaxed text-primary placeholder-slate-400 focus:border-transparent focus:outline-none focus:ring-0"
|
||||
style="min-height: 40px; max-height: 220px;"
|
||||
:disabled="isVoiceTranscribing"
|
||||
spellcheck="false"
|
||||
autocorrect="off"
|
||||
autocapitalize="off"
|
||||
@keydown.enter.prevent="emit('send')"
|
||||
/>
|
||||
|
||||
<div v-if="attachmentPolicy.anyEnabled" ref="attachmentMenuRef" class="relative">
|
||||
<div class="mt-1.5 flex items-center justify-between gap-2 px-1.5 pb-0.5">
|
||||
<div class="flex min-w-0 flex-1 flex-wrap items-center gap-2">
|
||||
<div
|
||||
v-if="attachmentPolicy.anyEnabled && !isProcurementContractAgent"
|
||||
ref="attachmentMenuRef"
|
||||
class="relative"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
:disabled="isThinking || isUploadingAttachments"
|
||||
title="附件"
|
||||
:title="$t('chat.attachmentsUi.title')"
|
||||
class="flex h-9 w-9 items-center justify-center rounded-lg text-muted transition-colors hover:text-brand-600 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
@click="toggleAttachmentMenu"
|
||||
>
|
||||
@@ -511,7 +633,7 @@ watch(
|
||||
@click="selectAttachmentLocal"
|
||||
>
|
||||
<Paperclip class="h-4 w-4 text-brand-500" />
|
||||
上传本地文件
|
||||
{{ $t('chat.attachmentsUi.uploadLocal') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="attachmentPolicy.canRemote"
|
||||
@@ -520,7 +642,7 @@ watch(
|
||||
@click="selectAttachmentUrl"
|
||||
>
|
||||
<Link2 class="h-4 w-4 text-brand-500" />
|
||||
粘贴 URL
|
||||
{{ $t('chat.attachmentsUi.pasteUrl') }}
|
||||
</button>
|
||||
<div v-if="showAttachmentUrlPanel" class="px-3 py-2">
|
||||
<div class="flex items-center gap-2">
|
||||
@@ -528,7 +650,7 @@ watch(
|
||||
ref="attachmentUrlInputRef"
|
||||
v-model="attachmentUrlInput"
|
||||
:disabled="isThinking || isUploadingAttachments"
|
||||
placeholder="粘贴附件 URL(http/https)"
|
||||
:placeholder="$t('chat.attachmentsUi.urlPlaceholder')"
|
||||
class="flex-1 rounded-lg border border-default bg-surface-soft px-3 py-2 text-xs text-secondary placeholder-slate-400 focus:outline-none focus:ring-0"
|
||||
@keydown.enter.prevent="submitRemoteUrl"
|
||||
/>
|
||||
@@ -536,7 +658,7 @@ watch(
|
||||
type="button"
|
||||
:disabled="isThinking || isUploadingAttachments"
|
||||
class="flex h-9 w-9 items-center justify-center rounded-lg border border-default text-muted transition-colors hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-50"
|
||||
title="添加"
|
||||
:title="$t('chat.attachmentsUi.add')"
|
||||
@click="submitRemoteUrl"
|
||||
>
|
||||
<Check class="h-4 w-4" />
|
||||
@@ -545,7 +667,7 @@ watch(
|
||||
type="button"
|
||||
:disabled="isThinking || isUploadingAttachments"
|
||||
class="flex h-9 w-9 items-center justify-center rounded-lg border border-default text-muted transition-colors hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-50"
|
||||
title="取消"
|
||||
:title="$t('chat.attachmentsUi.cancel')"
|
||||
@click="closeAttachmentMenu"
|
||||
>
|
||||
<X class="h-4 w-4" />
|
||||
@@ -555,32 +677,44 @@ watch(
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!isMaintenanceAgent" ref="kbMenuRef" class="relative">
|
||||
<div v-if="isProcurementContractAgent && procurementReviewMode === 'compare'" class="flex flex-wrap items-center gap-1.5">
|
||||
<button
|
||||
type="button"
|
||||
:disabled="kbDropdownDisabled"
|
||||
class="flex items-center gap-1 rounded-lg border border-default px-3 py-1.5 text-xs font-medium text-secondary transition-colors hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-60"
|
||||
@click="toggleKbDropdown"
|
||||
class="flex items-center gap-1 rounded-full border border-[#8db8e6] bg-[#f8fbff] px-3 py-1.5 text-xs font-semibold text-[#1f5f99] transition-colors hover:border-[#2f80d1] hover:bg-[#eef6ff] disabled:cursor-not-allowed disabled:opacity-50"
|
||||
:disabled="isThinking || isUploadingAttachments"
|
||||
@click="originalContractPickerRef?.click()"
|
||||
>
|
||||
<Database class="h-3.5 w-3.5 text-brand-500" />
|
||||
{{ getKbLabel(selectedKb) }} <ChevronDown class="h-3 w-3" />
|
||||
<Upload class="h-3.5 w-3.5" />
|
||||
{{ $t('chat.procurementContract.uploadOriginalContract') }}
|
||||
</button>
|
||||
<div
|
||||
v-if="showKbDropdown && !kbDropdownDisabled"
|
||||
class="absolute bottom-full left-0 mb-2 w-36 animate-fade-in overflow-hidden rounded-xl border border-subtle bg-surface py-1 shadow-xl"
|
||||
<button
|
||||
type="button"
|
||||
class="flex items-center gap-1 rounded-full bg-[#2f80d1] px-3 py-1.5 text-xs font-semibold text-white shadow-sm transition-colors hover:bg-[#2369ad] disabled:cursor-not-allowed disabled:opacity-50"
|
||||
:disabled="isThinking || isUploadingAttachments || !attachmentPolicy.canLocal"
|
||||
:title="$t('chat.procurementContract.uploadSellerReturnedContract')"
|
||||
@click="selectProcurementContractLocal"
|
||||
>
|
||||
<button
|
||||
v-for="option in availableKbOptions"
|
||||
:key="option"
|
||||
type="button"
|
||||
class="flex w-full items-center justify-between px-3 py-2 text-xs text-secondary transition-colors hover:bg-surface-soft"
|
||||
:class="{ 'font-bold text-brand-700': selectedKb === option }"
|
||||
@click="selectKb(option)"
|
||||
>
|
||||
{{ getKbLabel(option) }}
|
||||
<Check v-if="selectedKb === option" class="h-3.5 w-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
<Upload class="h-3.5 w-3.5" />
|
||||
{{ $t('chat.procurementContract.uploadSellerReturnedContract') }}
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="isProcurementContractAgent"
|
||||
class="flex flex-wrap items-center gap-1.5"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="flex items-center gap-1 rounded-full bg-[#2f80d1] px-3 py-1.5 text-xs font-semibold text-white shadow-sm transition-colors hover:bg-[#2369ad] disabled:cursor-not-allowed disabled:opacity-50"
|
||||
:disabled="isThinking || isUploadingAttachments || !attachmentPolicy.canLocal"
|
||||
:title="$t('chat.procurementContract.uploadContractToReview')"
|
||||
@click="selectProcurementContractLocal"
|
||||
>
|
||||
<Upload class="h-3.5 w-3.5" />
|
||||
{{ $t('chat.procurementContract.uploadContractToReview') }}
|
||||
</button>
|
||||
<span class="rounded-full border border-dashed border-[#d8e0ec] px-3 py-1.5 text-xs font-semibold text-[#667792]">
|
||||
{{ $t('chat.procurementContract.soloHint') }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div
|
||||
@@ -605,29 +739,47 @@ watch(
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
v-if="isThinking && !isUploadingAttachments"
|
||||
type="button"
|
||||
class="flex h-10 w-10 items-center justify-center rounded-full border border-rose-300 bg-rose-50 text-rose-600 shadow-sm transition-all duration-200 hover:scale-105 hover:bg-rose-100 active:scale-95"
|
||||
:title="$t('chat.stopGenerating')"
|
||||
:aria-label="$t('chat.stopGenerating')"
|
||||
@click="emit('stop')"
|
||||
>
|
||||
<Square class="h-4 w-4 fill-current" />
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
type="button"
|
||||
:disabled="!canSendMessage"
|
||||
class="flex h-10 w-10 shrink-0 items-center justify-center rounded-full border shadow-sm transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
:class="!canSendMessage
|
||||
? 'border-default bg-slate-100 text-muted'
|
||||
: 'border-brand-500 bg-brand-500 text-white shadow-[0_0_0_4px_rgba(59,130,246,0.18)] hover:scale-105 hover:bg-brand-600 hover:shadow-[0_0_0_6px_rgba(59,130,246,0.24)] active:scale-95'"
|
||||
@click="emit('send')"
|
||||
>
|
||||
<Loader2 v-if="isUploadingAttachments" class="h-4 w-4 animate-spin" />
|
||||
<Send v-else class="h-4 w-4" />
|
||||
</button>
|
||||
<div class="flex shrink-0 items-center gap-1.5">
|
||||
<button
|
||||
type="button"
|
||||
:disabled="isThinking || isVoiceTranscribing"
|
||||
:title="isVoiceRecording ? $t('chat.voiceStop') : isVoiceTranscribing ? $t('chat.voiceTranscribing') : $t('chat.voiceFeature')"
|
||||
class="flex h-10 w-10 items-center justify-center rounded-full transition-colors disabled:cursor-not-allowed disabled:opacity-50"
|
||||
:class="isVoiceRecording
|
||||
? 'animate-pulse bg-rose-50 text-red-500'
|
||||
: isVoiceTranscribing
|
||||
? 'bg-brand-50 text-brand-500'
|
||||
: 'text-muted hover:bg-surface-soft hover:text-brand-600'"
|
||||
@click="emit('voice-click')"
|
||||
>
|
||||
<Loader2 v-if="isVoiceTranscribing" class="h-5 w-5 animate-spin" />
|
||||
<Mic v-else class="h-5 w-5" />
|
||||
</button>
|
||||
|
||||
<button
|
||||
v-if="isThinking && !isUploadingAttachments"
|
||||
type="button"
|
||||
class="flex h-10 w-10 items-center justify-center rounded-full border border-rose-300 bg-rose-50 text-rose-600 shadow-sm transition-all duration-200 hover:scale-105 hover:bg-rose-100 active:scale-95"
|
||||
:title="$t('chat.stopGenerating')"
|
||||
:aria-label="$t('chat.stopGenerating')"
|
||||
@click="emit('stop')"
|
||||
>
|
||||
<Square class="h-4 w-4 fill-current" />
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
type="button"
|
||||
:disabled="!canSendMessage"
|
||||
class="flex h-10 w-10 shrink-0 items-center justify-center rounded-full border shadow-sm transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
:class="!canSendMessage
|
||||
? 'border-default bg-slate-100 text-muted'
|
||||
: 'border-brand-500 bg-brand-500 text-white shadow-[0_0_0_4px_rgba(59,130,246,0.18)] hover:scale-105 hover:bg-brand-600 hover:shadow-[0_0_0_6px_rgba(59,130,246,0.24)] active:scale-95'"
|
||||
@click="emit('send')"
|
||||
>
|
||||
<Loader2 v-if="isUploadingAttachments" class="h-4 w-4 animate-spin" />
|
||||
<Send v-else class="h-4 w-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-3 text-center text-[11px] text-muted">
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
/**
|
||||
* features/chat/components/ChatSidebar.vue
|
||||
* 用途:桌面端聊天侧栏,承载 Agent 信息、会话历史、Agent 切换面板与底部用户菜单。
|
||||
* 依赖:lucide-vue-next、LocaleToggleButton、AgentCategoryList、chat.types。
|
||||
* 依赖:lucide-vue-next、LocaleToggleButton、ExternalSystemLinks、AgentCategoryList、chat.types。
|
||||
* 逻辑:由聊天页面传入当前 Agent、历史记录与用户可用 Agent;通过事件把新会话、切换 Agent、反馈、进入管理控制台等操作回传给页面。
|
||||
* 管理员通过底部右侧工具图标进入管理控制台;用户下拉菜单仅保留退出登录。
|
||||
* 关联服务入口与主题/语言等底栏图标统一为同尺寸 inline icon 按钮,避免错位。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
|
||||
@@ -25,6 +26,7 @@ import {
|
||||
X,
|
||||
} from 'lucide-vue-next';
|
||||
import LocaleToggleButton from '@/shared/components/LocaleToggleButton.vue';
|
||||
import { ExternalSystemLinks } from '@/features/sso';
|
||||
import AgentCategoryList from '@/shared/components/AgentCategoryList.vue';
|
||||
import { isHrFocusedAgent, type AgentRegistryFields } from '@/shared/utils/agent-registry.utils';
|
||||
import type { AgentWithCategory } from '@/shared/utils/agent-category.utils';
|
||||
@@ -137,6 +139,12 @@ const orderExtractionAttentionClass = (item: DisplayHistoryItem) => {
|
||||
</button>
|
||||
|
||||
<div class="mt-auto flex flex-col items-center gap-6 pb-2 text-muted">
|
||||
<ExternalSystemLinks
|
||||
compact
|
||||
:show-label="false"
|
||||
button-class="inline-flex items-center justify-center transition-colors hover:text-secondary"
|
||||
icon-class="h-5 w-5 shrink-0"
|
||||
/>
|
||||
<button type="button" class="transition-colors hover:text-secondary"><Sparkles class="h-5 w-5" /></button>
|
||||
<div class="flex h-8 w-8 items-center justify-center rounded-full bg-brand-600 text-sm font-bold text-white shadow-sm shadow-brand-500/20">
|
||||
{{ userInitial('I') }}
|
||||
@@ -168,7 +176,7 @@ const orderExtractionAttentionClass = (item: DisplayHistoryItem) => {
|
||||
@click="emit('open-guide')"
|
||||
>
|
||||
<BookOpen class="h-4 w-4" />
|
||||
学习之窗
|
||||
{{ $t('chat.learningWindow') }}
|
||||
</button>
|
||||
</div>
|
||||
<span v-if="agentDescription" class="mt-1 block cursor-help truncate text-[11px] text-muted">
|
||||
@@ -286,7 +294,7 @@ const orderExtractionAttentionClass = (item: DisplayHistoryItem) => {
|
||||
class="flex h-10 min-w-[2.5rem] items-center justify-center rounded-full bg-brand-600 px-3 text-sm font-bold text-white shadow-sm shadow-brand-500/20 transition-colors hover:bg-brand-700"
|
||||
@click="showUserDropdown = !showUserDropdown"
|
||||
>
|
||||
退出
|
||||
{{ $t('chat.exitShort') }}
|
||||
</button>
|
||||
|
||||
<div
|
||||
@@ -316,10 +324,16 @@ const orderExtractionAttentionClass = (item: DisplayHistoryItem) => {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-3">
|
||||
<div class="flex items-center gap-3">
|
||||
<ExternalSystemLinks
|
||||
compact
|
||||
:show-label="false"
|
||||
button-class="inline-flex items-center justify-center transition-colors hover:text-secondary"
|
||||
icon-class="h-4 w-4 shrink-0"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="transition-colors hover:text-secondary"
|
||||
class="inline-flex items-center justify-center transition-colors hover:text-secondary"
|
||||
:title="appliedTheme === 'dark' ? ($t('theme.switchToLight') || 'Switch to light mode') : ($t('theme.switchToDark') || 'Switch to dark mode')"
|
||||
@click="emit('toggle-theme')"
|
||||
>
|
||||
@@ -327,16 +341,16 @@ const orderExtractionAttentionClass = (item: DisplayHistoryItem) => {
|
||||
<Moon v-else class="h-4 w-4" />
|
||||
</button>
|
||||
<LocaleToggleButton variant="sidebar" />
|
||||
<button type="button" class="transition-colors hover:text-secondary" :title="$t('chat.generalFeedback')" @click="emit('open-feedback')">
|
||||
<button type="button" class="inline-flex items-center justify-center transition-colors hover:text-secondary" :title="$t('chat.generalFeedback')" @click="emit('open-feedback')">
|
||||
<MessageSquareText class="h-4 w-4" />
|
||||
</button>
|
||||
<button type="button" class="transition-colors hover:text-secondary" :title="$t('workspace.title')" @click="emit('go-workspace')">
|
||||
<button type="button" class="inline-flex items-center justify-center transition-colors hover:text-secondary" :title="$t('workspace.title')" @click="emit('go-workspace')">
|
||||
<Briefcase class="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
v-if="currentUser?.role === 'admin'"
|
||||
type="button"
|
||||
class="transition-colors hover:text-secondary"
|
||||
class="inline-flex items-center justify-center transition-colors hover:text-secondary"
|
||||
:title="$t('admin.title')"
|
||||
@click="onGoAdmin"
|
||||
>
|
||||
|
||||
@@ -591,17 +591,13 @@ watch(() => page.currentAgentId, () => {
|
||||
:key="`${page.currentAgentId}-${page.conversationId || 'draft'}-${page.messages.length}`"
|
||||
|
||||
v-model="page.input"
|
||||
|
||||
v-model:selected-kb="page.selectedKb"
|
||||
|
||||
v-model:procurement-review-mode="page.procurementReviewMode"
|
||||
:attachments="page.attachments"
|
||||
|
||||
:attachment-policy="page.attachmentPolicy"
|
||||
|
||||
:available-kb-options="page.availableKbOptions"
|
||||
|
||||
:kb-dropdown-disabled="page.kbDropdownDisabled"
|
||||
|
||||
:is-thinking="page.isThinking"
|
||||
|
||||
:is-voice-recording="page.isVoiceRecording"
|
||||
@@ -613,7 +609,8 @@ watch(() => page.currentAgentId, () => {
|
||||
:can-send-message="page.canSendMessage"
|
||||
|
||||
:is-shipping-notice-agent="page.isShippingNoticeAgent"
|
||||
|
||||
:is-procurement-contract-agent="page.isProcurementContractAgent"
|
||||
:procurement-original-contract-name="page.procurementOriginalContractName"
|
||||
:is-maintenance-agent="isMaintenanceAgentPage"
|
||||
|
||||
:can-manage-maintenance="canManageMaintenance"
|
||||
@@ -625,9 +622,7 @@ watch(() => page.currentAgentId, () => {
|
||||
:shipping-picker-ref-holder="page.shippingPickerRefHolder"
|
||||
|
||||
:shipping-notice-picker-ref-holder="page.shippingNoticePickerRefHolder"
|
||||
|
||||
:get-kb-label="page.getKbLabel"
|
||||
|
||||
@send="page.handleSend()"
|
||||
|
||||
@stop="page.stopActiveGeneration()"
|
||||
@@ -657,7 +652,9 @@ watch(() => page.currentAgentId, () => {
|
||||
@maintenance-ledger-config="maintenancePanel = 'ledger'"
|
||||
|
||||
@maintenance-create-record="openBlankMaintenanceRecordCreate"
|
||||
|
||||
@clear-shipping-focus="page.clearShippingFocus"
|
||||
@procurement-original-contract-selected="page.handleProcurementOriginalContractSelected"
|
||||
@clear-procurement-original-contract="page.clearProcurementOriginalContract"
|
||||
/>
|
||||
|
||||
</div>
|
||||
@@ -819,4 +816,3 @@ watch(() => page.currentAgentId, () => {
|
||||
|
||||
</template>
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ async function handleQueryPreviewAssetImage(assetId: string, assetName: string)
|
||||
>
|
||||
<div class="flex items-center gap-2 rounded-full border border-brand-200 bg-white/95 px-4 py-2 text-sm text-brand-700 shadow-lg backdrop-blur">
|
||||
<Loader2 class="h-4 w-4 animate-spin text-brand-500" />
|
||||
<span>正在搜索该资产的履历资料,请耐心等待...</span>
|
||||
<span>{{ page.t('chat.assetHistory.searchingToast') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
@@ -82,7 +82,7 @@ async function handleQueryPreviewAssetImage(assetId: string, assetName: string)
|
||||
>
|
||||
<div class="flex items-center gap-2 rounded-full border border-brand-200 bg-white/95 px-4 py-2 text-sm text-brand-700 shadow-lg backdrop-blur">
|
||||
<Loader2 class="h-4 w-4 animate-spin text-brand-500" />
|
||||
<span>正在搜索该资产的图片资料,请耐心等待...</span>
|
||||
<span>{{ page.t('chat.assetImage.searchingToast') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<ChatLeaveAgentDialog
|
||||
|
||||
@@ -3,24 +3,17 @@
|
||||
* 用途:渲染单条聊天消息,统一承接用户气泡、助手 Markdown、内嵌文件下载、请假/出货子组件与操作栏。
|
||||
* 依赖:Vue computed、lucide 图标、消息附件/Leave/Shipping 子组件、chat.types 与页面级 handlers。
|
||||
* 逻辑:由 ChatMessageList 按消息逐条挂载;货代履约写按钮不在气泡内渲染,仅展示只读卡与深链通知。
|
||||
* 兼容:同时承接采购合同审查、库存映射、订单提取和 Mermaid 展示。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, ref, watch } from 'vue';
|
||||
import {
|
||||
Check,
|
||||
Copy,
|
||||
Download,
|
||||
Edit2,
|
||||
Eye,
|
||||
LayoutGrid,
|
||||
MessageSquareText,
|
||||
RotateCw,
|
||||
X,
|
||||
} from 'lucide-vue-next';
|
||||
import { computed, nextTick, onMounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Check, Copy, Download, Edit2, Eye, LayoutGrid, MessageSquareText, RotateCw, X } from 'lucide-vue-next';
|
||||
import { useAuthStore } from '@/features/auth/stores/auth.store';
|
||||
import LeaveMessageBlock, { type LeaveMessageHandlers } from './LeaveMessageBlock.vue';
|
||||
import ChatMessageAttachmentList from './ChatMessageAttachmentList.vue';
|
||||
import MaintenanceDeviceResultCard from './MaintenanceDeviceResultCard.vue';
|
||||
import ContractReviewResultCard from './ContractReviewResultCard.vue';
|
||||
import ShippingMatchResultCard from './ShippingMatchResultCard.vue';
|
||||
import ShippingParseReviewMessage, { type ShippingParseReviewHandlers } from './ShippingParseReviewMessage.vue';
|
||||
import type { ShippingMessageHandlers } from './shippingMessageHandlers';
|
||||
@@ -29,6 +22,7 @@ import TrainingVideoMessage from './TrainingVideoMessage.vue';
|
||||
import TrainingSummaryMessage from './TrainingSummaryMessage.vue';
|
||||
import TrainingResultCard from './TrainingResultCard.vue';
|
||||
import ShippingOrderExtractionCard from '../shipping/ShippingOrderExtractionCard.vue';
|
||||
import { buildMermaidFlowFallbackHtml } from '../../utils/mermaidChart';
|
||||
import type { ChatMessage, InlineDownloadFile, SourceFileLink } from '../../types/chat.types';
|
||||
import type { ShippingMatchResultPayload } from '../../types/shipping.types';
|
||||
import type { MaintenanceDevice } from '@/features/maintenance/types/ledger.types';
|
||||
@@ -92,9 +86,13 @@ const emit = defineEmits<{
|
||||
}>();
|
||||
|
||||
const authStore = useAuthStore();
|
||||
const { t } = useI18n();
|
||||
const INLINE_DOWNLOAD_ALLOWED_EMPLOYEE_ID = '17070141';
|
||||
const RESTRICTED_INLINE_DOWNLOAD_FILE_NAME = '资产明细全量导出表.csv';
|
||||
|
||||
/** 合同审查结果卡:自身已是完整卡片,外层只需透明容器。 */
|
||||
const isContractReviewMessage = computed(() => message.type === 'procurement-contract-review');
|
||||
|
||||
const isLeaveMessage = computed(() =>
|
||||
message.type === 'leave-form'
|
||||
|| message.type === 'leave-confirmation'
|
||||
@@ -173,6 +171,33 @@ const isCopied = computed(() => copiedIndex === index);
|
||||
const renderedMarkdown = computed(() => (
|
||||
message.role === 'assistant' ? handlers.renderMarkdown(message.content) : ''
|
||||
));
|
||||
const markdownContainer = ref<HTMLElement | null>(null);
|
||||
|
||||
/**
|
||||
* 用途:将回答中的 Mermaid 流程图代码块转换成内嵌流程卡片。
|
||||
* 依赖:useChatPageMarkdown 为 `mermaid` 代码块保留 `.chat-mermaid` 标记。
|
||||
* 逻辑:不直接执行 Mermaid,避免 Dify 非标准图语法使 Mermaid 在页面根节点注入错误 SVG;
|
||||
* 对可提取的主流程展示节点卡片和箭头,其余图表代码块静默隐藏,不影响普通文本与表格。
|
||||
*/
|
||||
const renderMermaidCharts = async () => {
|
||||
await nextTick();
|
||||
const container = markdownContainer.value;
|
||||
if (!container) return;
|
||||
const nodes = Array.from(container.querySelectorAll<HTMLElement>('pre.chat-mermaid:not([data-mermaid-rendered])'));
|
||||
if (!nodes.length) return;
|
||||
for (const node of nodes) {
|
||||
node.dataset.mermaidRendered = 'pending';
|
||||
const fallbackHtml = buildMermaidFlowFallbackHtml(node.textContent || '');
|
||||
if (fallbackHtml) {
|
||||
node.outerHTML = fallbackHtml;
|
||||
continue;
|
||||
}
|
||||
node.remove();
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => { void renderMermaidCharts(); });
|
||||
watch(renderedMarkdown, () => { void renderMermaidCharts(); });
|
||||
const inlineDownloadFiles = computed(() => (
|
||||
message.role === 'assistant' ? handlers.getInlineDownloadFiles(message.content).files : []
|
||||
));
|
||||
@@ -198,56 +223,57 @@ interface InlineFileEntry {
|
||||
table: InlinePreviewTable;
|
||||
}
|
||||
|
||||
const FIXED_ASSET_HEADER_LABELS: Record<string, string> = {
|
||||
id: '序号',
|
||||
asset_id: '资产编号',
|
||||
asset_no: '资产编号',
|
||||
asset_name: '资产名称',
|
||||
currency_amount: '本币金额(元)',
|
||||
specification: '规格型号',
|
||||
account_period: '账套',
|
||||
operating_center_code: '账套',
|
||||
custodian_person: '保管人',
|
||||
custodian_name: '保管人',
|
||||
custodian_dept: '保管部门',
|
||||
department_name: '保管部门',
|
||||
image: '图片',
|
||||
picture: '图片',
|
||||
storage_location: '存放位置名称',
|
||||
location_name: '存放位置名称',
|
||||
asset_status: '资产状态',
|
||||
reserved_field: '预留残值',
|
||||
residual_value: '预留残值',
|
||||
supplier: '供应商',
|
||||
vendor_name: '供应商',
|
||||
asset_nature: '资产性质',
|
||||
nature: '资产性质',
|
||||
amount_local: '本币金额(元)',
|
||||
unit_price: '本币金额(元)',
|
||||
quantity: '数量',
|
||||
unit: '计量单位',
|
||||
unit_of_measurement: '计量单位',
|
||||
acquisition_date: '取得时间',
|
||||
acquired_date: '取得时间',
|
||||
accounting_date: '入账日期',
|
||||
recorded_date: '入账日期',
|
||||
created_at: '创建时间',
|
||||
created_time: '创建时间',
|
||||
updated_at: '更新时间',
|
||||
snapshot_time: '快照时间',
|
||||
/** 英文字段名 → chat.assetColumns.* key(展示用;匹配仍用 aliases 中的中英文别名) */
|
||||
const FIXED_ASSET_HEADER_KEYS: Record<string, string> = {
|
||||
id: 'chat.assetColumns.id',
|
||||
asset_id: 'chat.assetColumns.assetId',
|
||||
asset_no: 'chat.assetColumns.assetId',
|
||||
asset_name: 'chat.assetColumns.assetName',
|
||||
currency_amount: 'chat.assetColumns.currencyAmount',
|
||||
specification: 'chat.assetColumns.specification',
|
||||
account_period: 'chat.assetColumns.accountPeriod',
|
||||
operating_center_code: 'chat.assetColumns.accountPeriod',
|
||||
custodian_person: 'chat.assetColumns.custodianPerson',
|
||||
custodian_name: 'chat.assetColumns.custodianPerson',
|
||||
custodian_dept: 'chat.assetColumns.custodianDept',
|
||||
department_name: 'chat.assetColumns.custodianDept',
|
||||
image: 'chat.assetColumns.image',
|
||||
picture: 'chat.assetColumns.image',
|
||||
storage_location: 'chat.assetColumns.storageLocation',
|
||||
location_name: 'chat.assetColumns.storageLocation',
|
||||
asset_status: 'chat.assetColumns.assetStatus',
|
||||
reserved_field: 'chat.assetColumns.residualValue',
|
||||
residual_value: 'chat.assetColumns.residualValue',
|
||||
supplier: 'chat.assetColumns.supplier',
|
||||
vendor_name: 'chat.assetColumns.supplier',
|
||||
asset_nature: 'chat.assetColumns.assetNature',
|
||||
nature: 'chat.assetColumns.assetNature',
|
||||
amount_local: 'chat.assetColumns.currencyAmount',
|
||||
unit_price: 'chat.assetColumns.currencyAmount',
|
||||
quantity: 'chat.assetColumns.quantity',
|
||||
unit: 'chat.assetColumns.unit',
|
||||
unit_of_measurement: 'chat.assetColumns.unit',
|
||||
acquisition_date: 'chat.assetColumns.acquisitionDate',
|
||||
acquired_date: 'chat.assetColumns.acquisitionDate',
|
||||
accounting_date: 'chat.assetColumns.accountingDate',
|
||||
recorded_date: 'chat.assetColumns.accountingDate',
|
||||
created_at: 'chat.assetColumns.createdAt',
|
||||
created_time: 'chat.assetColumns.createdAt',
|
||||
updated_at: 'chat.assetColumns.updatedAt',
|
||||
snapshot_time: 'chat.assetColumns.snapshotTime',
|
||||
};
|
||||
const FIXED_ASSET_CANONICAL_COLUMNS = [
|
||||
{ key: 'id', label: '序号', aliases: ['id', '序号'] },
|
||||
{ key: 'asset_id', label: '资产编号', aliases: ['asset_id', 'asset_no', '资产编号'] },
|
||||
{ key: 'asset_name', label: '资产名称', aliases: ['asset_name', '资产名称'] },
|
||||
{ key: 'custodian_person', label: '保管人', aliases: ['custodian_person', 'custodian_name', '保管人', '保管人姓名'] },
|
||||
{ key: 'custodian_dept', label: '保管部门', aliases: ['custodian_dept', 'department_name', '保管部门', '保管部门名称'] },
|
||||
{ key: 'image', label: '图片', aliases: ['image', 'picture', '图片'] },
|
||||
{ key: 'account_period', label: '账套', aliases: ['account_period', 'operating_center_code', '账套'] },
|
||||
{ key: 'supplier', label: '供应商', aliases: ['supplier', 'vendor_name', '供应商', '供应厂商'] },
|
||||
{ key: 'asset_status', label: '资产状态', aliases: ['asset_status', '资产状态'] },
|
||||
{ key: 'quantity', label: '数量', aliases: ['quantity', '数量'] },
|
||||
{ key: 'acquisition_date', label: '取得时间', aliases: ['acquisition_date', 'acquired_date', '取得时间', '取得日期'] },
|
||||
{ key: 'id', labelKey: 'chat.assetColumns.id', aliases: ['id', '序号'] },
|
||||
{ key: 'asset_id', labelKey: 'chat.assetColumns.assetId', aliases: ['asset_id', 'asset_no', '资产编号'] },
|
||||
{ key: 'asset_name', labelKey: 'chat.assetColumns.assetName', aliases: ['asset_name', '资产名称'] },
|
||||
{ key: 'custodian_person', labelKey: 'chat.assetColumns.custodianPerson', aliases: ['custodian_person', 'custodian_name', '保管人', '保管人姓名'] },
|
||||
{ key: 'custodian_dept', labelKey: 'chat.assetColumns.custodianDept', aliases: ['custodian_dept', 'department_name', '保管部门', '保管部门名称'] },
|
||||
{ key: 'image', labelKey: 'chat.assetColumns.image', aliases: ['image', 'picture', '图片'] },
|
||||
{ key: 'account_period', labelKey: 'chat.assetColumns.accountPeriod', aliases: ['account_period', 'operating_center_code', '账套'] },
|
||||
{ key: 'supplier', labelKey: 'chat.assetColumns.supplier', aliases: ['supplier', 'vendor_name', '供应商', '供应厂商'] },
|
||||
{ key: 'asset_status', labelKey: 'chat.assetColumns.assetStatus', aliases: ['asset_status', '资产状态'] },
|
||||
{ key: 'quantity', labelKey: 'chat.assetColumns.quantity', aliases: ['quantity', '数量'] },
|
||||
{ key: 'acquisition_date', labelKey: 'chat.assetColumns.acquisitionDate', aliases: ['acquisition_date', 'acquired_date', '取得时间', '取得日期'] },
|
||||
] as const;
|
||||
const INLINE_DIALOG_PAGE_SIZE = 15;
|
||||
|
||||
@@ -287,14 +313,15 @@ function parseCsvLine(line: string): string[] {
|
||||
}
|
||||
|
||||
/**
|
||||
* 将固定资产 CSV 的英文列名转换成面向业务展示的中文列名。
|
||||
* 将固定资产 CSV 的英文列名转换成面向业务展示的本地化列名。
|
||||
* 核心逻辑:优先命中已知字段映射;未知字段保留原值,避免误伤其他 Agent 的文件。
|
||||
* @param header - CSV 原始表头。
|
||||
* @returns 中文表头或原始表头。
|
||||
* @returns 本地化表头或原始表头。
|
||||
*/
|
||||
function localizeInlineTableHeader(header: string): string {
|
||||
const normalizedHeader = String(header || '').trim().toLowerCase();
|
||||
return FIXED_ASSET_HEADER_LABELS[normalizedHeader] || header || '-';
|
||||
const key = FIXED_ASSET_HEADER_KEYS[normalizedHeader];
|
||||
return key ? t(key) : (header || '-');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -317,14 +344,14 @@ function formatInlineDateOnly(value: string): string {
|
||||
|
||||
/**
|
||||
* 统一表格中的空值展示。
|
||||
* 核心逻辑:对空串、短横线、null/none 等占位值统一显示“无”,但保留数字 0 与正常文本。
|
||||
* 核心逻辑:对空串、短横线、null/none 等占位值统一显示本地化“无”,但保留数字 0 与正常文本。
|
||||
* @param value - 原始单元格值。
|
||||
* @returns 归一化后的展示值。
|
||||
*/
|
||||
function normalizeInlineTableCell(value: string): string {
|
||||
const normalized = String(value ?? '').trim();
|
||||
if (!normalized) return '无';
|
||||
if (['-', '--', 'null', 'none', 'n/a', 'na'].includes(normalized.toLowerCase())) return '无';
|
||||
if (!normalized) return t('chat.assetColumns.empty');
|
||||
if (['-', '--', 'null', 'none', 'n/a', 'na'].includes(normalized.toLowerCase())) return t('chat.assetColumns.empty');
|
||||
return normalized;
|
||||
}
|
||||
|
||||
@@ -387,7 +414,7 @@ function serializeCsvRows(rows: string[][]): string {
|
||||
* @returns 规范化后的表头与数据行。
|
||||
*/
|
||||
function buildFixedAssetInlineTable(rawHeaders: string[], dataRows: string[][]): InlinePreviewTable {
|
||||
const headers = FIXED_ASSET_CANONICAL_COLUMNS.map((column) => column.label);
|
||||
const headers = FIXED_ASSET_CANONICAL_COLUMNS.map((column) => t(column.labelKey));
|
||||
const canonicalHeaders = FIXED_ASSET_CANONICAL_COLUMNS.map((column) => column.key);
|
||||
const allRows = dataRows.map((row, rowIndex) => FIXED_ASSET_CANONICAL_COLUMNS.map((column) => {
|
||||
if (column.key === 'id') return String(rowIndex + 1);
|
||||
@@ -401,7 +428,7 @@ function buildFixedAssetInlineTable(rawHeaders: string[], dataRows: string[][]):
|
||||
if (normalizedImageValue) {
|
||||
return normalizeInlineTableCell(normalizedImageValue);
|
||||
}
|
||||
return normalizedAssetId ? '查看' : '无';
|
||||
return normalizedAssetId ? t('chat.assetColumns.view') : t('chat.assetColumns.empty');
|
||||
}
|
||||
const columnIndex = findInlineTableHeaderIndex(rawHeaders, [...column.aliases]);
|
||||
const rawValue = columnIndex >= 0 ? row[columnIndex] ?? '' : '';
|
||||
@@ -622,7 +649,10 @@ function canOpenInlineAssetHistory(cellIndex: number, cellValue: string): boolea
|
||||
}
|
||||
|
||||
function isInlineHighlightHeader(header: string): boolean {
|
||||
return header === '资产编号' || header === '图片';
|
||||
return header === t('chat.assetColumns.assetId')
|
||||
|| header === t('chat.assetColumns.image')
|
||||
|| header === '资产编号'
|
||||
|| header === '图片';
|
||||
}
|
||||
|
||||
async function openInlineAssetHistory(row: string[], cellIndex: number): Promise<void> {
|
||||
@@ -679,8 +709,10 @@ function handleInlineDownload(file: InlineDownloadFile): void {
|
||||
v-if="message.role === 'assistant' || hasUserPayload"
|
||||
class="text-[15px] leading-relaxed"
|
||||
:class="message.role === 'user'
|
||||
? 'rounded-2xl rounded-tr-sm bg-brand-600 p-2.5 text-white shadow-sm shadow-brand-500/15'
|
||||
: 'chat-msg-assistant'"
|
||||
? 'rounded-2xl rounded-tr-sm bg-brand-600 px-5 py-2.5 text-white shadow-sm shadow-brand-500/15'
|
||||
: isContractReviewMessage
|
||||
? 'w-full'
|
||||
: 'chat-msg-assistant'"
|
||||
>
|
||||
<template v-if="message.role === 'user'">
|
||||
<ChatMessageAttachmentList
|
||||
@@ -728,6 +760,10 @@ function handleInlineDownload(file: InlineDownloadFile): void {
|
||||
@view-record-history="emit('maintenance-view-record-history', $event)"
|
||||
@create-record="emit('maintenance-create-record-for-device', $event)"
|
||||
/>
|
||||
<ContractReviewResultCard
|
||||
v-else-if="message.type === 'procurement-contract-review'"
|
||||
:message="message"
|
||||
/>
|
||||
<TrainingExamQuestionMessage
|
||||
v-else-if="isTrainingExamMessage && trainingHandlers.getQuestion()"
|
||||
:question="trainingHandlers.getQuestion()!"
|
||||
@@ -947,7 +983,7 @@ function handleInlineDownload(file: InlineDownloadFile): void {
|
||||
<Download class="h-3.5 w-3.5" />
|
||||
{{ $t('chat.inlineFile.download') }}
|
||||
</button>
|
||||
<button type="button" class="btn-icon-ds" aria-label="关闭" @click="closeInlinePreviewDialog">
|
||||
<button type="button" class="btn-icon-ds" :aria-label="$t('common.close')" @click="closeInlinePreviewDialog">
|
||||
<X class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
@@ -1084,6 +1120,71 @@ function handleInlineDownload(file: InlineDownloadFile): void {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
:deep(.chat-markdown .chat-mermaid-diagram) {
|
||||
max-width: 100%;
|
||||
overflow: auto;
|
||||
margin: 1rem 0;
|
||||
padding: 1rem;
|
||||
border: 1px solid rgb(219 234 254);
|
||||
border-radius: 0.75rem;
|
||||
background: linear-gradient(135deg, rgb(248 250 252), rgb(239 246 255));
|
||||
}
|
||||
|
||||
:deep(.chat-markdown .chat-mermaid-diagram svg) {
|
||||
display: block;
|
||||
min-width: 36rem;
|
||||
max-width: none;
|
||||
height: auto;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
:deep(.chat-markdown .chat-mermaid-error) {
|
||||
white-space: pre;
|
||||
overflow: auto;
|
||||
color: rgb(127 29 29);
|
||||
}
|
||||
|
||||
:deep(.chat-markdown .chat-mermaid-error-tip) {
|
||||
margin: 0.75rem 0 0.25rem;
|
||||
color: rgb(185 28 28);
|
||||
font-size: 0.8125rem;
|
||||
}
|
||||
|
||||
:deep(.chat-markdown .chat-flow-fallback) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
max-width: 100%;
|
||||
overflow-x: auto;
|
||||
margin: 1rem 0;
|
||||
padding: 1rem;
|
||||
border: 1px solid rgb(191 219 254);
|
||||
border-radius: 0.75rem;
|
||||
background: linear-gradient(135deg, rgb(248 250 252), rgb(239 246 255));
|
||||
}
|
||||
|
||||
:deep(.chat-markdown .chat-flow-fallback-card) {
|
||||
flex: 0 0 auto;
|
||||
min-width: 8.5rem;
|
||||
max-width: 13rem;
|
||||
padding: 0.75rem 1rem;
|
||||
border: 1px solid rgb(96 165 250);
|
||||
border-radius: 0.625rem;
|
||||
background: white;
|
||||
color: rgb(30 64 175);
|
||||
font-weight: 600;
|
||||
line-height: 1.45;
|
||||
text-align: center;
|
||||
box-shadow: 0 2px 8px rgb(59 130 246 / 0.12);
|
||||
}
|
||||
|
||||
:deep(.chat-markdown .chat-flow-fallback-arrow) {
|
||||
flex: 0 0 auto;
|
||||
color: rgb(37 99 235);
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
:deep(.chat-markdown .chat-table-scroll) {
|
||||
max-width: 100%;
|
||||
overflow-x: auto;
|
||||
|
||||
Reference in new issue
Block a user