From 37e05fb5e2d64fae783c26f1bf57279764a9c5cc Mon Sep 17 00:00:00 2001 From: zhangyu Date: Thu, 24 Dec 2020 15:00:05 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E6=96=B0=E5=A2=9Eaccount=20?= =?UTF-8?q?=E5=AF=86=E7=A0=81=E6=B7=BB=E5=8A=A0=E4=BA=8C=E6=AC=A1=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/common/rightBox/accountBox.vue | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/nezha-fronted/src/components/common/rightBox/accountBox.vue b/nezha-fronted/src/components/common/rightBox/accountBox.vue index 5f6101cdf..86bfc5889 100644 --- a/nezha-fronted/src/components/common/rightBox/accountBox.vue +++ b/nezha-fronted/src/components/common/rightBox/accountBox.vue @@ -26,6 +26,11 @@ + + + + @@ -106,6 +111,18 @@ this.getRoles(); }, data() { + let validatePassword = (rule, value, callback) => { // 确认密码的二次校验 + console.log(value); + if (value === ''&& this.editUser.password) { + callback(new Error(this.$t('validate.required'))); + }else if(!this.editUser.password){ + callback(new Error(this.$t('config.account.inputConfirmPwd'))); + }else if (value !== this.editUser.password) { + callback(new Error(this.$t('config.account.confirmPwdErr'))); + } else { + callback(); + } + }; return { scriptIds: [], rules: { //表单校验规则 @@ -115,6 +132,10 @@ password: [ {required: true, message: this.$t('validate.required'), trigger: 'blur'} ], + passwordChange: [ + { validator: validatePassword, trigger: 'blur' }, + {required: true, message:'', trigger: 'blur'}, + ], roleIds: [ {required: true, message: this.$t('validate.required'), trigger: 'blur'} ], @@ -126,6 +147,7 @@ scripts: [], selectableScripts: [], roles:[], + passwordChange:'', } }, methods: { @@ -194,7 +216,12 @@ this.prevent_opt.save=false; }); }, - + /*密码失去焦点 检验确认密码*/ + passwordBlur(){ + if(this.editUser.password&&this.editUser.passwordChange){ + this.$refs.accountForm.validateField('passwordChange') + } + }, getScripts() { this.$get("/alert/script?pageNo=1&pageSize=-1").then(response => { this.scripts = response.data.list; @@ -311,4 +338,8 @@ position: absolute; left: -120px; } + .passwordChange{ + margin-left: 30px; + width: calc(100% - 30px); + }