2025-05-30 06:02:54 +00:00
|
|
|
|
<template>
|
2025-06-03 08:08:49 +00:00
|
|
|
|
<div class="resource-authorization p-16-24">
|
2025-06-20 09:02:42 +00:00
|
|
|
|
<div class="flex align-center mb-16">
|
2025-06-27 10:13:12 +00:00
|
|
|
|
<el-breadcrumb separator-icon="ArrowRight">
|
2025-07-09 08:12:02 +00:00
|
|
|
|
<el-breadcrumb-item>{{ t('views.system.resourceAuthorization.title') }}</el-breadcrumb-item>
|
2025-06-27 10:13:12 +00:00
|
|
|
|
<el-breadcrumb-item>
|
|
|
|
|
|
<h5 class="ml-4 color-text-primary">{{ activeData.label }}</h5>
|
|
|
|
|
|
</el-breadcrumb-item>
|
|
|
|
|
|
</el-breadcrumb>
|
2025-06-20 09:02:42 +00:00
|
|
|
|
<!-- 企业版: 工作空间下拉框-->
|
2025-06-27 14:22:52 +00:00
|
|
|
|
<el-divider
|
|
|
|
|
|
class="ml-24"
|
|
|
|
|
|
direction="vertical"
|
|
|
|
|
|
v-if="hasPermission(EditionConst.IS_EE, 'OR')"
|
|
|
|
|
|
/>
|
2025-06-20 10:10:32 +00:00
|
|
|
|
<WorkspaceDropdown
|
|
|
|
|
|
v-if="hasPermission(EditionConst.IS_EE, 'OR')"
|
|
|
|
|
|
:data="workspaceList"
|
|
|
|
|
|
:currentWorkspace="currentWorkspace"
|
|
|
|
|
|
@changeWorkspace="changeWorkspace"
|
|
|
|
|
|
/>
|
2025-06-20 09:02:42 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-08-15 08:03:03 +00:00
|
|
|
|
<el-card style="--el-card-padding: 0; height: calc(100vh - 140px)">
|
|
|
|
|
|
<div class="flex">
|
2025-07-08 09:10:26 +00:00
|
|
|
|
<div class="resource-authorization__left border-r">
|
|
|
|
|
|
<div class="p-24 pb-0">
|
2025-07-09 08:12:02 +00:00
|
|
|
|
<h4 class="mb-12">{{ $t('views.system.resourceAuthorization.member') }}</h4>
|
2025-06-20 09:02:42 +00:00
|
|
|
|
<el-input
|
|
|
|
|
|
v-model="filterText"
|
|
|
|
|
|
:placeholder="$t('common.search')"
|
|
|
|
|
|
prefix-icon="Search"
|
|
|
|
|
|
clearable
|
|
|
|
|
|
/>
|
2025-05-30 06:02:54 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="list-height-left">
|
|
|
|
|
|
<el-scrollbar>
|
2025-07-08 09:10:26 +00:00
|
|
|
|
<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">
|
2025-08-15 08:03:03 +00:00
|
|
|
|
<span class="mr-8 ellipsis-1" :title="row.nick_name">{{
|
|
|
|
|
|
row.nick_name
|
|
|
|
|
|
}}</span>
|
|
|
|
|
|
<el-text
|
|
|
|
|
|
class="color-input-placeholder ellipsis-1"
|
|
|
|
|
|
:title="row.roles.join(',')"
|
2025-07-16 05:49:46 +00:00
|
|
|
|
v-if="hasPermission([EditionConst.IS_EE, EditionConst.IS_PE], 'OR')"
|
2025-08-15 08:03:03 +00:00
|
|
|
|
>({{ row.roles?.join(',') }})</el-text
|
|
|
|
|
|
>
|
2025-07-08 09:10:26 +00:00
|
|
|
|
</div>
|
2025-05-30 06:02:54 +00:00
|
|
|
|
</div>
|
2025-07-08 09:10:26 +00:00
|
|
|
|
</template>
|
|
|
|
|
|
</common-list>
|
|
|
|
|
|
</div>
|
2025-05-30 06:02:54 +00:00
|
|
|
|
</el-scrollbar>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2025-08-15 08:03:03 +00:00
|
|
|
|
<PermissionTable
|
|
|
|
|
|
:data="permissionData"
|
|
|
|
|
|
:type="activeData.type"
|
|
|
|
|
|
ref="PermissionTableRef"
|
|
|
|
|
|
:getData="getPermissionList"
|
|
|
|
|
|
@submitPermissions="submitPermissions"
|
|
|
|
|
|
/>
|
2025-05-30 06:02:54 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
</el-card>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
2025-05-28 11:03:28 +00:00
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2025-06-20 10:10:32 +00:00
|
|
|
|
import { onMounted, ref, reactive, watch, computed } from 'vue'
|
2025-06-27 09:58:39 +00:00
|
|
|
|
import { useRoute } from 'vue-router'
|
2025-06-20 19:14:59 +00:00
|
|
|
|
import AuthorizationApi from '@/api/system/resource-authorization'
|
2025-08-15 08:03:03 +00:00
|
|
|
|
import PermissionTable from '@/views/system/resource-authorization/component/PermissionTable.vue'
|
2025-05-30 06:02:54 +00:00
|
|
|
|
import { MsgSuccess, MsgConfirm } from '@/utils/message'
|
|
|
|
|
|
import { AuthorizationEnum } from '@/enums/system'
|
|
|
|
|
|
import { t } from '@/locales'
|
2025-08-15 08:03:03 +00:00
|
|
|
|
import { EditionConst } from '@/utils/permission/data'
|
2025-06-20 09:02:42 +00:00
|
|
|
|
import { hasPermission } from '@/utils/permission/index'
|
2025-06-20 10:10:32 +00:00
|
|
|
|
import type { WorkspaceItem } from '@/api/type/workspace'
|
2025-07-02 08:01:22 +00:00
|
|
|
|
import { loadPermissionApi } from '@/utils/dynamics-api/permission-api.ts'
|
2025-06-30 05:38:04 +00:00
|
|
|
|
|
2025-08-15 08:03:03 +00:00
|
|
|
|
import useStore from '@/stores'
|
|
|
|
|
|
|
2025-06-27 09:58:39 +00:00
|
|
|
|
const route = useRoute()
|
2025-06-25 08:59:42 +00:00
|
|
|
|
const { user } = useStore()
|
2025-05-30 06:02:54 +00:00
|
|
|
|
const loading = ref(false)
|
|
|
|
|
|
const rLoading = ref(false)
|
2025-06-03 08:08:49 +00:00
|
|
|
|
const memberList = ref<any[]>([]) // 全部成员
|
|
|
|
|
|
const filterMember = ref<any[]>([]) // 搜索过滤后列表
|
2025-06-04 05:05:39 +00:00
|
|
|
|
const currentUser = ref<string>('')
|
|
|
|
|
|
const currentType = ref<string>('')
|
2025-05-30 06:02:54 +00:00
|
|
|
|
const filterText = ref('')
|
2025-08-15 08:03:03 +00:00
|
|
|
|
const permissionData = ref<any[]>([])
|
2025-06-25 08:59:42 +00:00
|
|
|
|
|
2025-05-30 06:02:54 +00:00
|
|
|
|
const settingTags = reactive([
|
|
|
|
|
|
{
|
|
|
|
|
|
label: t('views.knowledge.title'),
|
2025-06-27 09:58:39 +00:00
|
|
|
|
type: AuthorizationEnum.KNOWLEDGE,
|
2025-05-30 06:02:54 +00:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
label: t('views.application.title'),
|
2025-06-27 09:58:39 +00:00
|
|
|
|
type: AuthorizationEnum.APPLICATION,
|
2025-05-30 06:02:54 +00:00
|
|
|
|
},
|
2025-06-26 06:20:57 +00:00
|
|
|
|
{
|
|
|
|
|
|
label: t('views.tool.title'),
|
2025-06-27 09:58:39 +00:00
|
|
|
|
type: AuthorizationEnum.TOOL,
|
2025-06-26 06:20:57 +00:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
label: t('views.model.title'),
|
2025-06-27 09:58:39 +00:00
|
|
|
|
type: AuthorizationEnum.MODEL,
|
2025-06-26 06:20:57 +00:00
|
|
|
|
},
|
2025-05-30 06:02:54 +00:00
|
|
|
|
])
|
2025-06-27 09:58:39 +00:00
|
|
|
|
// 当前激活的数据类型(应用/知识库/模型/工具)
|
|
|
|
|
|
const activeData = computed(() => {
|
2025-07-07 09:04:14 +00:00
|
|
|
|
const lastIndex = route.path.lastIndexOf('/')
|
2025-06-27 09:58:39 +00:00
|
|
|
|
const currentPathType = route.path.substring(lastIndex + 1).toUpperCase()
|
|
|
|
|
|
return settingTags.filter((item) => {
|
|
|
|
|
|
return item.type === currentPathType
|
|
|
|
|
|
})[0]
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2025-06-04 05:05:39 +00:00
|
|
|
|
watch(filterText, (val: any) => {
|
2025-05-30 06:02:54 +00:00
|
|
|
|
if (val) {
|
2025-06-04 05:05:39 +00:00
|
|
|
|
filterMember.value = memberList.value.filter((v: any) =>
|
2025-07-04 08:17:56 +00:00
|
|
|
|
v.nick_name.toLowerCase().includes(val.toLowerCase()),
|
2025-05-30 06:02:54 +00:00
|
|
|
|
)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
filterMember.value = memberList.value
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2025-08-15 08:03:03 +00:00
|
|
|
|
function submitPermissions(obj: any) {
|
2025-07-07 09:27:16 +00:00
|
|
|
|
const workspaceId = currentWorkspaceId.value || user.getWorkspaceId() || 'default'
|
2025-06-20 09:02:42 +00:00
|
|
|
|
AuthorizationApi.putResourceAuthorization(
|
2025-07-07 09:27:16 +00:00
|
|
|
|
workspaceId,
|
2025-06-20 09:02:42 +00:00
|
|
|
|
currentUser.value,
|
2025-06-27 14:22:52 +00:00
|
|
|
|
(route.meta?.resource as string) || 'APPLICATION',
|
2025-08-15 08:03:03 +00:00
|
|
|
|
obj,
|
2025-06-20 09:02:42 +00:00
|
|
|
|
rLoading,
|
|
|
|
|
|
).then(() => {
|
2025-06-06 02:59:40 +00:00
|
|
|
|
MsgSuccess(t('common.submitSuccess'))
|
2025-08-15 08:03:03 +00:00
|
|
|
|
getPermissionList()
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const PermissionTableRef = ref()
|
|
|
|
|
|
|
|
|
|
|
|
const getPermissionList = () => {
|
|
|
|
|
|
const workspaceId = currentWorkspaceId.value || user.getWorkspaceId() || 'default'
|
|
|
|
|
|
const params: any = {}
|
|
|
|
|
|
if (PermissionTableRef.value.searchForm[PermissionTableRef.value.searchType]) {
|
|
|
|
|
|
params[PermissionTableRef.value.searchType] =
|
|
|
|
|
|
PermissionTableRef.value.searchForm[PermissionTableRef.value.searchType]
|
|
|
|
|
|
}
|
|
|
|
|
|
AuthorizationApi.getResourceAuthorization(
|
|
|
|
|
|
workspaceId,
|
|
|
|
|
|
currentUser.value,
|
|
|
|
|
|
(route.meta?.resource as string) || 'APPLICATION',
|
|
|
|
|
|
PermissionTableRef.value.paginationConfig,
|
|
|
|
|
|
params,
|
|
|
|
|
|
rLoading,
|
|
|
|
|
|
).then((res) => {
|
|
|
|
|
|
permissionData.value = res.data.records || []
|
|
|
|
|
|
PermissionTableRef.value.paginationConfig.total = res.data.total || 0
|
2025-06-06 02:59:40 +00:00
|
|
|
|
})
|
2025-05-30 06:02:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-03 08:08:49 +00:00
|
|
|
|
function clickMemberHandle(item: any) {
|
|
|
|
|
|
currentUser.value = item.id
|
|
|
|
|
|
currentType.value = item.type
|
2025-08-15 08:03:03 +00:00
|
|
|
|
getPermissionList()
|
2025-06-03 08:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getMember(id?: string) {
|
2025-07-07 09:27:16 +00:00
|
|
|
|
const workspaceId = currentWorkspaceId.value || user.getWorkspaceId() || 'default'
|
|
|
|
|
|
AuthorizationApi.getUserMember(workspaceId, loading).then((res) => {
|
2025-06-06 02:59:40 +00:00
|
|
|
|
memberList.value = res.data
|
|
|
|
|
|
filterMember.value = res.data
|
2025-07-07 08:59:24 +00:00
|
|
|
|
if (memberList.value.length > 0) {
|
|
|
|
|
|
const member = (id && memberList.value.find((p: any) => p.user_id === id)) || null
|
|
|
|
|
|
currentUser.value = member ? member.id : memberList.value?.[0]?.id
|
|
|
|
|
|
currentType.value = member ? member.type : memberList.value?.[0]?.type
|
2025-08-15 08:03:03 +00:00
|
|
|
|
getPermissionList()
|
2025-07-08 03:38:31 +00:00
|
|
|
|
} else {
|
2025-08-15 08:03:03 +00:00
|
|
|
|
permissionData.value = []
|
2025-07-07 08:59:24 +00:00
|
|
|
|
}
|
2025-06-13 09:12:31 +00:00
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-20 10:10:32 +00:00
|
|
|
|
const workspaceList = ref<WorkspaceItem[]>([])
|
|
|
|
|
|
const currentWorkspaceId = ref<string | undefined>('')
|
|
|
|
|
|
const currentWorkspace = computed(() => {
|
|
|
|
|
|
return workspaceList.value.find((w) => w.id == currentWorkspaceId.value)
|
|
|
|
|
|
})
|
|
|
|
|
|
async function getWorkspaceList() {
|
2025-07-02 01:56:42 +00:00
|
|
|
|
const res = await loadPermissionApi('workspace').getSystemWorkspaceList(loading)
|
2025-06-23 11:37:38 +00:00
|
|
|
|
workspaceList.value = res.data
|
2025-07-07 13:03:42 +00:00
|
|
|
|
currentWorkspaceId.value = (user.getWorkspaceId() as string) || 'default'
|
2025-06-20 10:10:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function changeWorkspace(item: WorkspaceItem) {
|
|
|
|
|
|
currentWorkspaceId.value = item.id
|
|
|
|
|
|
getMember()
|
|
|
|
|
|
}
|
2025-05-30 06:02:54 +00:00
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
2025-06-23 11:37:38 +00:00
|
|
|
|
if (user.isEE()) {
|
|
|
|
|
|
getWorkspaceList()
|
|
|
|
|
|
}
|
2025-06-03 08:08:49 +00:00
|
|
|
|
getMember()
|
2025-05-30 06:02:54 +00:00
|
|
|
|
})
|
2025-05-28 11:03:28 +00:00
|
|
|
|
</script>
|
|
|
|
|
|
|
2025-05-30 06:02:54 +00:00
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
.resource-authorization {
|
2025-06-03 08:08:49 +00:00
|
|
|
|
.resource-authorization__left {
|
2025-05-30 06:02:54 +00:00
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
|
width: var(--setting-left-width);
|
|
|
|
|
|
min-width: var(--setting-left-width);
|
|
|
|
|
|
}
|
|
|
|
|
|
.list-height-left {
|
2025-06-03 08:08:49 +00:00
|
|
|
|
height: calc(100vh - 240px);
|
2025-05-30 06:02:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|