fix: Workspace shared knowledge button visibility
This commit is contained in:
parent
f627daf231
commit
b6cf80d6ef
@ -80,7 +80,7 @@ import type { FormInstance } from 'element-plus'
|
|||||||
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
|
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
apiType: 'systemShare' | 'workspace' | 'systemManage'
|
apiType: 'systemShare' | 'workspace' | 'systemManage' | 'workspaceShare'
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
import systemShare from './system-share'
|
import systemShare from './system-share'
|
||||||
import workspace from './workspace'
|
import workspace from './workspace'
|
||||||
import systemManage from './system-manage'
|
import systemManage from './system-manage'
|
||||||
|
import workspaceShare from './workspace-share'
|
||||||
const permission = {
|
const permission = {
|
||||||
systemShare,
|
systemShare,
|
||||||
workspace,
|
workspace,
|
||||||
systemManage,
|
systemManage,
|
||||||
|
workspaceShare
|
||||||
}
|
}
|
||||||
export default permission
|
export default permission
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { hasPermission } from '@/utils/permission/index'
|
import { hasPermission } from '@/utils/permission/index'
|
||||||
import { ComplexPermission } from '@/utils/permission/type'
|
import { ComplexPermission } from '@/utils/permission/type'
|
||||||
import { EditionConst, PermissionConst, RoleConst } from '@/utils/permission/data'
|
import { EditionConst, PermissionConst, RoleConst } from '@/utils/permission/data'
|
||||||
const workspace = {
|
const systemManage = {
|
||||||
is_share: () =>
|
is_share: () =>
|
||||||
hasPermission(
|
hasPermission(
|
||||||
new ComplexPermission(
|
new ComplexPermission(
|
||||||
@ -37,4 +37,4 @@ const workspace = {
|
|||||||
problem_delete: () => false,
|
problem_delete: () => false,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default workspace
|
export default systemManage
|
||||||
|
|||||||
31
ui/src/permission/knowledge/workspace-share.ts
Normal file
31
ui/src/permission/knowledge/workspace-share.ts
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import { hasPermission } from '@/utils/permission/index'
|
||||||
|
import { ComplexPermission } from '@/utils/permission/type'
|
||||||
|
import { EditionConst, PermissionConst, RoleConst } from '@/utils/permission/data'
|
||||||
|
const workspaceShare = {
|
||||||
|
is_share: () => true,
|
||||||
|
create: () => false,
|
||||||
|
sync: () => false,
|
||||||
|
vector: () => false,
|
||||||
|
generate: () => false,
|
||||||
|
setting: () => false,
|
||||||
|
export: () => false,
|
||||||
|
delete: () => false,
|
||||||
|
|
||||||
|
doc_create: () => false,
|
||||||
|
doc_vector: () => false,
|
||||||
|
doc_generate: () => false,
|
||||||
|
doc_migrate: () => false,
|
||||||
|
doc_edit: () => false,
|
||||||
|
doc_sync: () => false,
|
||||||
|
doc_delete: () => false,
|
||||||
|
doc_export: () => false,
|
||||||
|
doc_download: () => false,
|
||||||
|
|
||||||
|
knowledge_chat_user_edit: () => false,
|
||||||
|
|
||||||
|
problem_create: () => false,
|
||||||
|
problem_relate: () => false,
|
||||||
|
problem_delete: () => false,
|
||||||
|
}
|
||||||
|
|
||||||
|
export default workspaceShare
|
||||||
@ -1,7 +1,7 @@
|
|||||||
import { hasPermission } from '@/utils/permission/index'
|
import { hasPermission } from '@/utils/permission/index'
|
||||||
import { ComplexPermission } from '@/utils/permission/type'
|
import { ComplexPermission } from '@/utils/permission/type'
|
||||||
import { EditionConst, PermissionConst, RoleConst } from '@/utils/permission/data'
|
import { EditionConst, PermissionConst, RoleConst } from '@/utils/permission/data'
|
||||||
const workspace = {
|
const systemManage = {
|
||||||
is_share: () =>
|
is_share: () =>
|
||||||
hasPermission(
|
hasPermission(
|
||||||
new ComplexPermission(
|
new ComplexPermission(
|
||||||
@ -18,4 +18,4 @@ const workspace = {
|
|||||||
delete: () => false,
|
delete: () => false,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default workspace
|
export default systemManage
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { hasPermission } from '@/utils/permission/index'
|
import { hasPermission } from '@/utils/permission/index'
|
||||||
import { ComplexPermission } from '@/utils/permission/type'
|
import { ComplexPermission } from '@/utils/permission/type'
|
||||||
import { EditionConst, PermissionConst, RoleConst } from '@/utils/permission/data'
|
import { EditionConst, PermissionConst, RoleConst } from '@/utils/permission/data'
|
||||||
const workspace = {
|
const systemManage = {
|
||||||
is_share: () =>
|
is_share: () =>
|
||||||
hasPermission(
|
hasPermission(
|
||||||
new ComplexPermission(
|
new ComplexPermission(
|
||||||
@ -22,4 +22,4 @@ const workspace = {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default workspace
|
export default systemManage
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import problemSystemShareApi from '@/api/system-shared/problem'
|
|||||||
import chatUserSystemShareApi from '@/api/system-shared/chat-user'
|
import chatUserSystemShareApi from '@/api/system-shared/chat-user'
|
||||||
import workspaceApi from '@/api/workspace/workspace'
|
import workspaceApi from '@/api/workspace/workspace'
|
||||||
import systemUserApi from '@/api/user/user'
|
import systemUserApi from '@/api/user/user'
|
||||||
|
import workspaceShare from '@/permission/knowledge/workspace-share'
|
||||||
|
|
||||||
// 普通 API
|
// 普通 API
|
||||||
const workspaceApiMap = {
|
const workspaceApiMap = {
|
||||||
@ -51,6 +52,7 @@ const data = {
|
|||||||
systemShare: systemShareApiMap,
|
systemShare: systemShareApiMap,
|
||||||
workspace: workspaceApiMap,
|
workspace: workspaceApiMap,
|
||||||
systemManage: systemManageApiMap,
|
systemManage: systemManageApiMap,
|
||||||
|
workspaceShare: workspaceApiMap
|
||||||
}
|
}
|
||||||
/** 动态导入 API 模块的函数
|
/** 动态导入 API 模块的函数
|
||||||
* loadSharedApi('knowledge', true,'systemShare')
|
* loadSharedApi('knowledge', true,'systemShare')
|
||||||
@ -62,7 +64,7 @@ export function loadSharedApi({
|
|||||||
}: {
|
}: {
|
||||||
type: string
|
type: string
|
||||||
isShared?: boolean | undefined
|
isShared?: boolean | undefined
|
||||||
systemType?: 'systemShare' | 'workspace' | 'systemManage'
|
systemType?: 'systemShare' | 'workspace' | 'systemManage' | 'workspaceShare'
|
||||||
}) {
|
}) {
|
||||||
if (isShared) {
|
if (isShared) {
|
||||||
// 共享 API
|
// 共享 API
|
||||||
|
|||||||
@ -56,7 +56,8 @@
|
|||||||
:disabled="current?.is_auth"
|
:disabled="current?.is_auth"
|
||||||
@click="handleSave"
|
@click="handleSave"
|
||||||
v-if="
|
v-if="
|
||||||
hasPermission(
|
route.path.includes('share/') ? false
|
||||||
|
: hasPermission(
|
||||||
permissionObj[
|
permissionObj[
|
||||||
route.path.includes('shared')
|
route.path.includes('shared')
|
||||||
? 'SHAREDKNOWLEDGE'
|
? 'SHAREDKNOWLEDGE'
|
||||||
@ -87,7 +88,8 @@
|
|||||||
<div
|
<div
|
||||||
class="flex align-center"
|
class="flex align-center"
|
||||||
v-if="
|
v-if="
|
||||||
hasPermission(
|
route.path.includes('share/') ? false
|
||||||
|
: hasPermission(
|
||||||
permissionObj[
|
permissionObj[
|
||||||
route.path.includes('shared')
|
route.path.includes('shared')
|
||||||
? 'SHAREDKNOWLEDGE'
|
? 'SHAREDKNOWLEDGE'
|
||||||
|
|||||||
@ -655,6 +655,8 @@ const apiType = computed(() => {
|
|||||||
return 'systemShare'
|
return 'systemShare'
|
||||||
} else if (route.path.includes('resource-management')) {
|
} else if (route.path.includes('resource-management')) {
|
||||||
return 'systemManage'
|
return 'systemManage'
|
||||||
|
} else if (route.path.includes('share/')) {
|
||||||
|
return 'workspaceShare'
|
||||||
} else {
|
} else {
|
||||||
return 'workspace'
|
return 'workspace'
|
||||||
}
|
}
|
||||||
|
|||||||
@ -204,6 +204,7 @@
|
|||||||
/>
|
/>
|
||||||
<div class="operate">
|
<div class="operate">
|
||||||
<el-button
|
<el-button
|
||||||
|
v-if="! route.path.includes('share/')"
|
||||||
text
|
text
|
||||||
class="sent-button"
|
class="sent-button"
|
||||||
:disabled="isDisabledChart || loading"
|
:disabled="isDisabledChart || loading"
|
||||||
|
|||||||
@ -167,12 +167,7 @@
|
|||||||
<el-button
|
<el-button
|
||||||
@click="submit"
|
@click="submit"
|
||||||
type="primary"
|
type="primary"
|
||||||
v-hasPermission="[
|
v-if=" !route.path.includes('share/') && permissionPrecise.setting(id)"
|
||||||
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
|
|
||||||
RoleConst.ADMIN,
|
|
||||||
PermissionConst.KNOWLEDGE_EDIT.getWorkspacePermissionWorkspaceManageRole,
|
|
||||||
PermissionConst.KNOWLEDGE_EDIT.getKnowledgeWorkspaceResourcePermission(id),
|
|
||||||
]"
|
|
||||||
>
|
>
|
||||||
{{ $t('common.save') }}</el-button
|
{{ $t('common.save') }}</el-button
|
||||||
>
|
>
|
||||||
@ -190,6 +185,8 @@ import BaseForm from '@/views/knowledge/component/BaseForm.vue'
|
|||||||
import { MsgSuccess, MsgConfirm } from '@/utils/message'
|
import { MsgSuccess, MsgConfirm } from '@/utils/message'
|
||||||
import { t } from '@/locales'
|
import { t } from '@/locales'
|
||||||
import { PermissionConst, RoleConst } from '@/utils/permission/data'
|
import { PermissionConst, RoleConst } from '@/utils/permission/data'
|
||||||
|
import permissionMap from '@/permission'
|
||||||
|
|
||||||
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
|
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
@ -206,6 +203,11 @@ const apiType = computed(() => {
|
|||||||
return 'workspace'
|
return 'workspace'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const permissionPrecise = computed(() => {
|
||||||
|
return permissionMap['knowledge'][apiType.value]
|
||||||
|
})
|
||||||
|
|
||||||
const webFormRef = ref()
|
const webFormRef = ref()
|
||||||
const BaseFormRef = ref()
|
const BaseFormRef = ref()
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
|||||||
@ -43,7 +43,7 @@
|
|||||||
class="mt-16"
|
class="mt-16"
|
||||||
:data="problemData"
|
:data="problemData"
|
||||||
:pagination-config="paginationConfig"
|
:pagination-config="paginationConfig"
|
||||||
:quick-create="permissionPrecise.doc_create(id)"
|
:quick-create="permissionPrecise.problem_create(id)"
|
||||||
:quickCreateName="$t('views.problem.quickCreateName')"
|
:quickCreateName="$t('views.problem.quickCreateName')"
|
||||||
:quickCreatePlaceholder="$t('views.problem.quickCreateProblem')"
|
:quickCreatePlaceholder="$t('views.problem.quickCreateProblem')"
|
||||||
:quickCreateMaxlength="256"
|
:quickCreateMaxlength="256"
|
||||||
@ -178,6 +178,8 @@ const apiType = computed(() => {
|
|||||||
return 'systemShare'
|
return 'systemShare'
|
||||||
} else if (route.path.includes('resource-management')) {
|
} else if (route.path.includes('resource-management')) {
|
||||||
return 'systemManage'
|
return 'systemManage'
|
||||||
|
} else if (route.path.includes('share/')) {
|
||||||
|
return 'workspaceShare'
|
||||||
} else {
|
} else {
|
||||||
return 'workspace'
|
return 'workspace'
|
||||||
}
|
}
|
||||||
|
|||||||
@ -234,7 +234,7 @@
|
|||||||
<el-button :loading="loading" @click="openDebug" v-if="permissionPrecise.debug(form?.id||'or')">{{
|
<el-button :loading="loading" @click="openDebug" v-if="permissionPrecise.debug(form?.id||'or')">{{
|
||||||
$t('common.debug')
|
$t('common.debug')
|
||||||
}}</el-button>
|
}}</el-button>
|
||||||
<el-button type="primary" @click="submit(FormRef)" :loading="loading">
|
<el-button type="primary" @click="submit(FormRef)" :loading="loading" v-if="permissionPrecise.edit(form?.id||'or') || permissionPrecise.create()" >
|
||||||
{{ isEdit ? $t('common.save') : $t('common.create') }}
|
{{ isEdit ? $t('common.save') : $t('common.create') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user