File tree Expand file tree Collapse file tree 1 file changed +11
-23
lines changed
Expand file tree Collapse file tree 1 file changed +11
-23
lines changed Original file line number Diff line number Diff line change @@ -300,33 +300,21 @@ export default {
300300 }
301301 },
302302 setDefaultRole () {
303+ if (this .roles .length === 0 ) return
304+
305+ let targetRoleType = null
306+
303307 if (this .isAdmin ()) {
304- if (this .isNonRootDomain ) {
305- const domainAdminRole = this .roles .find (role => role .type === ' DomainAdmin' )
306- if (domainAdminRole) {
307- this .form .roleid = domainAdminRole .id
308- return
309- }
310- } else {
311- const rootAdminRole = this .roles .find (role => role .type === ' Admin' )
312- if (rootAdminRole) {
313- this .form .roleid = rootAdminRole .id
314- return
315- }
316- }
308+ targetRoleType = this .isNonRootDomain ? ' DomainAdmin' : ' Admin'
309+ } else if (this .isDomainAdmin ()) {
310+ targetRoleType = ' User'
317311 }
318312
319- if (this .isDomainAdmin ()) {
320- const userRole = this .roles .find (role => role .type === ' User' )
321- if (userRole) {
322- this .form .roleid = userRole .id
323- return
324- }
325- }
313+ const targetRole = targetRoleType
314+ ? this .roles .find (role => role .type === targetRoleType)
315+ : this .roles [0 ]
326316
327- if (this .roles .length > 0 ) {
328- this .form .roleid = this .roles [0 ].id
329- }
317+ this .form .roleid = (targetRole || this .roles [0 ]).id
330318 },
331319 async validateConfirmPassword (rule , value ) {
332320 if (! value || value .length === 0 ) {
You can’t perform that action at this time.
0 commit comments