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"
|
style="width: 120px"
|
||||||
@change="search_type_change"
|
@change="search_type_change"
|
||||||
>
|
>
|
||||||
<el-option :label="$t('common.creator')" value="create_user" />
|
<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.model_type.label')" value="model_type"/>
|
||||||
<el-option :label="$t('views.model.modelForm.modeName.label')" value="name" />
|
<el-option :label="$t('views.model.modelForm.modeName.label')" value="name"/>
|
||||||
</el-select>
|
</el-select>
|
||||||
<el-input
|
<el-input
|
||||||
v-if="search_type === 'name'"
|
v-if="search_type === 'name'"
|
||||||
@ -34,7 +34,7 @@
|
|||||||
clearable
|
clearable
|
||||||
style="width: 220px"
|
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>
|
||||||
<el-select
|
<el-select
|
||||||
v-else-if="search_type === 'model_type'"
|
v-else-if="search_type === 'model_type'"
|
||||||
@ -44,7 +44,7 @@
|
|||||||
style="width: 220px"
|
style="width: 220px"
|
||||||
>
|
>
|
||||||
<template v-for="item in modelTypeList" :key="item.value">
|
<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>
|
</template>
|
||||||
</el-select>
|
</el-select>
|
||||||
</div>
|
</div>
|
||||||
@ -113,7 +113,7 @@
|
|||||||
@click="workspaceVisible = !workspaceVisible"
|
@click="workspaceVisible = !workspaceVisible"
|
||||||
>
|
>
|
||||||
<el-icon>
|
<el-icon>
|
||||||
<Filter />
|
<Filter/>
|
||||||
</el-icon>
|
</el-icon>
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
@ -138,17 +138,17 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
<el-button size="small" @click="filterWorkspaceChange('clear')"
|
<el-button size="small" @click="filterWorkspaceChange('clear')"
|
||||||
>{{ $t('common.clear') }}
|
>{{ $t('common.clear') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button type="primary" @click="filterWorkspaceChange" size="small"
|
<el-button type="primary" @click="filterWorkspaceChange" size="small"
|
||||||
>{{ $t('common.confirm') }}
|
>{{ $t('common.confirm') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-popover>
|
</el-popover>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</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">
|
<el-table-column :label="$t('views.document.table.updateTime')" width="180">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
{{ datetimeFormat(row.update_time) }}
|
{{ datetimeFormat(row.update_time) }}
|
||||||
@ -165,17 +165,17 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onBeforeMount, onMounted, ref, reactive, nextTick, computed } from 'vue'
|
import {onBeforeMount, onMounted, ref, reactive, nextTick, computed} from 'vue'
|
||||||
import type { Provider, Model } from '@/api/type/model'
|
import type {Provider, Model} from '@/api/type/model'
|
||||||
import ModelResourceApi from '@/api/system-resource-management/model'
|
import ModelResourceApi from '@/api/system-resource-management/model'
|
||||||
import { modelTypeList } from '@/views/model/component/data'
|
import {modelTypeList} from '@/views/model/component/data'
|
||||||
import { modelType } from '@/enums/model'
|
import {modelType} from '@/enums/model'
|
||||||
import { t } from '@/locales'
|
import {t} from '@/locales'
|
||||||
import useStore from '@/stores'
|
import useStore from '@/stores'
|
||||||
import { datetimeFormat } from '@/utils/time'
|
import {datetimeFormat} from '@/utils/time'
|
||||||
import {loadPermissionApi} from "@/utils/dynamics-api/permission-api.ts";
|
import {loadPermissionApi} from "@/utils/dynamics-api/permission-api.ts";
|
||||||
|
|
||||||
const { user, model } = useStore()
|
const {user, model} = useStore()
|
||||||
|
|
||||||
const search_type = ref('name')
|
const search_type = ref('name')
|
||||||
const model_search_form = ref<{
|
const model_search_form = ref<{
|
||||||
@ -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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user