111111 ]"
112112 >
113113 <el-row :gutter =" 16" style =" margin-left : 10px " >
114- <el-col :span =" 12" >
115- <div style =" display : flex ; align-items : center ; gap : 8px ; min-width : 0 " >
116- <span style =" font-size : 13px ; white-space : nowrap " >
114+ <el-col :span =" 24" >
115+ <div class =" flex" >
116+ <span style =" font-size : 13px ; white-space : nowrap ;width : 50px "
117+ class =" text-right mr-8" >
117118 {{ $t('views.role.member.role') }}
118119 </span >
119120 <el-select
120121 v-model =" form.role_id"
121122 :placeholder =" `${$t('common.selectPlaceholder')}${$t('views.role.member.role')}`"
122- style =" flex : 1 ; min-width : 180px "
123123 @change =" handleRoleChange"
124+ class =" w-240"
124125 >
125126 <el-option
126127 v-for =" role in roleOptions"
131132 </el-select >
132133 </div >
133134 </el-col >
134- <el-col :span =" 12" v-if =" user.isEE() && showWorkspaceSelector" >
135- <div style =" display : flex ; align-items : center ; gap : 8px ; min-width : 0 " >
136- <span style =" font-size : 13px ; white-space : nowrap " >
135+ <el-col :span =" 24" v-if =" user.isEE() && showWorkspaceSelector" class =" mt-16" >
136+ <div class =" flex" >
137+ <span style =" font-size : 13px ; white-space : nowrap ;width : 50px "
138+ class =" text-right mr-8" >
137139 {{ $t('views.role.member.workspace') }}
138140 </span >
139141 <el-select
140142 v-model =" form.workspace_id"
141143 :placeholder =" `${$t('common.selectPlaceholder')}${$t('views.role.member.workspace')}`"
142- style = " flex : 1 ; min-width : 180 px "
144+ class = " w-240 "
143145 >
144146 <el-option
145147 v-for =" workspace in workspaceOptions"
150152 </el-select >
151153 </div >
152154 </el-col >
155+ <el-col :span =" 24" v-if =" (user.isEE() || user.isPE()) && showPermissionSelector"
156+ class =" mt-16" >
157+ <div class =" flex" >
158+ <span style =" font-size : 13px ; white-space : nowrap ;width : 50px "
159+ class =" text-right mr-8" >
160+ {{ $t('views.system.resourceAuthorization.title') }}
161+ </span >
162+ <el-select
163+ v-model =" form.permission"
164+ :placeholder =" `${$t('common.selectPlaceholder')}${$t('views.system.resourceAuthorization.title')}`"
165+ class =" w-240"
166+ >
167+ <el-option
168+ v-for =" permission in permissionOptions"
169+ :key =" permission.value"
170+ :label =" permission.label"
171+ :value =" permission.value"
172+ />
173+ </el-select >
174+ </div >
175+ </el-col >
153176 </el-row >
154177 </el-form-item >
155178 </el-form >
174197<script setup lang="ts">
175198import {ref , onMounted , computed } from ' vue'
176199import {ComplexPermission } from ' @/utils/permission/type'
177- import {PermissionConst , RoleConst } from ' @/utils/permission/data'
200+ import {EditionConst , PermissionConst , RoleConst } from ' @/utils/permission/data'
178201import type {FormInstance } from ' element-plus'
179202import {t } from ' @/locales'
180203import authApi from ' @/api/system-settings/auth-setting.ts'
181204import {MsgSuccess } from ' @/utils/message.ts'
182205import WorkspaceApi from ' @/api/workspace/workspace.ts'
183206import useStore from ' @/stores'
207+ import {AuthorizationEnum } from " @/enums/system.ts" ;
208+ import {hasPermission } from " @/utils/permission" ;
184209
185210const loginMethods = ref <Array <{ label: string ; value: string }>>([])
186211const loading = ref (false )
@@ -194,6 +219,7 @@ const form = ref<any>({
194219 lock_time: 10 ,
195220 role_id: ' USER' ,
196221 workspace_id: ' default' ,
222+ permission: ' NOT_AUTH' ,
197223})
198224
199225const normalizeInputValue = (val : number | null ): number => {
@@ -234,6 +260,7 @@ const submit = async () => {
234260 lock_time: form .value .lock_time ,
235261 role_id: form .value .role_id ,
236262 workspace_id: form .value .workspace_id ,
263+ permission: form .value .permission ,
237264 }
238265 await authApi .putLoginSetting (params )
239266 MsgSuccess (t (' common.saveSuccess' ))
@@ -250,7 +277,36 @@ const workspaceOptions = ref<Array<{ id: string; name: string }>>([])
250277const {user} = useStore ()
251278const selectedRoleType = ref <string >(' ' ) // 存储选中角色类型,用于控制 workspace 显示
252279const showWorkspaceSelector = computed (() => selectedRoleType .value !== ' ADMIN' )
280+ const showPermissionSelector = computed (() => selectedRoleType .value === ' USER' )
281+ const permissionOptions = computed (() => {
282+ const baseOptions = [
283+ {
284+ label: t (' views.system.resourceAuthorization.setting.check' ),
285+ value: AuthorizationEnum .VIEW ,
286+ desc: t (' views.system.resourceAuthorization.setting.checkDesc' ),
287+ },
288+ {
289+ label: t (' views.system.resourceAuthorization.setting.management' ),
290+ value: AuthorizationEnum .MANAGE ,
291+ desc: t (' views.system.resourceAuthorization.setting.managementDesc' ),
292+ },
293+ {
294+ label: t (' views.system.resourceAuthorization.setting.notAuthorized' ),
295+ value: AuthorizationEnum .NOT_AUTH ,
296+ desc: ' ' ,
297+ }
298+ ];
299+
300+ if (hasPermission ([EditionConst .IS_EE , EditionConst .IS_PE ], ' OR' )) {
301+ baseOptions .splice (2 , 0 , {
302+ label: t (' views.system.resourceAuthorization.setting.role' ),
303+ value: AuthorizationEnum .ROLE ,
304+ desc: t (' views.system.resourceAuthorization.setting.roleDesc' ),
305+ });
306+ }
253307
308+ return baseOptions ;
309+ });
254310// 当角色变更时更新 selectedRoleType
255311const handleRoleChange = (roleId : string ) => {
256312 const selectedRole = roleOptions .value .find ((role ) => role .id === roleId )
@@ -304,6 +360,7 @@ onMounted(async () => {
304360 lock_time: data .lock_time ?? form .value .lock_time ?? 10 ,
305361 role_id: data .role_id ?? form .value .role_id ?? ' USER' ,
306362 workspace_id: data .workspace_id ?? form .value .workspace_id ?? ' default' ,
363+ permission: data .permission ?? form .value .permission ?? ' NOT_AUTH' ,
307364 }
308365 loginMethods .value = Array .isArray (data .auth_types ) ? data .auth_types : []
309366
0 commit comments