From e4592442ed4abeb115e04c3e8826c684cbbd76b2 Mon Sep 17 00:00:00 2001 From: baayso <baayso@outlook.com> Date: Thu, 17 Aug 2023 21:35:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=201.=E4=BF=AE=E5=A4=8D=E3=80=90=E4=B8=AA?= =?UTF-8?q?=E4=BA=BA=E4=B8=AD=E5=BF=83=E3=80=91=E9=A1=B5=E9=9D=A2=E5=9C=A8?= =?UTF-8?q?=E8=8B=B1=E8=AF=AD=E7=8E=AF=E5=A2=83=E4=B8=8B=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E5=90=8D=E8=BF=87=E9=95=BF=E8=A2=AB=E6=8D=A2=E8=A1=8C=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E5=AF=BC=E8=87=B4=E9=94=99=E4=BD=8D=EF=BC=9B2.?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E3=80=90=E4=B8=AA=E4=BA=BA=E4=B8=AD=E5=BF=83?= =?UTF-8?q?=E3=80=91=E9=A1=B5=E9=9D=A2=E3=80=90=E4=BF=AE=E6=94=B9=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E3=80=91=E6=A0=A1=E9=AA=8C=E5=A4=B1=E6=95=88=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Profile/components/BasicInfo.vue | 8 +++++--- src/views/Profile/components/ResetPwd.vue | 15 +++++++++------ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/views/Profile/components/BasicInfo.vue b/src/views/Profile/components/BasicInfo.vue index 89c0cfbe..e2189b15 100644 --- a/src/views/Profile/components/BasicInfo.vue +++ b/src/views/Profile/components/BasicInfo.vue @@ -1,5 +1,5 @@ <template> - <Form ref="formRef" :labelWidth="80" :rules="rules" :schema="schema"> + <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> @@ -7,8 +7,10 @@ </el-radio-group> </template> </Form> - <XButton :title="t('common.save')" @click="submit()" /> - <XButton :title="t('common.reset')" type="danger" @click="init()" /> + <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' diff --git a/src/views/Profile/components/ResetPwd.vue b/src/views/Profile/components/ResetPwd.vue index a2eac4d6..477be91f 100644 --- a/src/views/Profile/components/ResetPwd.vue +++ b/src/views/Profile/components/ResetPwd.vue @@ -1,12 +1,12 @@ <template> - <el-form ref="formRef" :model="password" :rules="rules" label-width="80px"> - <el-form-item :label="t('profile.password.oldPassword')"> + <el-form ref="formRef" :model="password" :rules="rules" :label-width="200"> + <el-form-item :label="t('profile.password.oldPassword')" prop="oldPassword"> <InputPassword v-model="password.oldPassword" /> </el-form-item> - <el-form-item :label="t('profile.password.newPassword')"> + <el-form-item :label="t('profile.password.newPassword')" prop="newPassword"> <InputPassword v-model="password.newPassword" strength /> </el-form-item> - <el-form-item :label="t('profile.password.confirmPassword')"> + <el-form-item :label="t('profile.password.confirmPassword')" prop="confirmPassword"> <InputPassword v-model="password.confirmPassword" strength /> </el-form-item> <el-form-item> @@ -33,17 +33,18 @@ const password = reactive({ }) // 表单校验 -const equalToPassword = (value, callback) => { +const equalToPassword = (_rule, value, callback) => { if (password.newPassword !== value) { callback(new Error(t('profile.password.diffPwd'))) } else { callback() } } + const rules = reactive<FormRules>({ oldPassword: [ { required: true, message: t('profile.password.oldPwdMsg'), trigger: 'blur' }, - { min: 3, max: 5, message: t('profile.password.pwdRules'), trigger: 'blur' } + { min: 6, max: 20, message: t('profile.password.pwdRules'), trigger: 'blur' } ], newPassword: [ { required: true, message: t('profile.password.newPwdMsg'), trigger: 'blur' }, @@ -54,6 +55,7 @@ const rules = reactive<FormRules>({ { required: true, validator: equalToPassword, trigger: 'blur' } ] }) + const submit = (formEl: FormInstance | undefined) => { if (!formEl) return formEl.validate(async (valid) => { @@ -63,6 +65,7 @@ const submit = (formEl: FormInstance | undefined) => { } }) } + const reset = (formEl: FormInstance | undefined) => { if (!formEl) return formEl.resetFields()