{{ 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);
+ }
+ }