fix: 修复【模型管理】添加模型,选择供应商页面筛选模型类型,选择供应商后再返回供应商列表,变成了全部供应商

This commit is contained in:
shaohuzhang1 2024-10-29 18:33:01 +08:00 committed by shaohuzhang1
parent a67ecb3011
commit 401552e819

View File

@ -20,7 +20,11 @@
</span> </span>
<template #dropdown> <template #dropdown>
<el-dropdown-menu> <el-dropdown-menu>
<el-dropdown-item v-for="item in modelTypeOptions" :key="item.value" @click="checkModelType(item.value)"> <el-dropdown-item
v-for="item in modelTypeOptions"
:key="item.value"
@click="checkModelType(item.value)"
>
<span>{{ item.text }}</span> <span>{{ item.text }}</span>
<el-icon v-if="currentModelType === item.text"><Check /></el-icon> <el-icon v-if="currentModelType === item.text"><Check /></el-icon>
</el-dropdown-item> </el-dropdown-item>
@ -62,10 +66,8 @@ const modelTypeOptions = ref([
const open = () => { const open = () => {
dialogVisible.value = true dialogVisible.value = true
ModelApi.getProvider(loading).then((ok) => { const option = modelTypeOptions.value.find((item) => item.text === currentModelType.value)
list_provider.value = ok.data checkModelType(option ? option.value : '')
list_provider.value.sort((a, b) => a.provider.localeCompare(b.provider))
})
} }
const close = () => { const close = () => {
@ -73,7 +75,9 @@ const close = () => {
} }
const checkModelType = (model_type: string) => { const checkModelType = (model_type: string) => {
currentModelType.value = modelTypeOptions.value.filter((item) => item.value === model_type)[0].text currentModelType.value = modelTypeOptions.value.filter(
(item) => item.value === model_type
)[0].text
ModelApi.getProviderByModelType(model_type, loading).then((ok) => { ModelApi.getProviderByModelType(model_type, loading).then((ok) => {
list_provider.value = ok.data list_provider.value = ok.data
list_provider.value.sort((a, b) => a.provider.localeCompare(b.provider)) list_provider.value.sort((a, b) => a.provider.localeCompare(b.provider))