mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-27 20:42:52 +00:00
feat: add application management API and update ApplicationResourceIndex.vue
This commit is contained in:
parent
46b7e5c38f
commit
be759701cc
|
|
@ -0,0 +1,319 @@
|
|||
import {Result} from '@/request/Result'
|
||||
import {get, post, postStream, del, put, request, download, exportFile} from '@/request/index'
|
||||
import type {pageRequest} from '@/api/type/common'
|
||||
import type {ApplicationFormType} from '@/api/type/application'
|
||||
import {type Ref} from 'vue'
|
||||
import useStore from '@/stores'
|
||||
|
||||
const prefix = '/system/resource/application'
|
||||
|
||||
/**
|
||||
* 获取全部应用
|
||||
* @param 参数
|
||||
*/
|
||||
const getAllApplication: (param?: any, loading?: Ref<boolean>) => Promise<Result<any[]>> = (
|
||||
param,
|
||||
loading,
|
||||
) => {
|
||||
return get(`${prefix}`, param, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分页应用
|
||||
* param {
|
||||
"name": "string",
|
||||
}
|
||||
*/
|
||||
const getApplication: (
|
||||
page: pageRequest,
|
||||
param: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (page, param, loading) => {
|
||||
return get(`${prefix}/${page.current_page}/${page.page_size}`, param, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建应用
|
||||
* @param 参数
|
||||
*/
|
||||
const postApplication: (
|
||||
data: ApplicationFormType,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (data, loading) => {
|
||||
return post(`${prefix}`, data, undefined, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改应用
|
||||
* @param 参数
|
||||
*/
|
||||
const putApplication: (
|
||||
application_id: string,
|
||||
data: ApplicationFormType,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (application_id, data, loading) => {
|
||||
return put(`${prefix}/${application_id}`, data, undefined, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除应用
|
||||
* @param 参数 application_id
|
||||
*/
|
||||
const delApplication: (
|
||||
application_id: string,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<boolean>> = (application_id, loading) => {
|
||||
return del(`${prefix}/${application_id}`, undefined, {}, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 应用详情
|
||||
* @param 参数 application_id
|
||||
*/
|
||||
const getApplicationDetail: (
|
||||
application_id: string,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (application_id, loading) => {
|
||||
return get(`${prefix}/${application_id}`, undefined, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取AccessToken
|
||||
* @param 参数 application_id
|
||||
*/
|
||||
const getAccessToken: (application_id: string, loading?: Ref<boolean>) => Promise<Result<any>> = (
|
||||
application_id,
|
||||
loading,
|
||||
) => {
|
||||
return get(`${prefix}/${application_id}/access_token`, undefined, loading)
|
||||
}
|
||||
/**
|
||||
* 获取应用设置
|
||||
* @param application_id 应用id
|
||||
* @param loading 加载器
|
||||
* @returns
|
||||
*/
|
||||
const getApplicationSetting: (
|
||||
application_id: string,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (application_id, loading) => {
|
||||
return get(`${prefix}/${application_id}/setting`, undefined, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改AccessToken
|
||||
* @param 参数 application_id
|
||||
* data {
|
||||
* "is_active": true
|
||||
* }
|
||||
*/
|
||||
const putAccessToken: (
|
||||
application_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (application_id, data, loading) => {
|
||||
return put(`${prefix}/${application_id}/access_token`, data, undefined, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出应用
|
||||
*/
|
||||
|
||||
const exportApplication = (
|
||||
application_id: string,
|
||||
application_name: string,
|
||||
loading?: Ref<boolean>,
|
||||
) => {
|
||||
return exportFile(
|
||||
application_name + '.mk',
|
||||
`${prefix}/${application_id}/export`,
|
||||
undefined,
|
||||
loading,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入应用
|
||||
*/
|
||||
const importApplication: (data: any, loading?: Ref<boolean>) => Promise<Result<any>> = (
|
||||
data,
|
||||
loading,
|
||||
) => {
|
||||
return post(`${prefix}/import`, data, undefined, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计
|
||||
* @param 参数 application_id, data
|
||||
*/
|
||||
const getStatistics: (
|
||||
application_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (application_id, data, loading) => {
|
||||
return get(`${prefix}/${application_id}/application_stats`, data, loading)
|
||||
}
|
||||
/**
|
||||
* 打开调试对话id
|
||||
* @param application_id 应用id
|
||||
* @param loading 加载器
|
||||
* @returns
|
||||
*/
|
||||
const open: (application_id: string, loading?: Ref<boolean>) => Promise<Result<string>> = (
|
||||
application_id,
|
||||
loading,
|
||||
) => {
|
||||
return get(`${prefix}/${application_id}/open`, {}, loading)
|
||||
}
|
||||
/**
|
||||
* 对话
|
||||
* @param 参数
|
||||
* chat_id: string
|
||||
* data
|
||||
*/
|
||||
const chat: (chat_id: string, data: any) => Promise<any> = (chat_id, data) => {
|
||||
const prefix = (window.MaxKB?.prefix ? window.MaxKB?.prefix : '/admin') + '/api'
|
||||
return postStream(`${prefix}/chat_message/${chat_id}`, data)
|
||||
}
|
||||
/**
|
||||
* 获取对话用户认证类型
|
||||
* @param loading 加载器
|
||||
* @returns
|
||||
*/
|
||||
const getChatUserAuthType: (loading?: Ref<boolean>) => Promise<any> = (loading) => {
|
||||
return get(`/chat_user/auth/types`, {}, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取平台状态
|
||||
*/
|
||||
const getPlatformStatus: (application_id: string) => Promise<Result<any>> = (application_id) => {
|
||||
return get(`${prefix}/${application_id}/platform/status`)
|
||||
}
|
||||
/**
|
||||
* 更新平台状态
|
||||
*/
|
||||
const updatePlatformStatus: (application_id: string, data: any) => Promise<Result<any>> = (
|
||||
application_id,
|
||||
data,
|
||||
) => {
|
||||
return post(`${prefix}/${application_id}/platform/status`, data)
|
||||
}
|
||||
/**
|
||||
* 获取平台配置
|
||||
*/
|
||||
const getPlatformConfig: (application_id: string, type: string) => Promise<Result<any>> = (
|
||||
application_id,
|
||||
type,
|
||||
) => {
|
||||
return get(`${prefix}/${application_id}/platform/${type}`)
|
||||
}
|
||||
/**
|
||||
* 更新平台配置
|
||||
*/
|
||||
const updatePlatformConfig: (
|
||||
application_id: string,
|
||||
type: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (application_id, type, data, loading) => {
|
||||
return post(`${prefix}/${application_id}/platform/${type}`, data, undefined, loading)
|
||||
}
|
||||
/**
|
||||
* 应用发布
|
||||
* @param application_id
|
||||
* @param loading
|
||||
* @returns
|
||||
*/
|
||||
const publish: (
|
||||
application_id: string,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (application_id, data, loading) => {
|
||||
return put(`${prefix}/${application_id}/publish`, data, {}, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param application_id
|
||||
* @param data
|
||||
* @param loading
|
||||
* @returns
|
||||
*/
|
||||
const playDemoText: (application_id: string, data: any, loading?: Ref<boolean>) => Promise<any> = (
|
||||
application_id,
|
||||
data,
|
||||
loading,
|
||||
) => {
|
||||
return download(
|
||||
`${prefix}/${application_id}/play_demo_text`,
|
||||
'post',
|
||||
data,
|
||||
undefined,
|
||||
loading,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 文本转语音
|
||||
*/
|
||||
const postTextToSpeech: (
|
||||
application_id: String,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (application_id, data, loading) => {
|
||||
return download(
|
||||
`${prefix}/${application_id}/text_to_speech`,
|
||||
'post',
|
||||
data,
|
||||
undefined,
|
||||
loading,
|
||||
)
|
||||
}
|
||||
/**
|
||||
* 语音转文本
|
||||
*/
|
||||
const speechToText: (
|
||||
application_id: String,
|
||||
data: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (application_id, data, loading) => {
|
||||
return post(`${prefix}/${application_id}/speech_to_text`, data, undefined, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* mcp 节点
|
||||
*/
|
||||
const getMcpTools: (application_id: String, loading?: Ref<boolean>) => Promise<Result<any>> = (
|
||||
application_id,
|
||||
loading,
|
||||
) => {
|
||||
return get(`${prefix}/${application_id}/mcp_tools`, undefined, loading)
|
||||
}
|
||||
|
||||
export default {
|
||||
getAllApplication,
|
||||
getApplication,
|
||||
postApplication,
|
||||
putApplication,
|
||||
delApplication,
|
||||
getApplicationDetail,
|
||||
getAccessToken,
|
||||
putAccessToken,
|
||||
exportApplication,
|
||||
importApplication,
|
||||
getStatistics,
|
||||
open,
|
||||
chat,
|
||||
getChatUserAuthType,
|
||||
getApplicationSetting,
|
||||
getPlatformStatus,
|
||||
updatePlatformStatus,
|
||||
getPlatformConfig,
|
||||
publish,
|
||||
updatePlatformConfig,
|
||||
playDemoText,
|
||||
postTextToSpeech,
|
||||
speechToText,
|
||||
getMcpTools,
|
||||
}
|
||||
|
|
@ -225,4 +225,5 @@ export default {
|
|||
emptyMessage1: 'Retrieval Testing results will show here',
|
||||
emptyMessage2: 'No matching sections found',
|
||||
},
|
||||
publishTime: 'Publish Time',
|
||||
}
|
||||
|
|
|
|||
|
|
@ -211,4 +211,5 @@ export default {
|
|||
emptyMessage1: '命中段落显示在这里',
|
||||
emptyMessage2: '没有命中的分段',
|
||||
},
|
||||
publishTime: '发布时间',
|
||||
}
|
||||
|
|
|
|||
|
|
@ -211,4 +211,5 @@ export default {
|
|||
emptyMessage1: '命中的段落顯示在這裡',
|
||||
emptyMessage2: '沒有命中的分段',
|
||||
},
|
||||
publishTime: '發佈時間',
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { PermissionConst, EditionConst, RoleConst } from '@/utils/permission/data'
|
||||
import { ComplexPermission } from '@/utils/permission/type'
|
||||
import {PermissionConst, EditionConst, RoleConst} from '@/utils/permission/data'
|
||||
import {ComplexPermission} from '@/utils/permission/type'
|
||||
|
||||
const systemRouter = {
|
||||
path: '/system',
|
||||
name: 'system',
|
||||
meta: { title: 'views.system.title' },
|
||||
meta: {title: 'views.system.title'},
|
||||
hidden: true,
|
||||
component: () => import('@/layout/layout-template/SystemMainLayout.vue'),
|
||||
children: [
|
||||
|
|
@ -78,6 +78,12 @@ const systemRouter = {
|
|||
parentPath: '/system',
|
||||
parentName: 'system',
|
||||
permission: [
|
||||
new ComplexPermission(
|
||||
[RoleConst.ADMIN],
|
||||
[PermissionConst.RESOURCE_APPLICATION_READ],
|
||||
[EditionConst.IS_EE],
|
||||
'OR',
|
||||
),
|
||||
new ComplexPermission(
|
||||
[RoleConst.ADMIN],
|
||||
[PermissionConst.RESOURCE_KNOWLEDGE_READ],
|
||||
|
|
@ -99,6 +105,26 @@ const systemRouter = {
|
|||
],
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: '/system/resource-management/application',
|
||||
name: 'ApplicationResourceIndex',
|
||||
meta: {
|
||||
title: 'views.application.title',
|
||||
activeMenu: '/system',
|
||||
parentPath: '/system',
|
||||
parentName: 'system',
|
||||
sameRoute: 'workspace',
|
||||
permission: [
|
||||
new ComplexPermission(
|
||||
[RoleConst.ADMIN],
|
||||
[PermissionConst.RESOURCE_APPLICATION_READ],
|
||||
[EditionConst.IS_EE],
|
||||
'OR',
|
||||
),
|
||||
],
|
||||
},
|
||||
component: () => import('@/views/system-resource-management/ApplicationResourceIndex.vue'),
|
||||
},
|
||||
{
|
||||
path: '/system/resource-management/knowledge',
|
||||
name: 'KnowledgeResourceIndex',
|
||||
|
|
@ -172,18 +198,18 @@ const systemRouter = {
|
|||
parentName: 'system',
|
||||
sameRoute: 'authorization',
|
||||
permission: [new ComplexPermission([RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
|
||||
[PermissionConst.APPLICATION_WORKSPACE_USER_RESOURCE_PERMISSION_READ,
|
||||
PermissionConst.APPLICATION_WORKSPACE_USER_RESOURCE_PERMISSION_READ.getWorkspacePermissionWorkspaceManageRole],[],'OR'),
|
||||
new ComplexPermission([RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
|
||||
[PermissionConst.KNOWLEDGE_WORKSPACE_USER_RESOURCE_PERMISSION_READ,
|
||||
PermissionConst.KNOWLEDGE_WORKSPACE_USER_RESOURCE_PERMISSION_READ.getWorkspacePermissionWorkspaceManageRole],[],'OR'),
|
||||
new ComplexPermission([RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
|
||||
[PermissionConst.TOOL_WORKSPACE_USER_RESOURCE_PERMISSION_READ,
|
||||
PermissionConst.TOOL_WORKSPACE_USER_RESOURCE_PERMISSION_READ.getWorkspacePermissionWorkspaceManageRole],[],'OR'),
|
||||
new ComplexPermission([RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
|
||||
[PermissionConst.MODEL_WORKSPACE_USER_RESOURCE_PERMISSION_READ,
|
||||
PermissionConst.MODEL_WORKSPACE_USER_RESOURCE_PERMISSION_READ.getWorkspacePermissionWorkspaceManageRole],[],'OR'),
|
||||
],
|
||||
[PermissionConst.APPLICATION_WORKSPACE_USER_RESOURCE_PERMISSION_READ,
|
||||
PermissionConst.APPLICATION_WORKSPACE_USER_RESOURCE_PERMISSION_READ.getWorkspacePermissionWorkspaceManageRole], [], 'OR'),
|
||||
new ComplexPermission([RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
|
||||
[PermissionConst.KNOWLEDGE_WORKSPACE_USER_RESOURCE_PERMISSION_READ,
|
||||
PermissionConst.KNOWLEDGE_WORKSPACE_USER_RESOURCE_PERMISSION_READ.getWorkspacePermissionWorkspaceManageRole], [], 'OR'),
|
||||
new ComplexPermission([RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
|
||||
[PermissionConst.TOOL_WORKSPACE_USER_RESOURCE_PERMISSION_READ,
|
||||
PermissionConst.TOOL_WORKSPACE_USER_RESOURCE_PERMISSION_READ.getWorkspacePermissionWorkspaceManageRole], [], 'OR'),
|
||||
new ComplexPermission([RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
|
||||
[PermissionConst.MODEL_WORKSPACE_USER_RESOURCE_PERMISSION_READ,
|
||||
PermissionConst.MODEL_WORKSPACE_USER_RESOURCE_PERMISSION_READ.getWorkspacePermissionWorkspaceManageRole], [], 'OR'),
|
||||
],
|
||||
},
|
||||
|
||||
children: [
|
||||
|
|
@ -199,7 +225,7 @@ const systemRouter = {
|
|||
sameRoute: 'authorization',
|
||||
permission: [new ComplexPermission([RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
|
||||
[PermissionConst.APPLICATION_WORKSPACE_USER_RESOURCE_PERMISSION_READ,
|
||||
PermissionConst.APPLICATION_WORKSPACE_USER_RESOURCE_PERMISSION_READ.getWorkspacePermissionWorkspaceManageRole],[],'OR'),]
|
||||
PermissionConst.APPLICATION_WORKSPACE_USER_RESOURCE_PERMISSION_READ.getWorkspacePermissionWorkspaceManageRole], [], 'OR'),]
|
||||
},
|
||||
component: () => import('@/views/system/resource-authorization/index.vue'),
|
||||
},
|
||||
|
|
@ -215,7 +241,7 @@ const systemRouter = {
|
|||
sameRoute: 'authorization',
|
||||
permission: [new ComplexPermission([RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
|
||||
[PermissionConst.KNOWLEDGE_WORKSPACE_USER_RESOURCE_PERMISSION_READ,
|
||||
PermissionConst.KNOWLEDGE_WORKSPACE_USER_RESOURCE_PERMISSION_READ.getWorkspacePermissionWorkspaceManageRole],[],'OR'),]
|
||||
PermissionConst.KNOWLEDGE_WORKSPACE_USER_RESOURCE_PERMISSION_READ.getWorkspacePermissionWorkspaceManageRole], [], 'OR'),]
|
||||
},
|
||||
component: () => import('@/views/system/resource-authorization/index.vue'),
|
||||
},
|
||||
|
|
@ -231,7 +257,7 @@ const systemRouter = {
|
|||
sameRoute: 'authorization',
|
||||
permission: [new ComplexPermission([RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
|
||||
[PermissionConst.TOOL_WORKSPACE_USER_RESOURCE_PERMISSION_READ,
|
||||
PermissionConst.TOOL_WORKSPACE_USER_RESOURCE_PERMISSION_READ.getWorkspacePermissionWorkspaceManageRole],[],'OR'),]
|
||||
PermissionConst.TOOL_WORKSPACE_USER_RESOURCE_PERMISSION_READ.getWorkspacePermissionWorkspaceManageRole], [], 'OR'),]
|
||||
},
|
||||
component: () => import('@/views/system/resource-authorization/index.vue'),
|
||||
},
|
||||
|
|
@ -247,7 +273,7 @@ const systemRouter = {
|
|||
sameRoute: 'authorization',
|
||||
permission: [new ComplexPermission([RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
|
||||
[PermissionConst.MODEL_WORKSPACE_USER_RESOURCE_PERMISSION_READ,
|
||||
PermissionConst.MODEL_WORKSPACE_USER_RESOURCE_PERMISSION_READ.getWorkspacePermissionWorkspaceManageRole],[],'OR'),]
|
||||
PermissionConst.MODEL_WORKSPACE_USER_RESOURCE_PERMISSION_READ.getWorkspacePermissionWorkspaceManageRole], [], 'OR'),]
|
||||
},
|
||||
component: () => import('@/views/system/resource-authorization/index.vue'),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Permission, Role, Edition } from '@/utils/permission/type'
|
||||
import {Permission, Role, Edition} from '@/utils/permission/type'
|
||||
// class Operate(Enum):
|
||||
// """
|
||||
// 一个权限组的操作权限
|
||||
|
|
@ -195,7 +195,7 @@ const PermissionConst = {
|
|||
SHARED_KNOWLEDGE_PROBLEM_CREATE: new Permission('SYSTEM_KNOWLEDGE_PROBLEM:READ+CREATE'),
|
||||
SHARED_KNOWLEDGE_PROBLEM_EDIT: new Permission('SYSTEM_KNOWLEDGE_PROBLEM:READ+EDIT'),
|
||||
SHARED_KNOWLEDGE_PROBLEM_DELETE: new Permission('SYSTEM_KNOWLEDGE_PROBLEM:READ+DELETE'),
|
||||
|
||||
|
||||
SHARED_KNOWLEDGE_HIT_TEST_READ: new Permission('SYSTEM_KNOWLEDGE_HIT_TEST:READ'),
|
||||
KNOWLEDGE_HIT_TEST_READ: new Permission('KNOWLEDGE_HIT_TEST:READ'),
|
||||
|
||||
|
|
@ -219,6 +219,7 @@ const PermissionConst = {
|
|||
RESOURCE_TOOL_EXPORT: new Permission('SYSTEM_RESOURCE_TOOL:READ+EXPORT'),
|
||||
|
||||
RESOURCE_KNOWLEDGE_READ: new Permission('SYSTEM_RESOURCE_KNOWLEDGE:READ'),
|
||||
RESOURCE_APPLICATION_READ: new Permission('SYSTEM_RESOURCE_APPLICATION:READ'),
|
||||
|
||||
RESOURCE_MODEL_READ: new Permission('SYSTEM_RESOURCE_MODEL:READ'),
|
||||
|
||||
|
|
@ -277,4 +278,4 @@ const EditionConst = {
|
|||
IS_EE: new Edition('X-PACK-EE'),
|
||||
IS_CE: new Edition('X-PACK-CE'),
|
||||
}
|
||||
export { PermissionConst, RoleConst, EditionConst }
|
||||
export {PermissionConst, RoleConst, EditionConst}
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@
|
|||
style="width: 120px"
|
||||
@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('common.name')" value="name" />
|
||||
<el-option :label="$t('common.name')" value="name"/>
|
||||
</el-select>
|
||||
<el-input
|
||||
v-if="search_type === 'name'"
|
||||
|
|
@ -34,13 +34,13 @@
|
|||
clearable
|
||||
style="width: 220px"
|
||||
>
|
||||
<el-option v-for="u in user_options" :key="u.id" :value="u.id" :label="u.nick_name" />
|
||||
<el-option v-for="u in user_options" :key="u.id" :value="u.id" :label="u.username"/>
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<app-table
|
||||
:data="knowledgeList"
|
||||
:data="applicationList"
|
||||
:pagination-config="paginationConfig"
|
||||
@sizeChange="getList"
|
||||
@changePage="getList"
|
||||
|
|
@ -57,10 +57,10 @@
|
|||
style="background: none"
|
||||
class="mr-8"
|
||||
>
|
||||
<img :src="scope.row?.icon" alt="" />
|
||||
<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="" />
|
||||
<img src="@/assets/node/icon_tool.svg" style="width: 58%" alt=""/>
|
||||
</el-avatar>
|
||||
</el-icon>
|
||||
{{ scope.row.name }}
|
||||
|
|
@ -71,16 +71,84 @@
|
|||
<el-table-column
|
||||
prop="tool_type"
|
||||
:label="$t('views.system.resource_management.type')"
|
||||
width="110"
|
||||
width="160"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.type === 1">{{
|
||||
$t('views.knowledge.knowledgeType.webKnowledge')
|
||||
}}</span>
|
||||
<span v-else-if="row.type === 2">{{
|
||||
$t('views.knowledge.knowledgeType.larkKnowledge')
|
||||
}}</span>
|
||||
<span v-else>{{ $t('views.knowledge.knowledgeType.generalKnowledge') }}</span>
|
||||
<template #default="scope">
|
||||
<el-tag type="warning" v-if="isWorkFlow(scope.row.type)" style="height: 22px">
|
||||
{{ $t('views.application.workflow') }}
|
||||
</el-tag>
|
||||
<el-tag class="blue-tag" v-else style="height: 22px">
|
||||
{{ $t('views.application.simple') }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
width="150"
|
||||
prop="is_publish"
|
||||
:label="$t('common.status.label')"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #header>
|
||||
<div>
|
||||
<span>{{ $t('common.status.label') }}</span>
|
||||
<el-popover :width="200" trigger="click" :visible="statusVisible">
|
||||
<template #reference>
|
||||
<el-button
|
||||
style="margin-top: -2px"
|
||||
:type="statusArr && statusArr.length > 0 ? 'primary' : ''"
|
||||
link
|
||||
@click="statusVisible = !statusVisible"
|
||||
>
|
||||
<el-icon>
|
||||
<Filter/>
|
||||
</el-icon>
|
||||
</el-button>
|
||||
</template>
|
||||
<div class="filter">
|
||||
<div class="form-item mb-16">
|
||||
<div @click.stop>
|
||||
<el-scrollbar height="300" style="margin: 0 0 0 10px">
|
||||
<el-checkbox-group
|
||||
v-model="statusArr"
|
||||
style="display: flex; flex-direction: column"
|
||||
>
|
||||
<el-checkbox
|
||||
v-for="item in statusOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-checkbox-group>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<el-button size="small" @click="filterStatusChange('clear')"
|
||||
>{{ $t('common.clear') }}
|
||||
</el-button>
|
||||
<el-button type="primary" @click="filterStatusChange" size="small"
|
||||
>{{ $t('common.confirm') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</el-popover>
|
||||
</div>
|
||||
</template>
|
||||
<template #default="scope">
|
||||
<div v-if="scope.row.is_publish" class="flex align-center">
|
||||
<el-icon class="color-success mr-8" style="font-size: 16px">
|
||||
<SuccessFilled/>
|
||||
</el-icon>
|
||||
<span class="color-secondary">
|
||||
{{ $t('views.application.status.published') }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-else class="flex align-center">
|
||||
<AppIcon iconName="app-disabled" class="color-secondary mr-8"></AppIcon>
|
||||
<span class="color-secondary">
|
||||
{{ $t('views.application.status.unpublished') }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
|
|
@ -102,7 +170,7 @@
|
|||
@click="workspaceVisible = !workspaceVisible"
|
||||
>
|
||||
<el-icon>
|
||||
<Filter />
|
||||
<Filter/>
|
||||
</el-icon>
|
||||
</el-button>
|
||||
</template>
|
||||
|
|
@ -127,23 +195,30 @@
|
|||
</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 :label="$t('views.document.table.updateTime')" width="180">
|
||||
|
||||
<el-table-column prop="nick_name" :label="$t('common.creator')" show-overflow-tooltip
|
||||
width="120"/>
|
||||
<el-table-column :label="$t('views.application.publishTime')" width="120">
|
||||
<template #default="{ row }">
|
||||
{{ datetimeFormat(row.update_time) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('common.createTime')" width="180">
|
||||
<el-table-column :label="$t('views.document.table.updateTime')" width="120">
|
||||
<template #default="{ row }">
|
||||
{{ datetimeFormat(row.update_time) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('common.createTime')" width="120">
|
||||
<template #default="{ row }">
|
||||
{{ datetimeFormat(row.create_time) }}
|
||||
</template>
|
||||
|
|
@ -154,16 +229,16 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, ref, reactive, computed } from 'vue'
|
||||
import KnowledgeResourceApi from '@/api/system-resource-management/knowledge'
|
||||
import { t } from '@/locales'
|
||||
import { isAppIcon } from '@/utils/common'
|
||||
import {onMounted, ref, reactive, computed} from 'vue'
|
||||
import ApplicationResourceApi from '@/api/system-resource-management/application'
|
||||
import {t} from '@/locales'
|
||||
import {isAppIcon} from '@/utils/common'
|
||||
import useStore from '@/stores'
|
||||
import { datetimeFormat } from '@/utils/time'
|
||||
import {datetimeFormat} from '@/utils/time'
|
||||
import {loadPermissionApi} from "@/utils/dynamics-api/permission-api.ts";
|
||||
import UserApi from '@/api/user/user.ts'
|
||||
import {isWorkFlow} from "@/utils/application.ts";
|
||||
|
||||
const { user } = useStore()
|
||||
const {user} = useStore()
|
||||
|
||||
const search_type = ref('name')
|
||||
const search_form = ref<any>({
|
||||
|
|
@ -174,7 +249,7 @@ const user_options = ref<any[]>([])
|
|||
|
||||
const loading = ref(false)
|
||||
const changeStateloading = ref(false)
|
||||
const knowledgeList = ref<any[]>([])
|
||||
const applicationList = ref<any[]>([])
|
||||
const paginationConfig = reactive({
|
||||
current_page: 1,
|
||||
page_size: 30,
|
||||
|
|
@ -183,6 +258,16 @@ const paginationConfig = reactive({
|
|||
const workspaceOptions = ref<any[]>([])
|
||||
const workspaceVisible = ref(false)
|
||||
const workspaceArr = ref<any[]>([])
|
||||
const statusVisible = ref(false)
|
||||
const statusArr = ref<any[]>([])
|
||||
const statusOptions = ref<any[]>([{
|
||||
label: t('views.application.status.published'),
|
||||
value: true,
|
||||
}, {
|
||||
label: t('views.application.status.unpublished'),
|
||||
value: false,
|
||||
}])
|
||||
|
||||
function filterWorkspaceChange(val: string) {
|
||||
if (val === 'clear') {
|
||||
workspaceArr.value = []
|
||||
|
|
@ -190,6 +275,15 @@ function filterWorkspaceChange(val: string) {
|
|||
getList()
|
||||
workspaceVisible.value = false
|
||||
}
|
||||
|
||||
function filterStatusChange(val: string) {
|
||||
if (val === 'clear') {
|
||||
statusArr.value = []
|
||||
}
|
||||
getList()
|
||||
statusVisible.value = false
|
||||
}
|
||||
|
||||
async function getWorkspaceList() {
|
||||
if (user.isEE()) {
|
||||
const res = await loadPermissionApi('workspace').getSystemWorkspaceList(loading)
|
||||
|
|
@ -199,27 +293,30 @@ async function getWorkspaceList() {
|
|||
}))
|
||||
}
|
||||
}
|
||||
|
||||
const search_type_change = () => {
|
||||
search_form.value = { name: '', create_user: '' }
|
||||
search_form.value = {name: '', create_user: ''}
|
||||
}
|
||||
|
||||
function getList() {
|
||||
const params = {
|
||||
[search_type.value]: search_form.value[search_type.value],
|
||||
}
|
||||
KnowledgeResourceApi.getKnowledgeListPage(paginationConfig, params, loading).then((res: any) => {
|
||||
if (workspaceArr.value.length > 0) {
|
||||
params['workspace_ids'] = JSON.stringify(workspaceArr.value)
|
||||
}
|
||||
if (statusArr.value.length > 0) {
|
||||
params['status'] = JSON.stringify(statusArr.value)
|
||||
}
|
||||
ApplicationResourceApi.getApplication(paginationConfig, params, loading).then((res: any) => {
|
||||
paginationConfig.total = res.data?.total
|
||||
knowledgeList.value = res.data?.records
|
||||
applicationList.value = res.data?.records
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getWorkspaceList()
|
||||
getList()
|
||||
|
||||
UserApi.getAllMemberList('').then((res: any) => {
|
||||
user_options.value = res.data
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue