diff --git a/frontend/src/components/business/ms-menu/index.vue b/frontend/src/components/business/ms-menu/index.vue index 8438793fb9..c8e87c068d 100644 --- a/frontend/src/components/business/ms-menu/index.vue +++ b/frontend/src/components/business/ms-menu/index.vue @@ -123,6 +123,7 @@ try { Message.loading(t('personal.switchOrgLoading')); await switchUserOrg(id, userStore.id || ''); + switchOrgVisible.value = false; Message.clear(); Message.success(t('personal.switchOrgSuccess')); personalMenusVisible.value = false; @@ -145,6 +146,7 @@ } }); + const isActiveSwitchOrg = ref(false); const personalMenus = [ { label: t('personal.info'), @@ -155,10 +157,16 @@ }, { label: t('personal.switchOrg'), - icon: , + icon: () => ( + + ), isTrigger: true, event: () => { switchOrgVisible.value = true; + isActiveSwitchOrg.value = true; }, }, { @@ -171,6 +179,14 @@ }, ]; + watch( + () => personalMenusVisible.value, + (val) => { + if (!val) { + isActiveSwitchOrg.value = false; + } + } + ); const personalInfoMenu = () => { return ( ( - <> +
- - {orgList.value.map((item) => ( - - {item.name} - {item.id === appStore.currentOrgId ? ( - - {t('personal.currentOrg')} - - ) : null} - - ))} - + +
+ {orgList.value.map((item) => ( +
{ + switchOrg(item.id); + }} + > + +
{item.name}
+
+ {item.id === appStore.currentOrgId ? ( + + {t('personal.currentOrg')} + + ) : null} +
+ ))} +
+
), }} - onSelect={(orgId: string) => { - switchOrg(orgId); - }} >
{ if (typeof e.event === 'function') { e.event(); } }} > - {e.icon} + {e.icon()} {e.label}
- +
); } return ( @@ -434,6 +462,20 @@ } } } + .switch-org-dropdown { + @apply absolute max-h-none; + + width: 300px; + .arco-trigger-popup-wrapper { + @apply max-h-full; + .switch-org-dropdown-list { + @apply overflow-y-auto; + .ms-scroll-bar(); + + max-height: 200px; + } + } + } .active-org { color: rgb(var(--primary-5)); background-color: rgb(var(--primary-1)); diff --git a/frontend/src/components/business/ms-personal-drawer/components/baseInfo.vue b/frontend/src/components/business/ms-personal-drawer/components/baseInfo.vue index c1ec7e42d8..8bb40590df 100644 --- a/frontend/src/components/business/ms-personal-drawer/components/baseInfo.vue +++ b/frontend/src/components/business/ms-personal-drawer/components/baseInfo.vue @@ -52,7 +52,7 @@ /> - + {{ t('common.update') }} {{ t('common.cancel') }} @@ -89,11 +89,11 @@ class="check-icon" /> -
+
{{ t('ms.personal.avatar', { index: index }) }}
([ { @@ -162,6 +164,19 @@ phone: userStore.phone, }); const baseInfoFormRef = ref(); + const orgList = ref([]); + + onBeforeMount(async () => { + try { + loading.value = true; + const res = await getBaseInfo(userStore.id || ''); + console.log(res); + } catch (error) { + // eslint-disable-next-line no-console + console.log(error); + } + }); + const updateLoading = ref(false); function cancelEdit() { @@ -194,12 +209,20 @@ } } - function updateBaseInfo() { + function editBaseInfo() { baseInfoFormRef.value?.validate(async (errors) => { if (!errors) { try { updateLoading.value = true; + await updateBaseInfo({ + id: userStore.id || '', + username: baseInfoForm.value.name || '', + email: baseInfoForm.value.email || '', + phone: baseInfoForm.value.phone || '', + avatar: userStore.avatar || '', + }); Message.success(t('common.updateSuccess')); + await userStore.isLogin(); isEdit.value = false; } catch (error) { // eslint-disable-next-line no-console @@ -212,25 +235,8 @@ } const avatarModalVisible = ref(false); - - async function handleChangeAvatarConfirm(done: (closed: boolean) => void) { - try { - // if (replaceVersion.value !== '') { - // await useLatestVersion(replaceVersion.value); - // } - // await toggleVersionStatus(activeRecord.value.id); - Message.success(t('common.updateSuccess')); - } catch (error) { - // eslint-disable-next-line no-console - console.log(error); - done(false); - } finally { - done(true); - } - } - const activeAvatarType = ref<'builtIn' | 'word'>('builtIn'); - const activeAvatar = ref('default'); + const activeAvatar = ref('default'); const avatarList = ref([]); let i = 1; while (i <= 46) { @@ -238,9 +244,29 @@ i++; } - function changeAvatar(avatar: string | number) { + function changeAvatar(avatar: string) { activeAvatar.value = avatar; } + + async function handleChangeAvatarConfirm(done: (closed: boolean) => void) { + try { + await updateBaseInfo({ + id: userStore.id || '', + username: baseInfoForm.value.name || '', + email: baseInfoForm.value.email || '', + phone: baseInfoForm.value.phone || '', + avatar: activeAvatar.value, + }); + Message.success(t('common.updateSuccess')); + await userStore.isLogin(); + } catch (error) { + // eslint-disable-next-line no-console + console.log(error); + done(false); + } finally { + done(true); + } + }