auth-web/src/views/account-settings/components/account-management.vue

88 lines
2.4 KiB
Vue
Raw Normal View History

2024-10-22 16:41:04 +08:00
<script lang="tsx" setup>
import { reactive, ref } from 'vue';
import { deviceDetection } from '@pureadmin/utils';
2024-10-22 16:41:04 +08:00
import { $t } from '@/plugins/i18n';
2025-04-25 16:21:15 +08:00
import { addDialog } from '@/components/ReDialog/index';
2024-10-22 16:41:04 +08:00
import { useAdminUserStore } from '@/store/system/adminUser';
import ResetPasswordDialog from '@/components/Table/ResetPasswords.vue';
import { removeToken } from '@/utils/auth';
import { useRouter } from 'vue-router';
2024-10-22 16:41:04 +08:00
const router = useRouter();
2025-04-25 16:21:15 +08:00
const adminUserStore = useAdminUserStore();
2024-10-22 16:41:04 +08:00
2025-04-25 16:21:15 +08:00
// 重置密码表单校验Ref
const ruleFormByRestPasswordRef = ref();
2024-10-22 16:41:04 +08:00
/** 重置密码 */
2025-04-25 16:21:15 +08:00
function onResetPassword() {
// 重置密码表单
const restPasswordForm = reactive({
password: '',
});
2025-04-24 13:43:37 +08:00
addDialog({
title: `修改密码`,
width: '30%',
draggable: true,
closeOnClickModal: false,
fullscreenIcon: true,
destroyOnClose: true,
contentRenderer: () => <ResetPasswordDialog ref={ruleFormByRestPasswordRef} form={restPasswordForm} />,
beforeSure: (done: any) => {
ruleFormByRestPasswordRef.value.ruleFormRef.validate(async (valid: any) => {
if (valid) {
// 更新用户密码
const data = { password: restPasswordForm.password };
const result = await adminUserStore.updateUserPasswordByLocalUser(data);
2024-10-22 16:41:04 +08:00
2025-04-24 13:43:37 +08:00
// 更新成功关闭弹窗
if (!result) return;
done();
removeToken();
await router.push('/login');
}
});
},
});
2025-04-25 16:21:15 +08:00
}
2024-10-22 16:41:04 +08:00
const list = ref([
2025-04-24 13:43:37 +08:00
{
title: $t('account_password'),
illustrate: $t('rest_password_tip'),
button: $t('modify'),
callback: onResetPassword,
},
// {
// title: '密保手机',
// illustrate: '已经绑定手机158****6789',
// button: '修改',
// },
]);
</script>
<template>
2025-04-24 13:43:37 +08:00
<div :class="['min-w-[180px]', deviceDetection() ? 'max-w-[100%]' : 'max-w-[70%]']">
<h3 class="my-8">{{ $t('account_management') }}</h3>
<div v-for="(item, index) in list" :key="index">
<div class="flex items-center">
<div class="flex-1">
<p>{{ item.title }}</p>
<el-text class="mx-1" type="info">{{ item.illustrate }}</el-text>
</div>
2025-04-25 16:21:15 +08:00
<el-button link type="primary" @click="item.callback">
2025-04-24 13:43:37 +08:00
{{ item.button }}
</el-button>
</div>
<el-divider />
</div>
</div>
</template>
<style lang="scss" scoped>
.el-divider--horizontal {
2025-04-24 13:43:37 +08:00
border-top: 0.1px var(--el-border-color) var(--el-border-style);
}
</style>