11<template >
22 <div class =" upload-document p-12-24" >
33 <div class =" flex align-center mb-16" >
4- <back-button to = " -1 " style =" margin-left : -4px " ></back-button >
4+ <back-button @click = " back " style =" margin-left : -4px " ></back-button >
55 <h3 style =" display : inline-block " >{{ $t('views.document.importDocument') }}</h3 >
66 </div >
77 <el-card style =" --el-card-padding : 0 " >
@@ -65,6 +65,9 @@ import applicationApi from '@/api/application/application'
6565import KnowledgeBase from ' @/views/knowledge-workflow/component/action/KnowledgeBase.vue'
6666import { loadSharedApi } from ' @/utils/dynamics-api/shared-api'
6767import { WorkflowType } from ' @/enums/application'
68+ import { ComplexPermission , Permission } from ' @/utils/permission/type'
69+ import { hasPermission } from ' @/utils/permission'
70+ import { EditionConst , PermissionConst , RoleConst } from ' @/utils/permission/data'
6871provide (' upload' , (file : any , loading ? : Ref <boolean >) => {
6972 return applicationApi .postUploadFile (file , id as string , ' KNOWLEDGE' , loading )
7073})
@@ -73,7 +76,7 @@ const route = useRoute()
7376const key = ref <number >(0 )
7477const {
7578 params : { folderId },
76- query : { id },
79+ query : { id } ,
7780 /*
7881 id为knowledgeID
7982 folderId 可以区分 resource-management shared还是 workspace
@@ -155,6 +158,91 @@ const goDocument = () => {
155158 }).href
156159 window .open (newUrl )
157160}
161+
162+ const back = () => {
163+ if (route .path .includes (' resource-management' )) {
164+ return router .push ({ path: get_resource_management_route () })
165+ } else if (route .path .includes (' shared' )) {
166+ return router .push ({ path: get_shared_route () })
167+ } else {
168+ return router .push ({ path: get_route () })
169+ }
170+ }
171+
172+ const get_shared_route = () => {
173+ if (hasPermission ([RoleConst .ADMIN , PermissionConst .SHARED_KNOWLEDGE_DOCUMENT_READ ], ' OR' )) {
174+ return ` /knowledge/${id }/shared/4/document `
175+ } else if (
176+ hasPermission ([RoleConst .ADMIN , PermissionConst .SHARED_KNOWLEDGE_PROBLEM_READ ], ' OR' )
177+ ) {
178+ return ` /knowledge/${id }/shared/4/problem `
179+ } else if (
180+ hasPermission ([RoleConst .ADMIN , PermissionConst .SHARED_KNOWLEDGE_HIT_TEST_READ ], ' OR' )
181+ ) {
182+ return ` /knowledge/${id }/shared/4/hit-test `
183+ } else if (
184+ hasPermission ([RoleConst .ADMIN , PermissionConst .SHARED_KNOWLEDGE_CHAT_USER_READ ], ' OR' )
185+ ) {
186+ return ` /knowledge/${id }/shared/4/chat-user `
187+ } else if (hasPermission ([RoleConst .ADMIN , PermissionConst .SHARED_KNOWLEDGE_EDIT ], ' OR' )) {
188+ return ` /knowledge/${id }/shared/4/setting `
189+ } else {
190+ return ` /system/shared/knowledge `
191+ }
192+ }
193+
194+ const get_resource_management_route = () => {
195+ if (hasPermission ([RoleConst .ADMIN , PermissionConst .RESOURCE_KNOWLEDGE_DOCUMENT_READ ], ' OR' )) {
196+ return ` /knowledge/${id }/resource-management/4/document `
197+ } else if (
198+ hasPermission ([RoleConst .ADMIN , PermissionConst .RESOURCE_KNOWLEDGE_PROBLEM_READ ], ' OR' )
199+ ) {
200+ return ` /knowledge/${id }/resource-management/4/problem `
201+ } else if (hasPermission ([RoleConst .ADMIN , PermissionConst .RESOURCE_KNOWLEDGE_HIT_TEST ], ' OR' )) {
202+ return ` /knowledge/${id }/resource-management/4/hit-test `
203+ } else if (
204+ hasPermission ([RoleConst .ADMIN , PermissionConst .RESOURCE_KNOWLEDGE_CHAT_USER_READ ], ' OR' )
205+ ) {
206+ return ` /knowledge/${id }/resource-management/4/chat-user `
207+ } else if (hasPermission ([RoleConst .ADMIN , PermissionConst .RESOURCE_KNOWLEDGE_EDIT ], ' OR' )) {
208+ return ` /knowledge/${id }/resource-management/4/setting `
209+ } else {
210+ return ` /system/resource-management/knowledge `
211+ }
212+ }
213+
214+ const get_route = () => {
215+ const checkPermission = (permissionConst : Permission ) => {
216+ return hasPermission (
217+ [
218+ new ComplexPermission (
219+ [RoleConst .USER ],
220+ [PermissionConst .KNOWLEDGE .getKnowledgeWorkspaceResourcePermission (id as string )],
221+ [],
222+ ' AND' ,
223+ ),
224+ RoleConst .WORKSPACE_MANAGE .getWorkspaceRole ,
225+ permissionConst .getWorkspacePermissionWorkspaceManageRole ,
226+ permissionConst .getKnowledgeWorkspaceResourcePermission (id as string ),
227+ ],
228+ ' OR' ,
229+ )
230+ }
231+ if (checkPermission (PermissionConst .KNOWLEDGE_DOCUMENT_READ )) {
232+ return ` /knowledge/${id }/${folderId }/4/document `
233+ } else if (checkPermission (PermissionConst .KNOWLEDGE_PROBLEM_READ )) {
234+ return ` /knowledge/${id }/${folderId }/4/problem `
235+ } else if (checkPermission (PermissionConst .KNOWLEDGE_HIT_TEST_READ )) {
236+ return ` /knowledge/${id }/${folderId }/4/hit-test `
237+ } else if (checkPermission (PermissionConst .KNOWLEDGE_CHAT_USER_READ )) {
238+ return ` /knowledge/${id }/${folderId }/4/chat-user `
239+ } else if (checkPermission (PermissionConst .KNOWLEDGE_EDIT )) {
240+ return ` /knowledge/${id }/${folderId }/4/setting `
241+ } else {
242+ return ` /knowledge `
243+ }
244+ }
245+
158246onMounted (() => {
159247 getDetail ()
160248})
0 commit comments