feat: resource-authorization
This commit is contained in:
parent
6c6aa20ff6
commit
e1841c6189
@ -140,7 +140,53 @@ const systemRouter = {
|
|||||||
parentName: 'system',
|
parentName: 'system',
|
||||||
sameRoute: 'authorization',
|
sameRoute: 'authorization',
|
||||||
},
|
},
|
||||||
component: () => import('@/views/system/resource-authorization/index.vue'),
|
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: '/system/authorization/application',
|
||||||
|
name: 'authorizationApplication',
|
||||||
|
meta: {
|
||||||
|
title: 'views.application.title',
|
||||||
|
activeMenu: '/system',
|
||||||
|
parentPath: '/system',
|
||||||
|
parentName: 'system',
|
||||||
|
},
|
||||||
|
component: () => import('@/views/system/resource-authorization/index.vue'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/system/authorization/knowledge',
|
||||||
|
name: 'authorizationKnowledge',
|
||||||
|
meta: {
|
||||||
|
title: 'views.knowledge.title',
|
||||||
|
activeMenu: '/system',
|
||||||
|
parentPath: '/system',
|
||||||
|
parentName: 'system',
|
||||||
|
},
|
||||||
|
component: () => import('@/views/system/resource-authorization/index.vue'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/system/authorization/tool',
|
||||||
|
name: 'authorizationTool',
|
||||||
|
meta: {
|
||||||
|
title: 'views.tool.title',
|
||||||
|
activeMenu: '/system',
|
||||||
|
parentPath: '/system',
|
||||||
|
parentName: 'system',
|
||||||
|
},
|
||||||
|
component: () => import('@/views/system/resource-authorization/index.vue'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/system/authorization/model',
|
||||||
|
name: 'authorizationModel',
|
||||||
|
meta: {
|
||||||
|
title: 'views.model.title',
|
||||||
|
activeMenu: '/system',
|
||||||
|
parentPath: '/system',
|
||||||
|
parentName: 'system',
|
||||||
|
},
|
||||||
|
component: () => import('@/views/system/resource-authorization/index.vue'),
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/system/shared',
|
path: '/system/shared',
|
||||||
|
|||||||
@ -8,9 +8,7 @@
|
|||||||
<el-radio :value="true" size="large">{{
|
<el-radio :value="true" size="large">{{
|
||||||
$t('views.resourceAuthorization.priority.role')
|
$t('views.resourceAuthorization.priority.role')
|
||||||
}}</el-radio>
|
}}</el-radio>
|
||||||
<el-radio :value="false" size="large">{{
|
<el-radio :value="false" size="large">{{ $t('common.custom') }}</el-radio>
|
||||||
$t('common.custom')
|
|
||||||
}}</el-radio>
|
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</div>
|
</div>
|
||||||
<el-input
|
<el-input
|
||||||
@ -33,17 +31,9 @@
|
|||||||
<el-table-column class-name="folder-flex" prop="name" :label="$t('common.name')">
|
<el-table-column class-name="folder-flex" prop="name" :label="$t('common.name')">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<div class="flex align-center">
|
<div class="flex align-center">
|
||||||
|
<!-- 文件夹 icon -->
|
||||||
<el-avatar
|
<el-avatar
|
||||||
v-if="isApplication && isAppIcon(row?.icon)"
|
v-if="row.isFolder"
|
||||||
style="background: none"
|
|
||||||
class="mr-12"
|
|
||||||
shape="square"
|
|
||||||
:size="20"
|
|
||||||
>
|
|
||||||
<img :src="row?.icon" alt="" />
|
|
||||||
</el-avatar>
|
|
||||||
<el-avatar
|
|
||||||
v-else-if="row.isFolder"
|
|
||||||
class="mr-12"
|
class="mr-12"
|
||||||
shape="square"
|
shape="square"
|
||||||
:size="20"
|
:size="20"
|
||||||
@ -55,10 +45,31 @@
|
|||||||
alt=""
|
alt=""
|
||||||
/>
|
/>
|
||||||
</el-avatar>
|
</el-avatar>
|
||||||
<LogoIcon v-else-if="isApplication" height="32px" class="mr-12" />
|
<!-- 知识库 icon -->
|
||||||
|
|
||||||
<KnowledgeIcon class="mr-12" :size="20" v-else-if="isKnowledge" :type="row.icon" />
|
<KnowledgeIcon class="mr-12" :size="20" v-else-if="isKnowledge" :type="row.icon" />
|
||||||
|
<!-- 应用/工具 自定义 icon -->
|
||||||
|
<el-avatar
|
||||||
|
v-else-if="isAppIcon(row?.icon) && !isModel"
|
||||||
|
style="background: none"
|
||||||
|
class="mr-12"
|
||||||
|
shape="square"
|
||||||
|
:size="20"
|
||||||
|
>
|
||||||
|
<img :src="row?.icon" alt="" />
|
||||||
|
</el-avatar>
|
||||||
|
<!-- 应用 icon -->
|
||||||
|
<LogoIcon v-else-if="isApplication" height="20px" class="mr-12" />
|
||||||
|
<!-- 工具 icon -->
|
||||||
|
<el-avatar v-else-if="isTool" class="avatar-green mr-12" shape="square" :size="20">
|
||||||
|
<img src="@/assets/node/icon_tool.svg" style="width: 58%" alt="" />
|
||||||
|
</el-avatar>
|
||||||
|
<!-- 模型 icon -->
|
||||||
|
<span
|
||||||
|
v-else-if="isModel"
|
||||||
|
style="width: 24px; height: 24px; display: inline-block"
|
||||||
|
class="mr-12"
|
||||||
|
:innerHTML="getProviderIcon(row)"
|
||||||
|
></span>
|
||||||
<span :title="row?.name">
|
<span :title="row?.name">
|
||||||
{{ row?.name }}
|
{{ row?.name }}
|
||||||
</span>
|
</span>
|
||||||
@ -160,11 +171,13 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, watch, computed } from 'vue'
|
import { ref, onMounted, watch, computed } from 'vue'
|
||||||
|
import type { Provider } from '@/api/type/model'
|
||||||
import { AuthorizationEnum } from '@/enums/system'
|
import { AuthorizationEnum } from '@/enums/system'
|
||||||
import { isAppIcon } from '@/utils/common'
|
import { isAppIcon } from '@/utils/common'
|
||||||
import { EditionConst } from '@/utils/permission/data'
|
import { EditionConst } from '@/utils/permission/data'
|
||||||
import { hasPermission } from '@/utils/permission/index'
|
import { hasPermission } from '@/utils/permission/index'
|
||||||
|
import useStore from '@/stores'
|
||||||
|
const { model } = useStore()
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
data: {
|
data: {
|
||||||
type: Array,
|
type: Array,
|
||||||
@ -185,7 +198,8 @@ const radioRole = computed({
|
|||||||
})
|
})
|
||||||
const isKnowledge = computed(() => props.type === AuthorizationEnum.KNOWLEDGE)
|
const isKnowledge = computed(() => props.type === AuthorizationEnum.KNOWLEDGE)
|
||||||
const isApplication = computed(() => props.type === AuthorizationEnum.APPLICATION)
|
const isApplication = computed(() => props.type === AuthorizationEnum.APPLICATION)
|
||||||
|
const isTool = computed(() => props.type === AuthorizationEnum.TOOL)
|
||||||
|
const isModel = computed(() => props.type === AuthorizationEnum.MODEL)
|
||||||
const dfsPermission = (arr: any = [], Name: string | number, e: boolean, idArr: any[]) => {
|
const dfsPermission = (arr: any = [], Name: string | number, e: boolean, idArr: any[]) => {
|
||||||
arr.map((item: any) => {
|
arr.map((item: any) => {
|
||||||
if (idArr.includes(item.id)) {
|
if (idArr.includes(item.id)) {
|
||||||
@ -218,6 +232,24 @@ function checkedOperateChange(Name: string | number, row: any, e: boolean) {
|
|||||||
dfsPermission(props.data, Name, e, [row.id])
|
dfsPermission(props.data, Name, e, [row.id])
|
||||||
emit('refreshData')
|
emit('refreshData')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const provider_list = ref<Array<Provider>>([])
|
||||||
|
function getProvider() {
|
||||||
|
model.asyncGetProvider().then((res: any) => {
|
||||||
|
provider_list.value = res?.data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const getProviderIcon = computed(() => {
|
||||||
|
return (row: any) => {
|
||||||
|
return provider_list.value.find((p) => p.provider === row.icon)?.icon
|
||||||
|
}
|
||||||
|
})
|
||||||
|
onMounted(() => {
|
||||||
|
if (isModel.value) {
|
||||||
|
getProvider()
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
:deep(.folder-flex) {
|
:deep(.folder-flex) {
|
||||||
|
|||||||
@ -52,7 +52,7 @@
|
|||||||
<div class="permission-setting p-24 flex" v-loading="rLoading">
|
<div class="permission-setting p-24 flex" v-loading="rLoading">
|
||||||
<div class="resource-authorization__table">
|
<div class="resource-authorization__table">
|
||||||
<h4 class="mb-4">{{ $t('views.resourceAuthorization.permissionSetting') }}</h4>
|
<h4 class="mb-4">{{ $t('views.resourceAuthorization.permissionSetting') }}</h4>
|
||||||
<el-tabs
|
<!-- <el-tabs
|
||||||
v-model="activeName"
|
v-model="activeName"
|
||||||
@tab-change="handleTabChange"
|
@tab-change="handleTabChange"
|
||||||
class="resource-authorization__tabs"
|
class="resource-authorization__tabs"
|
||||||
@ -62,18 +62,17 @@
|
|||||||
:key="item.value"
|
:key="item.value"
|
||||||
:label="item.label"
|
:label="item.label"
|
||||||
:name="item.value"
|
:name="item.value"
|
||||||
>
|
> -->
|
||||||
<PermissionSetting
|
<PermissionSetting
|
||||||
:key="index"
|
:data="activeData.data"
|
||||||
:data="item.data"
|
:type="activeData.type"
|
||||||
:type="item.value"
|
:tableHeight="tableHeight"
|
||||||
:tableHeight="tableHeight"
|
:manage="isManage(currentType)"
|
||||||
:manage="isManage(currentType)"
|
@refreshData="refreshData"
|
||||||
@refreshData="refreshData"
|
v-model:isRole="activeData.isRole"
|
||||||
v-model:isRole="item.isRole"
|
></PermissionSetting>
|
||||||
></PermissionSetting>
|
<!-- </el-tab-pane> -->
|
||||||
</el-tab-pane>
|
<!-- </el-tabs> -->
|
||||||
</el-tabs>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="submit-button">
|
<div class="submit-button">
|
||||||
@ -87,6 +86,7 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onMounted, ref, reactive, watch, computed } from 'vue'
|
import { onMounted, ref, reactive, watch, computed } from 'vue'
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
import AuthorizationApi from '@/api/system/resource-authorization'
|
import AuthorizationApi from '@/api/system/resource-authorization'
|
||||||
import PermissionSetting from './component/PermissionSetting.vue'
|
import PermissionSetting from './component/PermissionSetting.vue'
|
||||||
import { MsgSuccess, MsgConfirm } from '@/utils/message'
|
import { MsgSuccess, MsgConfirm } from '@/utils/message'
|
||||||
@ -98,6 +98,7 @@ import { EditionConst } from '@/utils/permission/data'
|
|||||||
import { hasPermission } from '@/utils/permission/index'
|
import { hasPermission } from '@/utils/permission/index'
|
||||||
import WorkspaceApi from '@/api/workspace/workspace.ts'
|
import WorkspaceApi from '@/api/workspace/workspace.ts'
|
||||||
import type { WorkspaceItem } from '@/api/type/workspace'
|
import type { WorkspaceItem } from '@/api/type/workspace'
|
||||||
|
const route = useRoute()
|
||||||
const { user } = useStore()
|
const { user } = useStore()
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const rLoading = ref(false)
|
const rLoading = ref(false)
|
||||||
@ -106,37 +107,46 @@ const filterMember = ref<any[]>([]) // 搜索过滤后列表
|
|||||||
const currentUser = ref<string>('')
|
const currentUser = ref<string>('')
|
||||||
const currentType = ref<string>('')
|
const currentType = ref<string>('')
|
||||||
const filterText = ref('')
|
const filterText = ref('')
|
||||||
|
|
||||||
const activeName = ref(AuthorizationEnum.KNOWLEDGE)
|
|
||||||
const tableHeight = ref(0)
|
const tableHeight = ref(0)
|
||||||
|
|
||||||
const settingTags = reactive([
|
const settingTags = reactive([
|
||||||
{
|
{
|
||||||
label: t('views.knowledge.title'),
|
label: t('views.knowledge.title'),
|
||||||
value: AuthorizationEnum.KNOWLEDGE,
|
type: AuthorizationEnum.KNOWLEDGE,
|
||||||
data: [] as any,
|
data: [] as any,
|
||||||
isRole: false,
|
isRole: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('views.application.title'),
|
label: t('views.application.title'),
|
||||||
value: AuthorizationEnum.APPLICATION,
|
type: AuthorizationEnum.APPLICATION,
|
||||||
data: [] as any,
|
data: [] as any,
|
||||||
isRole: false,
|
isRole: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('views.tool.title'),
|
label: t('views.tool.title'),
|
||||||
value: AuthorizationEnum.TOOL,
|
type: AuthorizationEnum.TOOL,
|
||||||
data: [] as any,
|
data: [] as any,
|
||||||
isRole: false,
|
isRole: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('views.model.title'),
|
label: t('views.model.title'),
|
||||||
value: AuthorizationEnum.MODEL,
|
type: AuthorizationEnum.MODEL,
|
||||||
data: [] as any,
|
data: [] as any,
|
||||||
isRole: false,
|
isRole: false,
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
|
||||||
|
// 当前激活的数据类型(应用/知识库/模型/工具)
|
||||||
|
|
||||||
|
const activeData = computed(() => {
|
||||||
|
var lastIndex = route.path.lastIndexOf('/')
|
||||||
|
const currentPathType = route.path.substring(lastIndex + 1).toUpperCase()
|
||||||
|
return settingTags.filter((item) => {
|
||||||
|
return item.type === currentPathType
|
||||||
|
})[0]
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
watch(filterText, (val: any) => {
|
watch(filterText, (val: any) => {
|
||||||
if (val) {
|
if (val) {
|
||||||
filterMember.value = memberList.value.filter((v: any) =>
|
filterMember.value = memberList.value.filter((v: any) =>
|
||||||
@ -287,7 +297,7 @@ const handleTabChange = () => {
|
|||||||
function getFolder() {
|
function getFolder() {
|
||||||
return AuthorizationApi.getSystemFolder(
|
return AuthorizationApi.getSystemFolder(
|
||||||
currentWorkspaceId.value || 'default',
|
currentWorkspaceId.value || 'default',
|
||||||
activeName.value,
|
activeData.value.type,
|
||||||
{},
|
{},
|
||||||
loading,
|
loading,
|
||||||
)
|
)
|
||||||
@ -305,12 +315,12 @@ const getWholeTree = async (user_id: string) => {
|
|||||||
settingTags.map((item: any) => {
|
settingTags.map((item: any) => {
|
||||||
let folderIdMap = []
|
let folderIdMap = []
|
||||||
const folderTree = cloneDeep((parentRes as unknown as any).data)
|
const folderTree = cloneDeep((parentRes as unknown as any).data)
|
||||||
if (Object.keys(childrenRes.data).indexOf(item.value) !== -1) {
|
if (Object.keys(childrenRes.data).indexOf(item.type) !== -1) {
|
||||||
item.isRole =
|
item.isRole =
|
||||||
childrenRes.data[item.value].length > 0 && hasPermission([EditionConst.IS_EE], 'OR')
|
childrenRes.data[item.type].length > 0 && hasPermission([EditionConst.IS_EE], 'OR')
|
||||||
? childrenRes.data[item.value][0].auth_type == 'ROLE'
|
? childrenRes.data[item.type][0].auth_type == 'ROLE'
|
||||||
: false
|
: false
|
||||||
folderIdMap = getFolderIdMap(childrenRes.data[item.value])
|
folderIdMap = getFolderIdMap(childrenRes.data[item.type])
|
||||||
dfsFolder(folderTree, folderIdMap)
|
dfsFolder(folderTree, folderIdMap)
|
||||||
const permissionHalf = {
|
const permissionHalf = {
|
||||||
VIEW: [],
|
VIEW: [],
|
||||||
@ -329,7 +339,7 @@ const getWholeTree = async (user_id: string) => {
|
|||||||
|
|
||||||
const refreshData = () => {
|
const refreshData = () => {
|
||||||
settingTags.map((item: any) => {
|
settingTags.map((item: any) => {
|
||||||
if (activeName.value === item.value) {
|
if (activeData.value.type === item.type) {
|
||||||
const permissionHalf = {
|
const permissionHalf = {
|
||||||
VIEW: [],
|
VIEW: [],
|
||||||
MANAGE: [],
|
MANAGE: [],
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user