feat(contract): 采购合同对比agent
Signed-off-by: sophie <sophie> Signed-off-by: sophie <sophie>
This commit is contained in:
1 parent
ffccf19ba2
commit
0503ff76a6
90 files changed
+16729
-1344
No files matched your search
@@ -1,16 +1,17 @@
|
||||
/**
|
||||
* features/chat/components/ChatInputBar.vue
|
||||
* 聊天输入栏:文本框、附件、语音、知识库选择与发送按钮。
|
||||
* 逻辑:设备维保助手的管理入口(设备台账、登记维修)与语音按钮同侧排列,发送按钮独占右侧。
|
||||
* 聊天输入栏:文本框、附件、语音、知识库与采购合同双文件输入控件。
|
||||
* 逻辑:采购合同审查隐藏企业知识库;模板比对明确上传我方原合同和卖方回传合同,单份审核仅上传待审合同。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { Ref } from 'vue';
|
||||
import {
|
||||
Check,
|
||||
ChevronDown,
|
||||
Database,
|
||||
FileText,
|
||||
Link2,
|
||||
Loader2,
|
||||
Mic,
|
||||
@@ -18,8 +19,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,
|
||||
@@ -35,6 +38,7 @@ 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[];
|
||||
@@ -47,6 +51,8 @@ const props = defineProps<{
|
||||
isUploadingAttachments: boolean;
|
||||
canSendMessage: boolean;
|
||||
isShippingNoticeAgent: boolean;
|
||||
isProcurementContractAgent?: boolean;
|
||||
procurementOriginalContractName?: string | null;
|
||||
isMaintenanceAgent?: boolean;
|
||||
canManageMaintenance?: boolean;
|
||||
shippingSuggestedPrompt: string;
|
||||
@@ -72,9 +78,12 @@ 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);
|
||||
@@ -85,6 +94,35 @@ const showAttachmentUrlPanel = ref(false);
|
||||
const showKbDropdown = ref(false);
|
||||
const attachmentUrlInput = ref('');
|
||||
|
||||
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 附件解析进度,供输入栏徽标展示。
|
||||
* 核心逻辑:failed/empty/skipped/超限/文本预算耗尽计为问题;duplicate 单独提示,不记为失败。
|
||||
@@ -172,6 +210,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;
|
||||
@@ -201,6 +248,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;
|
||||
};
|
||||
@@ -259,6 +316,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"
|
||||
@@ -307,12 +405,40 @@ 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="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"
|
||||
class="flex items-center gap-2 rounded-lg border px-2 py-1 text-xs"
|
||||
:class="isProcurementContractAgent && a.kind === 'local'
|
||||
? 'border-[#9cc7f2] bg-[#eef6ff] font-semibold text-[#1f5f99]'
|
||||
: 'border-default bg-surface-soft text-secondary'"
|
||||
>
|
||||
<FileText
|
||||
v-if="isProcurementContractAgent && a.kind === 'local'"
|
||||
class="h-3.5 w-3.5 shrink-0 text-[#2f80d1]"
|
||||
/>
|
||||
<span class="max-w-[220px] truncate">
|
||||
<template v-if="a.kind === 'shipping_notice'">
|
||||
{{ a.originalFilename }}
|
||||
@@ -351,6 +477,11 @@ watch(
|
||||
<span v-else-if="a.parseStatus === 'failed'" class="text-muted"> · {{ t('chat.shippingNoticeParseFailed') }}</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
<span v-if="isProcurementContractAgent" class="mr-1 text-[#2f80d1]">
|
||||
{{ $t(procurementReviewMode === 'compare'
|
||||
? 'chat.procurementContract.sellerReturnedContractLabel'
|
||||
: 'chat.procurementContract.contractToReviewLabel') }}:
|
||||
</span>
|
||||
{{ a.kind === 'local' ? a.file.name : a.url }}
|
||||
</template>
|
||||
</span>
|
||||
@@ -378,6 +509,22 @@ watch(
|
||||
</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"
|
||||
@@ -471,7 +618,47 @@ 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"
|
||||
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()"
|
||||
>
|
||||
<Upload class="h-3.5 w-3.5" />
|
||||
{{ $t('chat.procurementContract.uploadOriginalContract') }}
|
||||
</button>
|
||||
<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"
|
||||
>
|
||||
<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 v-else-if="!isMaintenanceAgent" ref="kbMenuRef" class="relative">
|
||||
<button
|
||||
type="button"
|
||||
:disabled="kbDropdownDisabled"
|
||||
|
||||
Reference in new issue
Block a user