88 direction =" vertical"
99 v-if =" hasPermission(EditionConst.IS_EE, 'OR')"
1010 />
11- <WorkspaceDropdown v-if =" hasPermission(EditionConst.IS_EE, 'OR')" />
11+ <WorkspaceDropdown
12+ v-if =" hasPermission(EditionConst.IS_EE, 'OR')"
13+ :data =" workspaceList"
14+ :currentWorkspace =" currentWorkspace"
15+ @changeWorkspace =" changeWorkspace"
16+ />
1217 </div >
1318
1419 <el-card style =" --el-card-padding : 0 " >
7681</template >
7782
7883<script lang="ts" setup>
79- import { onMounted , ref , reactive , watch } from ' vue'
84+ import { onMounted , ref , reactive , watch , computed } from ' vue'
8085import AuthorizationApi from ' @/api/user/resource-authorization'
8186import PermissionSetting from ' ./component/PermissionSetting.vue'
8287import { MsgSuccess , MsgConfirm } from ' @/utils/message'
@@ -86,6 +91,8 @@ import useStore from '@/stores'
8691import { cloneDeep } from ' lodash'
8792import { EditionConst } from ' @/utils/permission/data'
8893import { hasPermission } from ' @/utils/permission/index'
94+ import WorkspaceApi from ' @/api/workspace/workspace.ts'
95+ import type { WorkspaceItem } from ' @/api/type/workspace'
8996
9097const loading = ref (false )
9198const rLoading = ref (false )
@@ -97,7 +104,7 @@ const filterText = ref('')
97104
98105const activeName = ref (AuthorizationEnum .KNOWLEDGE )
99106const tableHeight = ref (0 )
100- const { folder } = useStore ()
107+ const { user } = useStore ()
101108
102109const settingTags = reactive ([
103110 {
@@ -153,6 +160,7 @@ function submitPermissions() {
153160 return [... pre , ... next ]
154161 }, [])
155162 AuthorizationApi .putResourceAuthorization (
163+ currentWorkspaceId .value || ' default' ,
156164 currentUser .value ,
157165 { user_resource_permission_list: user_resource_permission_list },
158166 rLoading ,
@@ -169,7 +177,7 @@ function clickMemberHandle(item: any) {
169177}
170178
171179function getMember(id ? : string ) {
172- AuthorizationApi .getUserMember (loading ).then ((res ) => {
180+ AuthorizationApi .getUserMember (currentWorkspaceId . value || ' default ' , loading ).then ((res ) => {
173181 memberList .value = res .data
174182 filterMember .value = res .data
175183
@@ -256,13 +264,20 @@ const dfsFolder = (arr: any[] = [], folderIdMap: any) => {
256264}
257265
258266function getFolder() {
259- return folder .asyncGetFolder (' KNOWLEDGE' , {}, loading )
267+ return AuthorizationApi .getSystemFolder (
268+ currentWorkspaceId .value || ' default' ,
269+ ' KNOWLEDGE' ,
270+ {},
271+ loading ,
272+ )
260273}
261-
262274function getResourcePermissions(user_id : string ) {
263- return AuthorizationApi .getResourceAuthorization (user_id , rLoading )
275+ return AuthorizationApi .getResourceAuthorization (
276+ currentWorkspaceId .value || ' default' ,
277+ user_id ,
278+ rLoading ,
279+ )
264280}
265-
266281const getWholeTree = async (user_id : string ) => {
267282 const [parentRes, childrenRes] = await Promise .all ([getFolder (), getResourcePermissions (user_id )])
268283 if (! childrenRes .data || Object .keys (childrenRes .data ).length > 0 ) {
@@ -313,7 +328,11 @@ const getFolderIdMap = (arr: any = []) => {
313328 }, {})
314329}
315330function ResourcePermissions(user_id : string ) {
316- AuthorizationApi .getResourceAuthorization (user_id , rLoading ).then ((res ) => {
331+ AuthorizationApi .getResourceAuthorization (
332+ currentWorkspaceId .value || ' default' ,
333+ user_id ,
334+ rLoading ,
335+ ).then ((res ) => {
317336 if (! res .data || Object .keys (res .data ).length > 0 ) {
318337 settingTags .map ((item : any ) => {
319338 if (Object .keys (res .data ).indexOf (item .value ) !== - 1 ) {
@@ -325,6 +344,23 @@ function ResourcePermissions(user_id: string) {
325344 })
326345}
327346
347+ const workspaceList = ref <WorkspaceItem []>([])
348+ const currentWorkspaceId = ref <string | undefined >(' ' )
349+ const currentWorkspace = computed (() => {
350+ return workspaceList .value .find ((w ) => w .id == currentWorkspaceId .value )
351+ })
352+ async function getWorkspaceList() {
353+ if (user .isEE ()) {
354+ const res = await WorkspaceApi .getSystemWorkspaceList (loading )
355+ workspaceList .value = res .data
356+ currentWorkspaceId .value = ' default'
357+ }
358+ }
359+
360+ function changeWorkspace(item : WorkspaceItem ) {
361+ currentWorkspaceId .value = item .id
362+ getMember ()
363+ }
328364function refresh(data ? : string []) {}
329365
330366onMounted (() => {
@@ -334,6 +370,7 @@ onMounted(() => {
334370 tableHeight .value = window .innerHeight - 330
335371 })()
336372 }
373+ getWorkspaceList ()
337374 getMember ()
338375})
339376 </script >
0 commit comments