11<template >
22 <el-scrollbar v-loading =" loading" >
33 <app-table :data =" tableData" border :span-method =" objectSpanMethod" >
4- <el-table-column prop =" module" :width =" 130" :label =" $t('views.role.permission.moduleName')" />
4+ <el-table-column prop =" module" :width =" 130" :label =" $t('views.role.permission.moduleName')" />
55 <el-table-column
66 prop =" name"
77 :width =" 150"
4949</template >
5050
5151<script setup lang="ts">
52- import { ref , watch , computed } from ' vue'
52+ import {ref , watch , computed } from ' vue'
5353import type {
5454 RoleItem ,
5555 RolePermissionItem ,
5656 RoleTableDataItem ,
5757 ChildrenPermissionItem ,
5858} from ' @/api/type/role'
59- import { loadPermissionApi } from ' @/utils/dynamics-api/permission-api'
59+ import {loadPermissionApi } from ' @/utils/dynamics-api/permission-api'
6060import RoleApi from ' @/api/system/role'
61- import { MsgSuccess } from ' @/utils/message'
62- import { t } from ' @/locales'
61+ import {MsgSuccess } from ' @/utils/message'
62+ import {t } from ' @/locales'
63+ import {hasPermission } from " @/utils/permission" ;
64+ import {EditionConst , RoleConst } from " @/utils/permission/data.ts" ;
6365
6466const props = defineProps <{
6567 currentRole? : RoleItem
6668}>()
6769
6870const loading = ref (false )
6971const tableData = ref <RoleTableDataItem []>([])
70- const disabled = computed (() => props .currentRole ?.internal ) // TODO 权限
72+ const needDisable = computed (() => {
73+ const isEeOrPe = hasPermission ([EditionConst .IS_EE , EditionConst .IS_PE ], ' OR' )
74+ const isAdminOrExtendAdmin = hasPermission ([RoleConst .ADMIN , RoleConst .EXTENDS_ADMIN ], ' OR' )
75+ const isWorkspaceManage =
76+ hasPermission (
77+ [
78+ RoleConst .WORKSPACE_MANAGE .getWorkspaceRole ,
79+ RoleConst .EXTENDS_WORKSPACE_MANAGE .getWorkspaceRole ,
80+ ],
81+ ' OR'
82+ )
83+
84+ if (! isEeOrPe ) {
85+ return false
86+ }
87+
88+ if (isAdminOrExtendAdmin ) {
89+ return false
90+ }
91+
92+ return isWorkspaceManage
93+ })
94+ const disabled = computed (() => props .currentRole ?.internal || needDisable .value )
7195
7296function transformData(data : RolePermissionItem []) {
7397 const transformedData: RoleTableDataItem [] = []
@@ -136,7 +160,7 @@ function handleCheckAll(checked: boolean) {
136160 })
137161}
138162
139- const objectSpanMethod = ({ row , column , rowIndex , columnIndex }: any ) => {
163+ const objectSpanMethod = ({row , column , rowIndex , columnIndex }: any ) => {
140164 if (columnIndex === 0 ) {
141165 const sameModuleRows = tableData .value .filter ((item ) => item .module === row .module )
142166 const firstRowIndex = tableData .value .findIndex ((item ) => item .module === row .module )
@@ -154,7 +178,7 @@ const objectSpanMethod = ({ row, column, rowIndex, columnIndex }: any) => {
154178 }
155179}
156180
157- watch (() => props .currentRole ?.id , getRolePermission , { immediate: true })
181+ watch (() => props .currentRole ?.id , getRolePermission , {immediate: true })
158182
159183async function handleSave() {
160184 try {
0 commit comments