fix(固资): 固资查询erp报错问题修复

This commit is contained in:
runny committed 2026-06-08 14:37:52 +08:00
1 parent d039fc255c
commit 4ce4d75524
2 files changed
+55 -13

No files matched your search

+45 -9
View File
@@ -71,13 +71,17 @@ const currentUser = ref(getStoredAuthUser());
const showUserDropdown = ref(false);
const userMenuRef = ref<HTMLElement | null>(null);
const selectedKb = ref('企业知识库');
const DEFAULT_KB = '企业知识库';
const ERP_KB = 'ERP知识库';
const ERP_KB_ENABLED_AGENT_NAMES = new Set(['固资管理']);
const selectedKb = ref(DEFAULT_KB);
const showKbDropdown = ref(false);
const kbMenuRef = ref<HTMLElement | null>(null);
const kbOptions = ['企业知识库', 'ERP知识库'];
const kbOptions = [DEFAULT_KB, ERP_KB];
const getKbLabel = (kb: string) => {
if (kb === '企业知识库') return t('chat.kb.enterprise');
if (kb === 'ERP知识库') return t('chat.kb.erp');
if (kb === DEFAULT_KB) return t('chat.kb.enterprise');
if (kb === ERP_KB) return t('chat.kb.erp');
return kb;
};
const chatScrollContainer = ref<HTMLElement | null>(null);
@@ -782,6 +786,37 @@ const normalizeAgentSuggestedQuestions = (value: unknown): AgentSuggestedQuestio
};
const currentAgentName = computed(() => String(currentAgent.value?.name || '').trim());
const canSelectErpKnowledgeBase = computed(() => ERP_KB_ENABLED_AGENT_NAMES.has(currentAgentName.value));
const availableKbOptions = computed(() => (
canSelectErpKnowledgeBase.value
? kbOptions
: kbOptions.filter((option) => option !== ERP_KB)
));
const kbDropdownDisabled = computed(() => availableKbOptions.value.length <= 1);
const toggleKbDropdown = () => {
if (kbDropdownDisabled.value) {
showKbDropdown.value = false;
return;
}
showKbDropdown.value = !showKbDropdown.value;
};
const selectKb = (option: string) => {
if (!availableKbOptions.value.includes(option)) return;
selectedKb.value = option;
showKbDropdown.value = false;
};
watch(canSelectErpKnowledgeBase, (allowed) => {
if (!allowed && selectedKb.value === ERP_KB) {
selectedKb.value = DEFAULT_KB;
}
if (!allowed) {
showKbDropdown.value = false;
}
}, { immediate: true });
const agentDescription = computed(() => {
const text = String(currentAgent.value?.description || '').trim();
return text || DEFAULT_AGENT_DESCRIPTIONS[currentAgentName.value] || '';
@@ -3567,20 +3602,21 @@ const showChatRating = ref(false);
</div>
<div class="relative" ref="kbMenuRef">
<button
@click="showKbDropdown = !showKbDropdown"
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"
@click="toggleKbDropdown"
: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"
>
<Database class="h-3.5 w-3.5 text-brand-500" />
{{ getKbLabel(selectedKb) }} <ChevronDown class="h-3 w-3" />
</button>
<div
v-if="showKbDropdown"
v-if="showKbDropdown && !kbDropdownDisabled"
class="absolute bottom-full left-0 mb-2 w-36 overflow-hidden rounded-xl border border-subtle bg-surface py-1 shadow-xl animate-fade-in"
>
<button
v-for="option in kbOptions"
v-for="option in availableKbOptions"
:key="option"
@click="selectedKb = option; showKbDropdown = false"
@click="selectKb(option)"
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 }"
>