优化个人中心/基本资料修改时数据显示问题

master
RuoYi 12 months ago
parent 87be9b7acf
commit afd8de5094
  1. 23
      src/views/system/user/profile/userInfo.vue

@ -1,16 +1,16 @@
<template> <template>
<el-form ref="userRef" :model="user" :rules="rules" label-width="80px"> <el-form ref="userRef" :model="form" :rules="rules" label-width="80px">
<el-form-item label="用户昵称" prop="nickName"> <el-form-item label="用户昵称" prop="nickName">
<el-input v-model="user.nickName" maxlength="30" /> <el-input v-model="form.nickName" maxlength="30" />
</el-form-item> </el-form-item>
<el-form-item label="手机号码" prop="phonenumber"> <el-form-item label="手机号码" prop="phonenumber">
<el-input v-model="user.phonenumber" maxlength="11" /> <el-input v-model="form.phonenumber" maxlength="11" />
</el-form-item> </el-form-item>
<el-form-item label="邮箱" prop="email"> <el-form-item label="邮箱" prop="email">
<el-input v-model="user.email" maxlength="50" /> <el-input v-model="form.email" maxlength="50" />
</el-form-item> </el-form-item>
<el-form-item label="性别"> <el-form-item label="性别">
<el-radio-group v-model="user.sex"> <el-radio-group v-model="form.sex">
<el-radio label="0"></el-radio> <el-radio label="0"></el-radio>
<el-radio label="1"></el-radio> <el-radio label="1"></el-radio>
</el-radio-group> </el-radio-group>
@ -33,6 +33,7 @@ const props = defineProps({
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
const form = ref({});
const rules = ref({ const rules = ref({
nickName: [{ required: true, message: "用户昵称不能为空", trigger: "blur" }], nickName: [{ required: true, message: "用户昵称不能为空", trigger: "blur" }],
email: [{ required: true, message: "邮箱地址不能为空", trigger: "blur" }, { type: "email", message: "请输入正确的邮箱地址", trigger: ["blur", "change"] }], email: [{ required: true, message: "邮箱地址不能为空", trigger: "blur" }, { type: "email", message: "请输入正确的邮箱地址", trigger: ["blur", "change"] }],
@ -43,14 +44,24 @@ const rules = ref({
function submit() { function submit() {
proxy.$refs.userRef.validate(valid => { proxy.$refs.userRef.validate(valid => {
if (valid) { if (valid) {
updateUserProfile(props.user).then(response => { updateUserProfile(form.value).then(response => {
proxy.$modal.msgSuccess("修改成功"); proxy.$modal.msgSuccess("修改成功");
props.user.phonenumber = form.value.phonenumber;
props.user.email = form.value.email;
}); });
} }
}); });
}; };
/** 关闭按钮 */ /** 关闭按钮 */
function close() { function close() {
proxy.$tab.closePage(); proxy.$tab.closePage();
}; };
//
watch(() => props.user, user => {
if (user) {
form.value = { nickName: user.nickName, phonenumber: user.phonenumber, email: user.email, sex: user.sex };
}
},{ immediate: true });
</script> </script>

Loading…
Cancel
Save