From a77b968a17022397ed4e9c77fe5ed04db5c7c6b2 Mon Sep 17 00:00:00 2001 From: lai <371757574@qq.com> Date: Fri, 27 Sep 2024 17:56:41 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=90=E5=88=B6=E6=96=B0=E5=A2=9E=E6=97=B6?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E7=A7=9F=E6=88=B7=E6=95=B0=E6=8D=AE=E6=97=B6?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E7=A7=9F=E6=88=B7=E8=A7=92=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/i18n/locales/en-US.ts | 1 + src/i18n/locales/zh-CN.ts | 1 + src/views/system/user/index.vue | 21 +++++++++++++++++---- 3 files changed, 19 insertions(+), 4 deletions(-) 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')" >