diff --git a/src/i18n/locales/en-US.ts b/src/i18n/locales/en-US.ts index ee746670..ff7bdf2a 100644 --- a/src/i18n/locales/en-US.ts +++ b/src/i18n/locales/en-US.ts @@ -1715,6 +1715,7 @@ export default { lock:'Lock', inactive:'Inactive', active:'Active', + permissionTip:'If want to select a tenant role, make sure there is at least one tenant in the tenant management.', }, config: { configName: "Config Name", diff --git a/src/i18n/locales/zh-CN.ts b/src/i18n/locales/zh-CN.ts index 437be291..d24bacee 100644 --- a/src/i18n/locales/zh-CN.ts +++ b/src/i18n/locales/zh-CN.ts @@ -1715,6 +1715,7 @@ export default { lock:'锁定', inactive:'未激活', active:'激活', + permissionTip:'若要选择租户角色,需保证起码租户管理中有一个租户', }, config: { configName: "参数名称", diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index 100607bc..48575b7f 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -369,6 +369,7 @@ function fnModalVisibleByVive(userId: string | number) { * @param userId 用户编号ID, 不传为新增 */ function fnModalVisibleByEdit(userId?: string | number) { + fnGetDeptTree(); // 获取部门树 if (!userId) { modalStateFrom.resetFields(); if (modalState.confirmLoading) return; @@ -395,6 +396,17 @@ function fnModalVisibleByEdit(userId?: string | number) { modalState.from = Object.assign(modalState.from, user); modalState.from.roleIds = roleIds; modalState.from.postIds = postIds; + //deptTreeData.value=[]; + //若长度为0 删除租户选项 + if (deptTreeData.value.length === 0) { + const index = modalState.options.roles.findIndex( + (role: any) => role.roleKey === 'tenant' + ); + + if (index !== -1) { + modalState.options.roles.splice(index, 1); + } + } modalState.title = t('common.addText') + t('views.system.user.userInfo'); modalState.visibleByEdit = true; @@ -431,8 +443,8 @@ function fnModalVisibleByEdit(userId?: string | number) { (role: any) => role.roleKey === 'tenant' ); - if(modalState.showTenant) fnGetDeptTree(); - + if (modalState.showTenant) fnGetDeptTree(); + modalState.title = t('common.editText') + t('views.system.user.userInfo'); modalState.visibleByEdit = true; @@ -779,8 +791,8 @@ let deptTreeData = ref([]); /**查询部门下拉树结构 */ function fnGetDeptTree() { - deptTreeData.value=[]; //reSet - listTenant({ parentId: 0 }).then(res => { + deptTreeData.value = []; //reSet + listTenant({ parentId: 0 }).then(res => { if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) { res.data.forEach((item: any) => { if (item.parentId === '0') { @@ -1467,6 +1479,7 @@ onMounted(() => { name="roleIds" :label-col="{ span: 3 }" v-perms:has="['system:user:editRole']" + :help="t('views.system.user.permissionTip')" >