fix: 1.修复【个人中心】页面在英语环境下字段名过长被换行展示导致错位;2.修复【个人中心】页面【修改密码】校验失效。

(cherry picked from commit e4592442ed)
pull/245/head
baayso 2023-08-17 21:35:58 +08:00 committed by shizhong
parent 6e5552c02e
commit 664a86e71c
2 changed files with 10 additions and 5 deletions

View File

@ -1,5 +1,5 @@
<template> <template>
<Form ref="formRef" :labelWidth="80" :rules="rules" :schema="schema"> <Form ref="formRef" :labelWidth="200" :rules="rules" :schema="schema">
<template #sex="form"> <template #sex="form">
<el-radio-group v-model="form['sex']"> <el-radio-group v-model="form['sex']">
<el-radio :label="1">{{ t('profile.user.man') }}</el-radio> <el-radio :label="1">{{ t('profile.user.man') }}</el-radio>
@ -7,8 +7,10 @@
</el-radio-group> </el-radio-group>
</template> </template>
</Form> </Form>
<XButton :title="t('common.save')" @click="submit()" /> <div style="text-align: center">
<XButton :title="t('common.reset')" type="danger" @click="init()" /> <XButton :title="t('common.save')" type="primary" @click="submit()" />
<XButton :title="t('common.reset')" type="danger" @click="init()" />
</div>
</template> </template>
<script lang="ts" name="BasicInfo" setup> <script lang="ts" name="BasicInfo" setup>
import type { FormRules } from 'element-plus' import type { FormRules } from 'element-plus'

View File

@ -1,5 +1,5 @@
<template> <template>
<el-form ref="formRef" :model="password" :rules="rules" label-width="80px"> <el-form ref="formRef" :model="password" :rules="rules" :label-width="200">
<el-form-item :label="t('profile.password.oldPassword')" prop="oldPassword"> <el-form-item :label="t('profile.password.oldPassword')" prop="oldPassword">
<InputPassword v-model="password.oldPassword" /> <InputPassword v-model="password.oldPassword" />
</el-form-item> </el-form-item>
@ -31,13 +31,14 @@ const password = reactive({
}) })
// //
const equalToPassword = (rule, value, callback) => { const equalToPassword = (_rule, value, callback) => {
if (password.newPassword !== value) { if (password.newPassword !== value) {
callback(new Error(t('profile.password.diffPwd'))) callback(new Error(t('profile.password.diffPwd')))
} else { } else {
callback() callback()
} }
} }
const rules = reactive<FormRules>({ const rules = reactive<FormRules>({
oldPassword: [ oldPassword: [
{ required: true, message: t('profile.password.oldPwdMsg'), trigger: 'blur' }, { required: true, message: t('profile.password.oldPwdMsg'), trigger: 'blur' },
@ -52,6 +53,7 @@ const rules = reactive<FormRules>({
{ required: true, validator: equalToPassword, trigger: 'blur' } { required: true, validator: equalToPassword, trigger: 'blur' }
] ]
}) })
const submit = (formEl: FormInstance | undefined) => { const submit = (formEl: FormInstance | undefined) => {
if (!formEl) return if (!formEl) return
formEl.validate(async (valid) => { formEl.validate(async (valid) => {
@ -61,6 +63,7 @@ const submit = (formEl: FormInstance | undefined) => {
} }
}) })
} }
const reset = (formEl: FormInstance | undefined) => { const reset = (formEl: FormInstance | undefined) => {
if (!formEl) return if (!formEl) return
formEl.resetFields() formEl.resetFields()