mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 09:54:54 +00:00
feat: share api
This commit is contained in:
parent
521fff2818
commit
92df83771e
|
|
@ -33,6 +33,76 @@ const getKnowledgeListPage: (
|
|||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 知识库详情
|
||||
* @param 参数 knowledge_id
|
||||
*/
|
||||
const getKnowledgeDetail: (knowledge_id: string, loading?: Ref<boolean>) => Promise<Result<any>> = (
|
||||
knowledge_id,
|
||||
loading,
|
||||
) => {
|
||||
return get(`${prefix}/${prefix_workspace.value}/knowledge/${knowledge_id}`, undefined, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 文档分页列表
|
||||
* @param 参数 knowledge_id,
|
||||
* param {
|
||||
"name": "string",
|
||||
folder_id: "string",
|
||||
}
|
||||
*/
|
||||
|
||||
const getDocumentPage: (
|
||||
knowledge_id: string,
|
||||
page: pageRequest,
|
||||
param: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (knowledge_id, page, param, loading) => {
|
||||
return get(
|
||||
`${prefix}/${prefix_workspace.value}/knowledge/${knowledge_id}/document/${page.current_page}/${page.page_size}`,
|
||||
param,
|
||||
loading,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 文档详情
|
||||
* @param 参数 knowledge_id
|
||||
*/
|
||||
const getDocumentDetail: (
|
||||
knowledge_id: string,
|
||||
document_id: string,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (knowledge_id, document_id, loading) => {
|
||||
return get(`${prefix}/${prefix_workspace.value}/knowledge/${knowledge_id}/document/${document_id}`,
|
||||
{},
|
||||
loading,)
|
||||
}
|
||||
|
||||
/**
|
||||
* 段落分页列表
|
||||
* @param 参数 knowledge_id document_id
|
||||
* param {
|
||||
"title": "string",
|
||||
"content": "string",
|
||||
}
|
||||
*/
|
||||
const getParagraphPage: (
|
||||
knowledge_id: string,
|
||||
document_id: string,
|
||||
page: pageRequest,
|
||||
param: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (knowledge_id, document_id, page, param, loading) => {
|
||||
return get(
|
||||
`${prefix}/${prefix_workspace.value}/knowledge/${knowledge_id}/document/${document_id}/paragraph/${page.current_page}/${page.page_size}`,
|
||||
param,
|
||||
loading,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
const getModelList: (
|
||||
param: any,
|
||||
loading?: Ref<boolean>,
|
||||
|
|
@ -57,6 +127,10 @@ const getToolListPage: (
|
|||
export default {
|
||||
getKnowledgeList,
|
||||
getKnowledgeListPage,
|
||||
getKnowledgeDetail,
|
||||
getDocumentPage,
|
||||
getDocumentDetail,
|
||||
getParagraphPage,
|
||||
getModelList,
|
||||
getToolList,
|
||||
getToolListPage
|
||||
|
|
|
|||
|
|
@ -1,66 +0,0 @@
|
|||
import { Result } from '@/request/Result'
|
||||
import { get, post, del, put, exportFile, exportExcel } from '@/request/index'
|
||||
import { type Ref } from 'vue'
|
||||
import type { pageRequest } from '@/api/type/common'
|
||||
import type { knowledgeData } from '@/api/type/knowledge'
|
||||
|
||||
import useStore from '@/stores'
|
||||
const prefix: any = { _value: '/system/shared/knowledge/' }
|
||||
Object.defineProperty(prefix, 'value', {
|
||||
get: function () {
|
||||
const { user } = useStore()
|
||||
return this._value + user.getWorkspaceId()
|
||||
},
|
||||
})
|
||||
|
||||
/**
|
||||
* 知识库列表(无分页)
|
||||
* @param 参数
|
||||
* param {
|
||||
folder_id: "string",
|
||||
name: "string",
|
||||
tool_type: "string",
|
||||
desc: string,
|
||||
}
|
||||
*/
|
||||
const getKnowledgeList: (param?: any, loading?: Ref<boolean>) => Promise<Result<any>> = (
|
||||
param,
|
||||
loading,
|
||||
) => {
|
||||
return get(`${prefix.value}`, param, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 知识库分页列表
|
||||
* @param 参数
|
||||
* param {
|
||||
"folder_id": "string",
|
||||
"name": "string",
|
||||
"tool_type": "string",
|
||||
desc: string,
|
||||
}
|
||||
*/
|
||||
const getKnowledgeListPage: (
|
||||
page: pageRequest,
|
||||
param?: any,
|
||||
loading?: Ref<boolean>,
|
||||
) => Promise<Result<any>> = (page, param, loading) => {
|
||||
return get(`${prefix.value}/${page.current_page}/${page.page_size}`, param, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 知识库详情
|
||||
* @param 参数 knowledge_id
|
||||
*/
|
||||
const getKnowledgeDetail: (knowledge_id: string, loading?: Ref<boolean>) => Promise<Result<any>> = (
|
||||
knowledge_id,
|
||||
loading,
|
||||
) => {
|
||||
return get(`${prefix.value}/${knowledge_id}`, undefined, loading)
|
||||
}
|
||||
|
||||
export default {
|
||||
getKnowledgeList,
|
||||
getKnowledgeListPage,
|
||||
getKnowledgeDetail,
|
||||
}
|
||||
|
|
@ -35,7 +35,8 @@ const route = useRoute()
|
|||
|
||||
const {
|
||||
meta: { activeMenu },
|
||||
params: { id },
|
||||
params: { id, folderId },
|
||||
query: { isShared },
|
||||
} = route as any
|
||||
|
||||
const apiType = computed(() => {
|
||||
|
|
@ -48,6 +49,10 @@ const apiType = computed(() => {
|
|||
}
|
||||
})
|
||||
|
||||
const shareDisabled = computed(() => {
|
||||
return folderId === 'share' || isShared === 'true'
|
||||
})
|
||||
|
||||
onBeforeRouteLeave((to, from) => {
|
||||
common.saveBreadcrumb(null)
|
||||
})
|
||||
|
|
@ -75,7 +80,7 @@ const toBackPath = computed(() => {
|
|||
|
||||
function getKnowledgeDetail() {
|
||||
loading.value = true
|
||||
loadSharedApi({ type: 'knowledge', systemType: apiType.value })
|
||||
loadSharedApi({ type: 'knowledge', isShared: shareDisabled.value, systemType: apiType.value })
|
||||
.getKnowledgeDetail(id)
|
||||
.then((res: any) => {
|
||||
current.value = res.data
|
||||
|
|
|
|||
|
|
@ -218,6 +218,9 @@ h5 {
|
|||
.p-8-12 {
|
||||
padding: calc(var(--app-base-px)) calc(var(--app-base-px) + 4px);
|
||||
}
|
||||
.p-8-16 {
|
||||
padding: calc(var(--app-base-px)) calc(var(--app-base-px) * 2);
|
||||
}
|
||||
.p-12-16 {
|
||||
padding: calc(var(--app-base-px) + 4px) calc(var(--app-base-px) * 2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1066,7 +1066,7 @@ function getList(bool?: boolean) {
|
|||
}
|
||||
|
||||
function getDetail() {
|
||||
loadSharedApi({ type: 'knowledge', systemType: apiType.value })
|
||||
loadSharedApi({ type: 'knowledge', isShared: isShared.value, systemType: apiType.value })
|
||||
.getKnowledgeDetail(id, loading)
|
||||
.then((res: any) => {
|
||||
knowledgeDetail.value = res.data
|
||||
|
|
|
|||
|
|
@ -275,7 +275,7 @@ function addParagraph() {
|
|||
}
|
||||
|
||||
function getDetail() {
|
||||
loadSharedApi({ type: 'document', systemType: apiType.value })
|
||||
loadSharedApi({ type: 'document', isShared: shareDisabled.value, systemType: apiType.value })
|
||||
.getDocumentDetail(id, documentId, loading)
|
||||
.then((res: any) => {
|
||||
documentDetail.value = res.data
|
||||
|
|
@ -283,7 +283,7 @@ function getDetail() {
|
|||
}
|
||||
|
||||
function getParagraphList() {
|
||||
loadSharedApi({ type: 'paragraph', systemType: apiType.value })
|
||||
loadSharedApi({ type: 'paragraph', isShared: shareDisabled.value, systemType: apiType.value })
|
||||
.getParagraphPage(
|
||||
id,
|
||||
documentId,
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@
|
|||
</el-breadcrumb>
|
||||
<el-card style="--el-card-padding: 0">
|
||||
<div class="flex">
|
||||
<div class="user-left border-r p-16">
|
||||
<div class="p-8 pb-0 mb-12">
|
||||
<div class="flex-between mb-16">
|
||||
<div class="user-left border-r">
|
||||
<div class="p-24 pb-0">
|
||||
<div class="flex-between mb-12">
|
||||
<h4 class="medium">{{ $t('views.chatUser.group.title') }}</h4>
|
||||
<el-tooltip
|
||||
effect="dark"
|
||||
|
|
@ -51,81 +51,83 @@
|
|||
|
||||
<div class="list-height-left">
|
||||
<el-scrollbar v-loading="loading">
|
||||
<common-list
|
||||
:data="filterList"
|
||||
@click="clickUserGroup"
|
||||
:default-active="current?.id"
|
||||
@mouseenter="mouseenter"
|
||||
@mouseleave="mouseId = ''"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="flex-between">
|
||||
<span class="ellipsis">{{ row.name }}</span>
|
||||
<div @click.stop v-show="mouseId === row.id">
|
||||
<el-dropdown :teleported="false">
|
||||
<el-button text>
|
||||
<el-icon class="color-secondary">
|
||||
<MoreFilled />
|
||||
</el-icon>
|
||||
</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu style="min-width: 80px">
|
||||
<el-dropdown-item
|
||||
@click.stop="createOrUpdate(row)"
|
||||
class="p-8"
|
||||
v-if="
|
||||
hasPermission(
|
||||
new ComplexPermission(
|
||||
[RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
|
||||
[
|
||||
PermissionConst.WORKSPACE_USER_GROUP_EDIT,
|
||||
PermissionConst.USER_GROUP_EDIT,
|
||||
],
|
||||
[],
|
||||
<div class="p-8-16">
|
||||
<common-list
|
||||
:data="filterList"
|
||||
@click="clickUserGroup"
|
||||
:default-active="current?.id"
|
||||
@mouseenter="mouseenter"
|
||||
@mouseleave="mouseId = ''"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="flex-between">
|
||||
<span class="ellipsis">{{ row.name }}</span>
|
||||
<div @click.stop v-show="mouseId === row.id">
|
||||
<el-dropdown :teleported="false" trigger="click">
|
||||
<el-button text>
|
||||
<el-icon class="color-secondary">
|
||||
<MoreFilled />
|
||||
</el-icon>
|
||||
</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu style="min-width: 80px">
|
||||
<el-dropdown-item
|
||||
@click.stop="createOrUpdate(row)"
|
||||
class="p-8"
|
||||
v-if="
|
||||
hasPermission(
|
||||
new ComplexPermission(
|
||||
[RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
|
||||
[
|
||||
PermissionConst.WORKSPACE_USER_GROUP_EDIT,
|
||||
PermissionConst.USER_GROUP_EDIT,
|
||||
],
|
||||
[],
|
||||
'OR',
|
||||
),
|
||||
'OR',
|
||||
),
|
||||
'OR',
|
||||
)
|
||||
"
|
||||
>
|
||||
<el-icon>
|
||||
<EditPen />
|
||||
</el-icon>
|
||||
{{ $t('common.rename') }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
@click.stop="deleteGroup(row)"
|
||||
class="border-t p-8"
|
||||
v-if="
|
||||
hasPermission(
|
||||
new ComplexPermission(
|
||||
[RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
|
||||
[
|
||||
PermissionConst.WORKSPACE_USER_GROUP_DELETE,
|
||||
PermissionConst.USER_GROUP_DELETE,
|
||||
],
|
||||
[],
|
||||
)
|
||||
"
|
||||
>
|
||||
<el-icon>
|
||||
<EditPen />
|
||||
</el-icon>
|
||||
{{ $t('common.rename') }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
@click.stop="deleteGroup(row)"
|
||||
class="border-t p-8"
|
||||
v-if="
|
||||
hasPermission(
|
||||
new ComplexPermission(
|
||||
[RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE],
|
||||
[
|
||||
PermissionConst.WORKSPACE_USER_GROUP_DELETE,
|
||||
PermissionConst.USER_GROUP_DELETE,
|
||||
],
|
||||
[],
|
||||
'OR',
|
||||
),
|
||||
'OR',
|
||||
),
|
||||
'OR',
|
||||
)
|
||||
"
|
||||
>
|
||||
<el-icon>
|
||||
<Delete />
|
||||
</el-icon>
|
||||
{{ $t('common.delete') }}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
)
|
||||
"
|
||||
>
|
||||
<el-icon>
|
||||
<Delete />
|
||||
</el-icon>
|
||||
{{ $t('common.delete') }}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #empty>
|
||||
<span></span>
|
||||
</template>
|
||||
</common-list>
|
||||
</template>
|
||||
<template #empty>
|
||||
<span></span>
|
||||
</template>
|
||||
</common-list>
|
||||
</div>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@
|
|||
|
||||
<el-card style="--el-card-padding: 0">
|
||||
<div class="flex main-calc-height">
|
||||
<div class="resource-authorization__left border-r p-16">
|
||||
<div class="p-8">
|
||||
<div class="resource-authorization__left border-r">
|
||||
<div class="p-24 pb-0">
|
||||
<h4 class="mb-12">{{ $t('views.resourceAuthorization.member') }}</h4>
|
||||
<el-input
|
||||
v-model="filterText"
|
||||
|
|
@ -35,22 +35,23 @@
|
|||
</div>
|
||||
<div class="list-height-left">
|
||||
<el-scrollbar>
|
||||
<common-list
|
||||
:data="filterMember"
|
||||
class="mt-8"
|
||||
v-loading="loading"
|
||||
@click="clickMemberHandle"
|
||||
:default-active="currentUser"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="flex-between">
|
||||
<div class="flex">
|
||||
<span class="mr-8">{{ row.nick_name }}</span>
|
||||
<TagGroup :tags="row.roles" />
|
||||
<div class="p-8-16">
|
||||
<common-list
|
||||
:data="filterMember"
|
||||
v-loading="loading"
|
||||
@click="clickMemberHandle"
|
||||
:default-active="currentUser"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="flex-between">
|
||||
<div class="flex">
|
||||
<span class="mr-8">{{ row.nick_name }}</span>
|
||||
<TagGroup :tags="row.roles" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</common-list>
|
||||
</template>
|
||||
</common-list>
|
||||
</div>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
@mouseleave="mouseId = ''"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span>{{ row.role_name }}</span>
|
||||
<span>{{ row.role_name }}</span>
|
||||
</template>
|
||||
<template #empty>
|
||||
<span></span>
|
||||
|
|
@ -49,7 +49,9 @@
|
|||
[RoleConst.ADMIN],
|
||||
[PermissionConst.ROLE_CREATE],
|
||||
[],
|
||||
'OR',)"
|
||||
'OR',
|
||||
)
|
||||
"
|
||||
>
|
||||
<el-icon :size="18"><Plus /></el-icon>
|
||||
</el-button>
|
||||
|
|
@ -71,7 +73,7 @@
|
|||
>
|
||||
</span>
|
||||
<div @click.stop v-show="mouseId === row.id">
|
||||
<el-dropdown :teleported="false">
|
||||
<el-dropdown :teleported="false" trigger="click">
|
||||
<el-button text>
|
||||
<el-icon class="color-secondary">
|
||||
<MoreFilled />
|
||||
|
|
@ -79,26 +81,38 @@
|
|||
</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu style="min-width: 80px">
|
||||
<el-dropdown-item @click.stop="createOrUpdateRole(row)" class="p-8"
|
||||
v-if="hasPermission(
|
||||
new ComplexPermission(
|
||||
[RoleConst.ADMIN],
|
||||
[PermissionConst.ROLE_EDIT],
|
||||
[],'OR'
|
||||
),'OR'
|
||||
)"
|
||||
<el-dropdown-item
|
||||
@click.stop="createOrUpdateRole(row)"
|
||||
class="p-8"
|
||||
v-if="
|
||||
hasPermission(
|
||||
new ComplexPermission(
|
||||
[RoleConst.ADMIN],
|
||||
[PermissionConst.ROLE_EDIT],
|
||||
[],
|
||||
'OR',
|
||||
),
|
||||
'OR',
|
||||
)
|
||||
"
|
||||
>
|
||||
<el-icon><EditPen /></el-icon>
|
||||
{{ $t('common.rename') }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item @click.stop="deleteRole(row)" class="border-t p-8"
|
||||
v-if="hasPermission(
|
||||
new ComplexPermission(
|
||||
[RoleConst.ADMIN],
|
||||
[PermissionConst.ROLE_DELETE],
|
||||
[],'OR'
|
||||
),'OR'
|
||||
)"
|
||||
<el-dropdown-item
|
||||
@click.stop="deleteRole(row)"
|
||||
class="border-t p-8"
|
||||
v-if="
|
||||
hasPermission(
|
||||
new ComplexPermission(
|
||||
[RoleConst.ADMIN],
|
||||
[PermissionConst.ROLE_DELETE],
|
||||
[],
|
||||
'OR',
|
||||
),
|
||||
'OR',
|
||||
)
|
||||
"
|
||||
>
|
||||
<el-icon><Delete /></el-icon>
|
||||
{{ $t('common.delete') }}
|
||||
|
|
@ -202,7 +216,7 @@ async function refresh(role?: RoleItem) {
|
|||
if (role) {
|
||||
currentRole.value = role
|
||||
} else {
|
||||
currentRole.value = customRoleList.value.find(item => item.id === currentRole.value?.id)
|
||||
currentRole.value = customRoleList.value.find((item) => item.id === currentRole.value?.id)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -238,12 +252,14 @@ function deleteRole(item: RoleItem) {
|
|||
},
|
||||
)
|
||||
.then(() => {
|
||||
loadPermissionApi('role').deleteRole(item.id, loading).then(async () => {
|
||||
MsgSuccess(t('common.deleteSuccess'))
|
||||
await getRole()
|
||||
currentRole.value =
|
||||
item.id === currentRole.value?.id ? internalRoleList.value[0] : currentRole.value
|
||||
})
|
||||
loadPermissionApi('role')
|
||||
.deleteRole(item.id, loading)
|
||||
.then(async () => {
|
||||
MsgSuccess(t('common.deleteSuccess'))
|
||||
await getRole()
|
||||
currentRole.value =
|
||||
item.id === currentRole.value?.id ? internalRoleList.value[0] : currentRole.value
|
||||
})
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
|
|
@ -285,4 +301,3 @@ function mouseenter(row: any) {
|
|||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
<h2 class="mb-16">{{ $t('views.workspace.title') }}</h2>
|
||||
<el-card style="--el-card-padding: 0">
|
||||
<div class="flex main-calc-height">
|
||||
<div class="workspace-left border-r p-16">
|
||||
<div class="p-8 pb-0 mt-8 mb-12">
|
||||
<div class="workspace-left border-r">
|
||||
<div class="p-24 pb-0">
|
||||
<div class="flex-between mb-12">
|
||||
<h4 class="medium">{{ $t('views.workspace.list') }}</h4>
|
||||
<el-tooltip
|
||||
|
|
@ -31,62 +31,64 @@
|
|||
</div>
|
||||
<div class="list-height-left">
|
||||
<el-scrollbar v-loading="loading">
|
||||
<common-list
|
||||
:data="filterList"
|
||||
@click="clickWorkspace"
|
||||
:default-active="currentWorkspace?.id"
|
||||
@mouseenter="mouseenter"
|
||||
@mouseleave="mouseId = ''"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="flex-between">
|
||||
<span class="ellipsis">{{ row.name }}</span>
|
||||
<div @click.stop v-show="mouseId === row.id">
|
||||
<el-dropdown :teleported="false">
|
||||
<el-button text>
|
||||
<el-icon class="color-secondary">
|
||||
<MoreFilled />
|
||||
</el-icon>
|
||||
</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu style="min-width: 80px">
|
||||
<el-dropdown-item
|
||||
@click.stop="createOrUpdateWorkspace(row)"
|
||||
class="p-8"
|
||||
v-if="
|
||||
hasPermission(
|
||||
[RoleConst.ADMIN, PermissionConst.WORKSPACE_EDIT],
|
||||
'OR',
|
||||
)
|
||||
"
|
||||
>
|
||||
<el-icon><EditPen /></el-icon>
|
||||
{{ $t('common.rename') }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
@click.stop="deleteWorkspace(row)"
|
||||
class="border-t p-8"
|
||||
v-if="
|
||||
row.id !== 'default' &&
|
||||
hasPermission(
|
||||
[RoleConst.ADMIN, PermissionConst.WORKSPACE_DELETE],
|
||||
'OR',
|
||||
)
|
||||
"
|
||||
>
|
||||
<el-icon><Delete /></el-icon>
|
||||
{{ $t('common.delete') }}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
<div class="p-8-16">
|
||||
<common-list
|
||||
:data="filterList"
|
||||
@click="clickWorkspace"
|
||||
:default-active="currentWorkspace?.id"
|
||||
@mouseenter="mouseenter"
|
||||
@mouseleave="mouseId = ''"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="flex-between">
|
||||
<span class="ellipsis">{{ row.name }}</span>
|
||||
<div @click.stop v-show="mouseId === row.id">
|
||||
<el-dropdown :teleported="false" trigger="click">
|
||||
<el-button text>
|
||||
<el-icon class="color-secondary">
|
||||
<MoreFilled />
|
||||
</el-icon>
|
||||
</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu style="min-width: 80px">
|
||||
<el-dropdown-item
|
||||
@click.stop="createOrUpdateWorkspace(row)"
|
||||
class="p-8"
|
||||
v-if="
|
||||
hasPermission(
|
||||
[RoleConst.ADMIN, PermissionConst.WORKSPACE_EDIT],
|
||||
'OR',
|
||||
)
|
||||
"
|
||||
>
|
||||
<el-icon><EditPen /></el-icon>
|
||||
{{ $t('common.rename') }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
@click.stop="deleteWorkspace(row)"
|
||||
class="border-t p-8"
|
||||
v-if="
|
||||
row.id !== 'default' &&
|
||||
hasPermission(
|
||||
[RoleConst.ADMIN, PermissionConst.WORKSPACE_DELETE],
|
||||
'OR',
|
||||
)
|
||||
"
|
||||
>
|
||||
<el-icon><Delete /></el-icon>
|
||||
{{ $t('common.delete') }}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #empty>
|
||||
<span></span>
|
||||
</template>
|
||||
</common-list>
|
||||
</template>
|
||||
<template #empty>
|
||||
<span></span>
|
||||
</template>
|
||||
</common-list>
|
||||
</div>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -119,7 +121,7 @@ import type { WorkspaceItem } from '@/api/type/workspace'
|
|||
import { MsgSuccess, MsgConfirm } from '@/utils/message'
|
||||
import { PermissionConst, RoleConst } from '@/utils/permission/data'
|
||||
import { hasPermission } from '@/utils/permission/index'
|
||||
import {loadPermissionApi} from "@/utils/dynamics-api/permission-api.ts";
|
||||
import { loadPermissionApi } from '@/utils/dynamics-api/permission-api.ts'
|
||||
|
||||
const filterText = ref('')
|
||||
const loading = ref(false)
|
||||
|
|
@ -148,7 +150,7 @@ async function refresh(workspace?: WorkspaceItem) {
|
|||
if (workspace) {
|
||||
currentWorkspace.value = workspace
|
||||
} else {
|
||||
currentWorkspace.value = list.value.find(item => item.id === currentWorkspace.value?.id)
|
||||
currentWorkspace.value = list.value.find((item) => item.id === currentWorkspace.value?.id)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -194,12 +196,14 @@ async function deleteWorkspace(item: WorkspaceItem) {
|
|||
confirmButtonClass: 'danger',
|
||||
},
|
||||
).then(() => {
|
||||
loadPermissionApi('workspace').deleteWorkspace(item.id as string, loading).then(async () => {
|
||||
MsgSuccess(t('common.deleteSuccess'))
|
||||
await getWorkspace()
|
||||
currentWorkspace.value =
|
||||
item.id === currentWorkspace.value?.id ? list.value[0] : currentWorkspace.value
|
||||
})
|
||||
loadPermissionApi('workspace')
|
||||
.deleteWorkspace(item.id as string, loading)
|
||||
.then(async () => {
|
||||
MsgSuccess(t('common.deleteSuccess'))
|
||||
await getWorkspace()
|
||||
currentWorkspace.value =
|
||||
item.id === currentWorkspace.value?.id ? list.value[0] : currentWorkspace.value
|
||||
})
|
||||
})
|
||||
} else {
|
||||
MsgConfirm(
|
||||
|
|
|
|||
Loading…
Reference in New Issue