parent
5cdd6afc25
commit
0a1af829b6
@ -1,92 +0,0 @@
|
|||||||
<template>
|
|
||||||
<Form ref="formRef" :labelWidth="200" :rules="rules" :schema="schema">
|
|
||||||
<template #sex="form">
|
|
||||||
<el-radio-group v-model="form['sex']">
|
|
||||||
<el-radio :label="1">{{ t('profile.user.man') }}</el-radio>
|
|
||||||
<el-radio :label="2">{{ t('profile.user.woman') }}</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</template>
|
|
||||||
</Form>
|
|
||||||
<div style="text-align: center">
|
|
||||||
<XButton :title="t('common.save')" type="primary" @click="submit()" />
|
|
||||||
<XButton :title="t('common.reset')" type="danger" @click="init()" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import type { FormRules } from 'element-plus'
|
|
||||||
import { FormSchema } from '@/types/form'
|
|
||||||
import type { FormExpose } from '@/components/Form'
|
|
||||||
import {
|
|
||||||
getUserProfile,
|
|
||||||
updateUserProfile,
|
|
||||||
UserProfileUpdateReqVO
|
|
||||||
} from '@/api/system/user/profile'
|
|
||||||
|
|
||||||
defineOptions({ name: 'BasicInfo' })
|
|
||||||
|
|
||||||
const { t } = useI18n()
|
|
||||||
const message = useMessage() // 消息弹窗
|
|
||||||
// 表单校验
|
|
||||||
const rules = reactive<FormRules>({
|
|
||||||
nickname: [{ required: true, message: t('profile.rules.nickname'), trigger: 'blur' }],
|
|
||||||
email: [
|
|
||||||
{ required: true, message: t('profile.rules.mail'), trigger: 'blur' },
|
|
||||||
{
|
|
||||||
type: 'email',
|
|
||||||
message: t('profile.rules.truemail'),
|
|
||||||
trigger: ['blur', 'change']
|
|
||||||
}
|
|
||||||
],
|
|
||||||
mobile: [
|
|
||||||
{ required: true, message: t('profile.rules.phone'), trigger: 'blur' },
|
|
||||||
{
|
|
||||||
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
|
|
||||||
message: t('profile.rules.truephone'),
|
|
||||||
trigger: 'blur'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
const schema = reactive<FormSchema[]>([
|
|
||||||
{
|
|
||||||
field: 'nickname',
|
|
||||||
label: t('profile.user.nickname'),
|
|
||||||
component: 'Input'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'mobile',
|
|
||||||
label: t('profile.user.mobile'),
|
|
||||||
component: 'Input'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'email',
|
|
||||||
label: t('profile.user.email'),
|
|
||||||
component: 'Input'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'sex',
|
|
||||||
label: t('profile.user.sex'),
|
|
||||||
component: 'InputNumber',
|
|
||||||
value: 0
|
|
||||||
}
|
|
||||||
])
|
|
||||||
const formRef = ref<FormExpose>() // 表单 Ref
|
|
||||||
const submit = () => {
|
|
||||||
const elForm = unref(formRef)?.getElFormRef()
|
|
||||||
if (!elForm) return
|
|
||||||
elForm.validate(async (valid) => {
|
|
||||||
if (valid) {
|
|
||||||
const data = unref(formRef)?.formModel as UserProfileUpdateReqVO
|
|
||||||
await updateUserProfile(data)
|
|
||||||
message.success(t('common.updateSuccess'))
|
|
||||||
await init()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const init = async () => {
|
|
||||||
const res = await getUserProfile()
|
|
||||||
unref(formRef)?.setValues(res)
|
|
||||||
}
|
|
||||||
onMounted(async () => {
|
|
||||||
await init()
|
|
||||||
})
|
|
||||||
</script>
|
|
@ -1,7 +1,7 @@
|
|||||||
import BasicInfo from './BasicInfo.vue'
|
import BaseInfo from './BaseInfo.vue'
|
||||||
import ProfileUser from './ProfileUser.vue'
|
import ProfileUser from './ProfileUser.vue'
|
||||||
import ResetPwd from './ResetPwd.vue'
|
import ResetPwd from './ResetPwd.vue'
|
||||||
import UserAvatarVue from './UserAvatar.vue'
|
import UserAvatarVue from './UserAvatar.vue'
|
||||||
import UserSocial from './UserSocial.vue'
|
import UserSocial from './UserSocial.vue'
|
||||||
|
|
||||||
export { BasicInfo, ProfileUser, ResetPwd, UserAvatarVue, UserSocial }
|
export { BaseInfo, ProfileUser, ResetPwd, UserAvatarVue, UserSocial }
|
||||||
|
Loading…
Reference in new issue