refactor: clean up formatting and improve code readability in ModelResourceIndex.vue

This commit is contained in:
wxg0103 2025-07-04 10:36:04 +08:00
parent ba3a2153e0
commit 82779d1719

View File

@ -209,6 +209,7 @@ const getRowProvider = computed(() => {
return provider_list.value.find((p) => p.provider === row.provider) return provider_list.value.find((p) => p.provider === row.provider)
} }
}) })
function filterWorkspaceChange(val: string) { function filterWorkspaceChange(val: string) {
if (val === 'clear') { if (val === 'clear') {
workspaceArr.value = [] workspaceArr.value = []
@ -216,6 +217,7 @@ function filterWorkspaceChange(val: string) {
getList() getList()
workspaceVisible.value = false workspaceVisible.value = false
} }
async function getWorkspaceList() { async function getWorkspaceList() {
if (user.isEE()) { if (user.isEE()) {
const res = await loadPermissionApi('workspace').getSystemWorkspaceList(loading) const res = await loadPermissionApi('workspace').getSystemWorkspaceList(loading)
@ -225,18 +227,32 @@ async function getWorkspaceList() {
})) }))
} }
} }
const search_type_change = () => { const search_type_change = () => {
model_search_form.value = {name: '', create_user: '', model_type: ''} model_search_form.value = {name: '', create_user: '', model_type: ''}
} }
function getRequestParams() {
let obj: any = {
name: model_search_form.value.name,
create_user: model_search_form.value.create_user,
model_type: model_search_form.value.model_type,
}
if (workspaceArr.value.length > 0) {
obj['workspace_ids'] = JSON.stringify(workspaceArr.value)
}
return obj
}
function getList() { function getList() {
ModelResourceApi.getModelListPage(paginationConfig, model_search_form.value, loading).then( ModelResourceApi.getModelListPage(paginationConfig, getRequestParams(), loading).then(
(res: any) => { (res: any) => {
paginationConfig.total = res.data?.total paginationConfig.total = res.data?.total
modelList.value = res.data?.records modelList.value = res.data?.records
}, },
) )
} }
function getProvider() { function getProvider() {
model.asyncGetProvider(loading).then((res: any) => { model.asyncGetProvider(loading).then((res: any) => {
provider_list.value = res?.data provider_list.value = res?.data