feat: resource model
This commit is contained in:
parent
8e6ca99ef6
commit
36e715d319
@ -2,7 +2,6 @@ import { Result } from '@/request/Result'
|
|||||||
import { get, post, del, put, exportFile, exportExcel } from '@/request/index'
|
import { get, post, del, put, exportFile, exportExcel } from '@/request/index'
|
||||||
import { type Ref } from 'vue'
|
import { type Ref } from 'vue'
|
||||||
import type { pageRequest } from '@/api/type/common'
|
import type { pageRequest } from '@/api/type/common'
|
||||||
import type { knowledgeData } from '@/api/type/knowledge'
|
|
||||||
|
|
||||||
const prefix = '/system/resource/knowledge'
|
const prefix = '/system/resource/knowledge'
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import type {
|
|||||||
CreateModelRequest,
|
CreateModelRequest,
|
||||||
EditModelRequest,
|
EditModelRequest,
|
||||||
} from '@/api/type/model'
|
} from '@/api/type/model'
|
||||||
|
import type { pageRequest } from '@/api/type/common'
|
||||||
import type { FormField } from '@/components/dynamics-form/type'
|
import type { FormField } from '@/components/dynamics-form/type'
|
||||||
|
|
||||||
const prefix = '/system/resource'
|
const prefix = '/system/resource'
|
||||||
@ -15,11 +16,12 @@ const prefix = '/system/resource'
|
|||||||
* 获得模型列表
|
* 获得模型列表
|
||||||
* @params 参数 name, model_type, model_name
|
* @params 参数 name, model_type, model_name
|
||||||
*/
|
*/
|
||||||
const getModelList: (
|
const getModelListPage: (
|
||||||
|
page: pageRequest,
|
||||||
data?: ListModelRequest,
|
data?: ListModelRequest,
|
||||||
loading?: Ref<boolean>,
|
loading?: Ref<boolean>,
|
||||||
) => Promise<Result<Array<Model>>> = (data, loading) => {
|
) => Promise<Result<Array<Model>>> = (page, data, loading) => {
|
||||||
return get(`${prefix}/model`, data, loading)
|
return get(`${prefix}/model/${page.current_page}/${page.page_size}`, data, loading)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -142,7 +144,7 @@ const deleteModel: (model_id: string, loading?: Ref<boolean>) => Promise<Result<
|
|||||||
return del(`${prefix}/model/${model_id}`, undefined, {}, loading)
|
return del(`${prefix}/model/${model_id}`, undefined, {}, loading)
|
||||||
}
|
}
|
||||||
export default {
|
export default {
|
||||||
getModelList,
|
getModelListPage,
|
||||||
createModel,
|
createModel,
|
||||||
updateModel,
|
updateModel,
|
||||||
deleteModel,
|
deleteModel,
|
||||||
|
|||||||
@ -113,17 +113,17 @@ const systemRouter = {
|
|||||||
},
|
},
|
||||||
component: () => import('@/views/system-resource-management/ToolResourceIndex.vue'),
|
component: () => import('@/views/system-resource-management/ToolResourceIndex.vue'),
|
||||||
},
|
},
|
||||||
// {
|
{
|
||||||
// path: '/system/resource-management/model',
|
path: '/system/resource-management/model',
|
||||||
// name: 'ModelResourceIndex',
|
name: 'ModelResourceIndex',
|
||||||
// meta: {
|
meta: {
|
||||||
// title: 'views.model.title',
|
title: 'views.model.title',
|
||||||
// activeMenu: '/system',
|
activeMenu: '/system',
|
||||||
// parentPath: '/system',
|
parentPath: '/system',
|
||||||
// parentName: 'system',
|
parentName: 'system',
|
||||||
// },
|
},
|
||||||
// component: () => import('@/views/system-resource-management/ModelResourceIndex.vue'),
|
component: () => import('@/views/system-resource-management/ModelResourceIndex.vue'),
|
||||||
// },
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
.complex-search {
|
.complex-search {
|
||||||
border: 1px solid var(--el-border-color);
|
border: 1px solid var(--el-border-color);
|
||||||
border-radius: var(--el-border-radius-base);
|
border-radius: var(--el-border-radius-base);
|
||||||
|
width: 350px;
|
||||||
.el-select__wrapper {
|
.el-select__wrapper {
|
||||||
box-shadow: none !important;
|
box-shadow: none !important;
|
||||||
border-radius: var(--el-border-radius-base) 0 0 var(--el-border-radius-base);
|
border-radius: var(--el-border-radius-base) 0 0 var(--el-border-radius-base);
|
||||||
|
|||||||
@ -38,8 +38,7 @@
|
|||||||
>{{ $t('views.model.modelForm.model_type.label') }}
|
>{{ $t('views.model.modelForm.model_type.label') }}
|
||||||
</el-text>
|
</el-text>
|
||||||
<span class="ellipsis ml-16">
|
<span class="ellipsis ml-16">
|
||||||
{{ $t(modelType[model.model_type as keyof typeof modelType]) }}</span
|
{{ $t(modelType[model.model_type as keyof typeof modelType]) }}</span>
|
||||||
>
|
|
||||||
</li>
|
</li>
|
||||||
<li class="flex">
|
<li class="flex">
|
||||||
<el-text type="info" class="color-secondary"
|
<el-text type="info" class="color-secondary"
|
||||||
|
|||||||
@ -115,7 +115,6 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onMounted, ref, computed } from 'vue'
|
import { onMounted, ref, computed } from 'vue'
|
||||||
import ProviderApi from '@/api/model/provider'
|
|
||||||
import type { Provider, Model } from '@/api/type/model'
|
import type { Provider, Model } from '@/api/type/model'
|
||||||
import ModelCard from '@/views/model/component/ModelCard.vue'
|
import ModelCard from '@/views/model/component/ModelCard.vue'
|
||||||
import ProviderComponent from '@/views/model/component/Provider.vue'
|
import ProviderComponent from '@/views/model/component/Provider.vue'
|
||||||
@ -123,13 +122,13 @@ import { splitArray } from '@/utils/common'
|
|||||||
import { modelTypeList, allObj } from '@/views/model/component/data'
|
import { modelTypeList, allObj } from '@/views/model/component/data'
|
||||||
import CreateModelDialog from '@/views/model/component/CreateModelDialog.vue'
|
import CreateModelDialog from '@/views/model/component/CreateModelDialog.vue'
|
||||||
import SelectProviderDialog from '@/views/model/component/SelectProviderDialog.vue'
|
import SelectProviderDialog from '@/views/model/component/SelectProviderDialog.vue'
|
||||||
import { t } from '@/locales'
|
|
||||||
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
|
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
|
||||||
|
import useStore from '@/stores'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import permissionMap from '@/permission'
|
import permissionMap from '@/permission'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
const { model } = useStore()
|
||||||
const apiType = computed(() => {
|
const apiType = computed(() => {
|
||||||
if (route.path.includes('shared')) {
|
if (route.path.includes('shared')) {
|
||||||
return 'systemShare'
|
return 'systemShare'
|
||||||
@ -217,7 +216,7 @@ const search_type_change = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
ProviderApi.getProvider(loading).then((ok) => {
|
model.asyncGetProvider(loading).then((ok: any) => {
|
||||||
active_provider.value = allObj
|
active_provider.value = allObj
|
||||||
provider_list.value = [allObj, ...ok.data]
|
provider_list.value = [allObj, ...ok.data]
|
||||||
list_model()
|
list_model()
|
||||||
|
|||||||
@ -47,23 +47,12 @@
|
|||||||
>
|
>
|
||||||
<!-- <el-table-column type="selection" width="55" /> -->
|
<!-- <el-table-column type="selection" width="55" /> -->
|
||||||
<el-table-column width="220" :label="$t('common.name')">
|
<el-table-column width="220" :label="$t('common.name')">
|
||||||
<template #default="scope">
|
<template #default="{ row }">
|
||||||
<div class="table-name flex align-center">
|
<div class="flex align-center">
|
||||||
<el-icon size="24" class="mr-8">
|
<KnowledgeIcon :type="row.type" />
|
||||||
<el-avatar
|
<span class="ml-8">
|
||||||
v-if="isAppIcon(scope.row?.icon)"
|
{{ row.name }}
|
||||||
shape="square"
|
</span>
|
||||||
:size="24"
|
|
||||||
style="background: none"
|
|
||||||
class="mr-8"
|
|
||||||
>
|
|
||||||
<img :src="scope.row?.icon" alt="" />
|
|
||||||
</el-avatar>
|
|
||||||
<el-avatar v-else class="avatar-green" shape="square" :size="24">
|
|
||||||
<img src="@/assets/node/icon_tool.svg" style="width: 58%" alt="" />
|
|
||||||
</el-avatar>
|
|
||||||
</el-icon>
|
|
||||||
{{ scope.row.name }}
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
<el-input
|
<el-input
|
||||||
v-if="search_type === 'name'"
|
v-if="search_type === 'name'"
|
||||||
v-model="model_search_form.name"
|
v-model="model_search_form.name"
|
||||||
@change="list_model"
|
@change="getList"
|
||||||
:placeholder="$t('common.searchBar.placeholder')"
|
:placeholder="$t('common.searchBar.placeholder')"
|
||||||
style="width: 220px"
|
style="width: 220px"
|
||||||
clearable
|
clearable
|
||||||
@ -30,7 +30,7 @@
|
|||||||
<el-select
|
<el-select
|
||||||
v-else-if="search_type === 'create_user'"
|
v-else-if="search_type === 'create_user'"
|
||||||
v-model="model_search_form.create_user"
|
v-model="model_search_form.create_user"
|
||||||
@change="list_model"
|
@change="getList"
|
||||||
clearable
|
clearable
|
||||||
style="width: 220px"
|
style="width: 220px"
|
||||||
>
|
>
|
||||||
@ -40,7 +40,7 @@
|
|||||||
v-else-if="search_type === 'model_type'"
|
v-else-if="search_type === 'model_type'"
|
||||||
v-model="model_search_form.model_type"
|
v-model="model_search_form.model_type"
|
||||||
clearable
|
clearable
|
||||||
@change="list_model"
|
@change="getList"
|
||||||
style="width: 220px"
|
style="width: 220px"
|
||||||
>
|
>
|
||||||
<template v-for="item in modelTypeList" :key="item.value">
|
<template v-for="item in modelTypeList" :key="item.value">
|
||||||
@ -51,47 +51,49 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<app-table
|
<app-table
|
||||||
:data="model_list"
|
:data="modelList"
|
||||||
:pagination-config="paginationConfig"
|
:pagination-config="paginationConfig"
|
||||||
|
@sizeChange="getList"
|
||||||
|
@changePage="getList"
|
||||||
>
|
>
|
||||||
<!-- <el-table-column type="selection" width="55" /> -->
|
<!-- <el-table-column type="selection" width="55" /> -->
|
||||||
<el-table-column width="220" :label="$t('common.name')">
|
<el-table-column width="220" :label="$t('common.name')">
|
||||||
<template #default="scope">
|
<template #default="{ row }">
|
||||||
<div class="table-name flex align-center">
|
{{ row.name }}
|
||||||
<el-icon size="24" class="mr-8">
|
</template>
|
||||||
<el-avatar
|
</el-table-column>
|
||||||
v-if="isAppIcon(scope.row?.icon)"
|
<el-table-column
|
||||||
shape="square"
|
prop="provider"
|
||||||
:size="24"
|
:label="$t('views.system.resource_management.type')"
|
||||||
style="background: none"
|
show-overflow-tooltip
|
||||||
class="mr-8"
|
width="150"
|
||||||
>
|
>
|
||||||
<img :src="scope.row?.icon" alt="" />
|
<template #default="{ row }">
|
||||||
</el-avatar>
|
<el-space :size="8">
|
||||||
<el-avatar v-else class="avatar-green" shape="square" :size="24">
|
<span
|
||||||
<img src="@/assets/node/icon_tool.svg" style="width: 58%" alt="" />
|
style="width: 24px; height: 24px; display: inline-block"
|
||||||
</el-avatar>
|
:innerHTML="getRowProvider(row)?.icon"
|
||||||
</el-icon>
|
>
|
||||||
{{ scope.row.name }}
|
</span>
|
||||||
</div>
|
<span> {{ getRowProvider(row)?.name }}</span>
|
||||||
|
</el-space>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column width="120" :label="$t('views.model.modelForm.model_type.label')">
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ $t(modelType[row.model_type as keyof typeof modelType]) }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
width="220"
|
||||||
|
:label="$t('views.model.modelForm.base_model.label')"
|
||||||
|
show-overflow-tooltip
|
||||||
|
>
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ row.model_name }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column prop="tool_type" :label="$t('views.system.resource_management.type')">
|
|
||||||
<template #default="scope">
|
|
||||||
{{ $t(ToolType[scope.row.tool_type as keyof typeof ToolType]) }}
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column :label="$t('common.status.label')" width="120">
|
|
||||||
<template #default="scope">
|
|
||||||
<div class="flex align-center">
|
|
||||||
<AppIcon
|
|
||||||
:iconName="scope.row.is_active ? 'app-close_colorful' : 'app-succeed'"
|
|
||||||
></AppIcon>
|
|
||||||
{{ $t(scope.row.is_active ? 'views.tool.enabled' : 'common.status.disable') }}
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column
|
<el-table-column
|
||||||
v-if="user.isEE()"
|
v-if="user.isEE()"
|
||||||
width="150"
|
width="150"
|
||||||
@ -163,19 +165,18 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onMounted, ref, reactive, computed } from 'vue'
|
import { onBeforeMount, onMounted, ref, reactive, nextTick, computed } from 'vue'
|
||||||
import { cloneDeep, get } from 'lodash'
|
import { cloneDeep, get } from 'lodash'
|
||||||
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, allObj } from '@/views/model/component/data'
|
import { modelTypeList } from '@/views/model/component/data'
|
||||||
|
import { modelType } from '@/enums/model'
|
||||||
import { t } from '@/locales'
|
import { t } from '@/locales'
|
||||||
import { isAppIcon } from '@/utils/common'
|
|
||||||
import { ToolType } from '@/enums/tool'
|
|
||||||
import useStore from '@/stores'
|
import useStore from '@/stores'
|
||||||
import WorkspaceApi from '@/api/workspace/workspace.ts'
|
import WorkspaceApi from '@/api/workspace/workspace.ts'
|
||||||
import { datetimeFormat } from '@/utils/time'
|
import { datetimeFormat } from '@/utils/time'
|
||||||
|
|
||||||
const { user } = 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<{
|
||||||
@ -190,8 +191,9 @@ const model_search_form = ref<{
|
|||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const changeStateloading = ref(false)
|
const changeStateloading = ref(false)
|
||||||
const model_list = ref<Array<Model>>([])
|
const modelList = ref<Array<Model>>([])
|
||||||
const user_options = ref<any[]>([])
|
const user_options = ref<any[]>([])
|
||||||
|
const provider_list = ref<Array<Provider>>([])
|
||||||
|
|
||||||
const paginationConfig = reactive({
|
const paginationConfig = reactive({
|
||||||
current_page: 1,
|
current_page: 1,
|
||||||
@ -202,11 +204,17 @@ const paginationConfig = reactive({
|
|||||||
const workspaceOptions = ref<any[]>([])
|
const workspaceOptions = ref<any[]>([])
|
||||||
const workspaceVisible = ref(false)
|
const workspaceVisible = ref(false)
|
||||||
const workspaceArr = ref<any[]>([])
|
const workspaceArr = ref<any[]>([])
|
||||||
|
|
||||||
|
const getRowProvider = computed(() => {
|
||||||
|
return (row: any) => {
|
||||||
|
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 = []
|
||||||
}
|
}
|
||||||
list_model()
|
getList()
|
||||||
workspaceVisible.value = false
|
workspaceVisible.value = false
|
||||||
}
|
}
|
||||||
async function getWorkspaceList() {
|
async function getWorkspaceList() {
|
||||||
@ -222,19 +230,24 @@ const search_type_change = () => {
|
|||||||
model_search_form.value = { name: '', create_user: '', model_type: '' }
|
model_search_form.value = { name: '', create_user: '', model_type: '' }
|
||||||
}
|
}
|
||||||
|
|
||||||
const list_model = () => {
|
function getList() {
|
||||||
ModelResourceApi.getModelList({ ...model_search_form.value }, loading).then((ok: any) => {
|
ModelResourceApi.getModelListPage(paginationConfig, model_search_form.value, loading).then(
|
||||||
model_list.value = ok.data
|
(res: any) => {
|
||||||
const v = model_list.value.map((m) => ({ id: m.user_id, username: m.username }))
|
paginationConfig.total = res.data?.total
|
||||||
if (user_options.value.length === 0) {
|
modelList.value = res.data?.records
|
||||||
user_options.value = Array.from(new Map(v.map((item) => [item.id, item])).values())
|
},
|
||||||
}
|
)
|
||||||
|
}
|
||||||
|
function getProvider() {
|
||||||
|
model.asyncGetProvider(loading).then((res: any) => {
|
||||||
|
provider_list.value = res?.data
|
||||||
|
getList()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getWorkspaceList()
|
getWorkspaceList()
|
||||||
// list_model()
|
getProvider()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -221,6 +221,5 @@ onMounted(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.resource-manage_tool {
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user