diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index 48575b7f..0c7f4745 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -396,17 +396,6 @@ 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; @@ -792,20 +781,33 @@ let deptTreeData = ref([]); /**查询部门下拉树结构 */ function fnGetDeptTree() { 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') { - deptTreeData.value.push({ - childern: undefined, - title: item.tenantName, - key: item.tenantId, - ...item, - }); + listTenant({ parentId: 0 }) + .then(res => { + if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) { + res.data.forEach((item: any) => { + if (item.parentId === '0') { + deptTreeData.value.push({ + childern: undefined, + title: item.tenantName, + key: item.tenantId, + ...item, + }); + } + }); + } + }) + .finally(() => { + //若长度为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); } - }); - } - }); + } + }); } function handleChange(value: any, options: any) {