mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-31 18:22:49 +00:00
refactor: clean up formatting and improve code readability in ModelResourceIndex.vue
This commit is contained in:
parent
ba3a2153e0
commit
82779d1719
|
|
@ -15,9 +15,9 @@
|
|||
style="width: 120px"
|
||||
@change="search_type_change"
|
||||
>
|
||||
<el-option :label="$t('common.creator')" value="create_user" />
|
||||
<el-option :label="$t('views.model.modelForm.model_type.label')" value="model_type" />
|
||||
<el-option :label="$t('views.model.modelForm.modeName.label')" value="name" />
|
||||
<el-option :label="$t('common.creator')" value="create_user"/>
|
||||
<el-option :label="$t('views.model.modelForm.model_type.label')" value="model_type"/>
|
||||
<el-option :label="$t('views.model.modelForm.modeName.label')" value="name"/>
|
||||
</el-select>
|
||||
<el-input
|
||||
v-if="search_type === 'name'"
|
||||
|
|
@ -34,7 +34,7 @@
|
|||
clearable
|
||||
style="width: 220px"
|
||||
>
|
||||
<el-option v-for="u in user_options" :key="u.id" :value="u.id" :label="u.username" />
|
||||
<el-option v-for="u in user_options" :key="u.id" :value="u.id" :label="u.username"/>
|
||||
</el-select>
|
||||
<el-select
|
||||
v-else-if="search_type === 'model_type'"
|
||||
|
|
@ -44,7 +44,7 @@
|
|||
style="width: 220px"
|
||||
>
|
||||
<template v-for="item in modelTypeList" :key="item.value">
|
||||
<el-option :label="item.text" :value="item.value" />
|
||||
<el-option :label="item.text" :value="item.value"/>
|
||||
</template>
|
||||
</el-select>
|
||||
</div>
|
||||
|
|
@ -113,7 +113,7 @@
|
|||
@click="workspaceVisible = !workspaceVisible"
|
||||
>
|
||||
<el-icon>
|
||||
<Filter />
|
||||
<Filter/>
|
||||
</el-icon>
|
||||
</el-button>
|
||||
</template>
|
||||
|
|
@ -138,17 +138,17 @@
|
|||
</div>
|
||||
<div class="text-right">
|
||||
<el-button size="small" @click="filterWorkspaceChange('clear')"
|
||||
>{{ $t('common.clear') }}
|
||||
>{{ $t('common.clear') }}
|
||||
</el-button>
|
||||
<el-button type="primary" @click="filterWorkspaceChange" size="small"
|
||||
>{{ $t('common.confirm') }}
|
||||
>{{ $t('common.confirm') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</el-popover>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="nick_name" :label="$t('common.creator')" show-overflow-tooltip />
|
||||
<el-table-column prop="nick_name" :label="$t('common.creator')" show-overflow-tooltip/>
|
||||
<el-table-column :label="$t('views.document.table.updateTime')" width="180">
|
||||
<template #default="{ row }">
|
||||
{{ datetimeFormat(row.update_time) }}
|
||||
|
|
@ -165,17 +165,17 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { onBeforeMount, onMounted, ref, reactive, nextTick, computed } from 'vue'
|
||||
import type { Provider, Model } from '@/api/type/model'
|
||||
import {onBeforeMount, onMounted, ref, reactive, nextTick, computed} from 'vue'
|
||||
import type {Provider, Model} from '@/api/type/model'
|
||||
import ModelResourceApi from '@/api/system-resource-management/model'
|
||||
import { modelTypeList } from '@/views/model/component/data'
|
||||
import { modelType } from '@/enums/model'
|
||||
import { t } from '@/locales'
|
||||
import {modelTypeList} from '@/views/model/component/data'
|
||||
import {modelType} from '@/enums/model'
|
||||
import {t} from '@/locales'
|
||||
import useStore from '@/stores'
|
||||
import { datetimeFormat } from '@/utils/time'
|
||||
import {datetimeFormat} from '@/utils/time'
|
||||
import {loadPermissionApi} from "@/utils/dynamics-api/permission-api.ts";
|
||||
|
||||
const { user, model } = useStore()
|
||||
const {user, model} = useStore()
|
||||
|
||||
const search_type = ref('name')
|
||||
const model_search_form = ref<{
|
||||
|
|
@ -209,6 +209,7 @@ const getRowProvider = computed(() => {
|
|||
return provider_list.value.find((p) => p.provider === row.provider)
|
||||
}
|
||||
})
|
||||
|
||||
function filterWorkspaceChange(val: string) {
|
||||
if (val === 'clear') {
|
||||
workspaceArr.value = []
|
||||
|
|
@ -216,6 +217,7 @@ function filterWorkspaceChange(val: string) {
|
|||
getList()
|
||||
workspaceVisible.value = false
|
||||
}
|
||||
|
||||
async function getWorkspaceList() {
|
||||
if (user.isEE()) {
|
||||
const res = await loadPermissionApi('workspace').getSystemWorkspaceList(loading)
|
||||
|
|
@ -225,18 +227,32 @@ async function getWorkspaceList() {
|
|||
}))
|
||||
}
|
||||
}
|
||||
|
||||
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() {
|
||||
ModelResourceApi.getModelListPage(paginationConfig, model_search_form.value, loading).then(
|
||||
ModelResourceApi.getModelListPage(paginationConfig, getRequestParams(), loading).then(
|
||||
(res: any) => {
|
||||
paginationConfig.total = res.data?.total
|
||||
modelList.value = res.data?.records
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
function getProvider() {
|
||||
model.asyncGetProvider(loading).then((res: any) => {
|
||||
provider_list.value = res?.data
|
||||
|
|
|
|||
Loading…
Reference in New Issue