6969 :deleteButtonDisabled =" deleteButtonDisabled"
7070 />
7171 <template #footer >
72- <el-button @click.prevent =" visible = false" > {{ $t('common.cancel') }}</el-button >
73- <el-button type =" primary" @click =" submit(userFormRef)" :loading =" loading" >
74- {{ $t('common.save') }}
75- </el-button >
72+ <div style =" display : flex ; width : 100% ;" >
73+ <el-button @click =" openDialog" v-if =" !isEdit && showPermission" >
74+ {{ $t('views.system.resourceAuthorization.setting.defaultPermission') }}
75+ </el-button >
76+ <div style =" margin-left : auto ;" >
77+ <el-button @click.prevent =" visible = false" >{{ $t('common.cancel') }}</el-button >
78+ <el-button type =" primary" @click =" submit(userFormRef)" :loading =" loading" >
79+ {{ $t('common.save') }}
80+ </el-button >
81+ </div >
82+ </div >
83+
7684 </template >
7785 </el-drawer >
86+ <el-dialog
87+ v-model =" dialogVisible"
88+ :title =" $t('views.system.resourceAuthorization.setting.defaultPermission')"
89+ destroy-on-close
90+ @close =" closeDialog"
91+ >
92+ <template #header =" { titleId , titleClass } " v-if =" user .isEE ()" >
93+ <div class =" dialog-header" >
94+ <h4 :id =" titleId" :class =" titleClass" style =" margin : 0 ;" >
95+ {{ $t('views.system.resourceAuthorization.setting.defaultPermission') }}
96+ <span class =" dialog-subtitle" >
97+ {{ $t('views.system.resourceAuthorization.setting.defaultPermissionTip') }}
98+ </span >
99+ </h4 >
100+ </div >
101+ </template >
102+ <el-radio-group v-model =" radioPermission" class =" radio-block" >
103+ <template v-for =" (item , index ) in permissionOptions " :key =" index " >
104+ <el-radio :value =" item.value" class =" mr-16" >
105+ <p class =" color-text-primary lighter" >{{ item.label }}</p >
106+ <el-text class =" color-secondary lighter" >{{ item.desc }}</el-text >
107+ </el-radio >
108+ </template >
109+ </el-radio-group >
110+ <template #footer >
111+ <div class =" dialog-footer mt-24" >
112+ <el-button @click =" closeDialog" > {{ $t('common.cancel') }}</el-button >
113+ <el-button type =" primary" @click =" submitDialog" > {{ $t('common.confirm') }}</el-button >
114+ </div >
115+ </template >
116+ </el-dialog >
78117</template >
79118<script setup lang="ts">
80119import {ref , reactive , watch , onBeforeMount , computed } from ' vue'
@@ -85,8 +124,10 @@ import {t} from '@/locales'
85124import type {FormItemModel } from ' @/api/type/role'
86125import WorkspaceApi from ' @/api/workspace/workspace'
87126import MemberFormContent from ' @/views/system/role/component/MemberFormContent.vue'
88- import {RoleTypeEnum } from ' @/enums/system'
127+ import {AuthorizationEnum , RoleTypeEnum } from ' @/enums/system'
89128import useStore from ' @/stores'
129+ import {hasPermission } from " @/utils/permission" ;
130+ import {EditionConst } from " @/utils/permission/data.ts" ;
90131
91132const {user} = useStore ()
92133const props = defineProps ({
@@ -109,15 +150,56 @@ const memberFormContentLoading = ref(false)
109150const formItemModel = ref <FormItemModel []>([])
110151const roleFormItem = ref <FormItemModel []>([])
111152const adminRoleList = ref <any []>([])
153+ const userRoleList = ref <any []>([])
112154const workspaceFormItem = ref <FormItemModel []>([])
113155
114156const isAdmin = computed (() => userForm .value [' id' ] === ' f0dd8f71-e4ee-11ee-8c84-a8a1595801ab' )
157+ const dialogVisible = ref (false )
158+ const radioPermission = ref (' NOT_AUTH' )
159+ const defaultPermission = ref (' NOT_AUTH' )
160+ const permissionOptions = computed (() => {
161+ const baseOptions = [
162+ {
163+ label: t (' views.system.resourceAuthorization.setting.check' ),
164+ value: AuthorizationEnum .VIEW ,
165+ desc: t (' views.system.resourceAuthorization.setting.checkDesc' ),
166+ },
167+ {
168+ label: t (' views.system.resourceAuthorization.setting.management' ),
169+ value: AuthorizationEnum .MANAGE ,
170+ desc: t (' views.system.resourceAuthorization.setting.managementDesc' ),
171+ },
172+ {
173+ label: t (' views.system.resourceAuthorization.setting.notAuthorized' ),
174+ value: AuthorizationEnum .NOT_AUTH ,
175+ desc: ' ' ,
176+ }
177+ ];
115178
116- function deleteButtonDisabled(element : any ) {
117- if (isAdmin .value && [' ADMIN' , ' WORKSPACE_MANAGE' , ' USER' ].includes (element .role_id )) {
179+ if (hasPermission ([EditionConst .IS_EE , EditionConst .IS_PE ], ' OR' )) {
180+ baseOptions .splice (2 , 0 , {
181+ label: t (' views.system.resourceAuthorization.setting.role' ),
182+ value: AuthorizationEnum .ROLE ,
183+ desc: t (' views.system.resourceAuthorization.setting.roleDesc' ),
184+ });
185+ }
186+
187+ return baseOptions ;
188+ });
189+
190+ const showPermission = computed (() => {
191+ // 社区版本的可以显示 别的版本 过期了 也可以显示
192+ if (user .isCE () || user .isExpire ()) {
118193 return true
119194 }
120- return false
195+ const hasUserRole = list .value .some ((item ) => userRoleList .value .includes (item .role_id ));
196+ return (user .isEE () || user .isPE ()) && hasUserRole
197+ })
198+
199+
200+ function deleteButtonDisabled(element : any ) {
201+ return isAdmin .value && [' ADMIN' , ' WORKSPACE_MANAGE' , ' USER' ].includes (element .role_id );
202+
121203}
122204
123205async function getRoleFormItem() {
@@ -145,6 +227,10 @@ async function getRoleFormItem() {
145227 },
146228 ]
147229 adminRoleList .value = res .data .filter ((item ) => item .type === RoleTypeEnum .ADMIN )
230+ userRoleList .value = res .data
231+ .filter ((item ) => item .type === RoleTypeEnum .USER )
232+ .map ((item ) => item .id )
233+
148234 } catch (e ) {
149235 console .error (e )
150236 }
@@ -352,6 +438,7 @@ const submit = async (formEl: FormInstance | undefined) => {
352438 visible .value = false
353439 })
354440 } else {
441+ params .defaultPermission = defaultPermission .value
355442 userManageApi
356443 .postUserManage (params , loading )
357444 .then ((res ) => {
@@ -369,6 +456,35 @@ const submit = async (formEl: FormInstance | undefined) => {
369456 })
370457}
371458
459+ const openDialog = () => {
460+ dialogVisible .value = true
461+ }
462+
463+ const closeDialog = () => {
464+ dialogVisible .value = false
465+ }
466+
467+ const submitDialog = () => {
468+ defaultPermission .value = radioPermission .value
469+ closeDialog ()
470+ }
471+
472+
372473defineExpose ({open })
373474 </script >
374- <style lang="scss" scoped></style >
475+ <style lang="scss" scoped>
476+ .dialog-header {
477+ h4 {
478+ display : flex ;
479+ align-items : baseline ;
480+ gap : 8px ;
481+ margin : 0 ;
482+ }
483+
484+ .dialog-subtitle {
485+ font-size : 14px ;
486+ color : var (--el-text-color-secondary );
487+ }
488+ }
489+
490+ </style >
0 commit comments