From da9cf99879af3585d2dae494a7a71b89f7f7a960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B4=AA=E6=B4=AA?= <2498601771@qq.com> Date: Wed, 3 Jul 2024 10:50:32 +0800 Subject: [PATCH] =?UTF-8?q?CN-1663=20fix:=20=E7=AE=A1=E7=90=86--=E7=94=A8?= =?UTF-8?q?=E6=88=B7=EF=BC=8C=E7=BC=96=E8=BE=91=E7=94=A8=E6=88=B7=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E5=AF=86=E7=A0=81=E6=9C=AA=E5=81=9A?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E4=BB=A5=E5=8F=8A=E7=A1=AE=E8=AE=A4=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E6=A0=A1=E9=AA=8C=E6=97=A0=E6=95=88=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/rightBox/settings/UserBox.vue | 27 +++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/components/rightBox/settings/UserBox.vue b/src/components/rightBox/settings/UserBox.vue index 18f35f11..174214bf 100644 --- a/src/components/rightBox/settings/UserBox.vue +++ b/src/components/rightBox/settings/UserBox.vue @@ -37,7 +37,7 @@ + show-word-limit show-password type="password"> @@ -119,18 +119,24 @@ export default { mixins: [rightBoxMixin], data () { const validatePin = (rule, value, callback) => { // 确认密码 - const reg = /^[-\d\w/~!@#$%^&*_.?]+$/g - const isValid = value.match(reg) // 返回匹配到的值 - if (value && value.length < 8) { - callback(new Error(this.$t('validate.atLeastEight'))) - } else if (!isValid || this.passwordLevel(this.editObject.pin) === 1) { - callback(new Error(handleSpecialCode(this.$t('validate.passwordError')))) - } else { + if (value) { + const reg = /^[-\d\w/~!@#$%^&*_.?]+$/g + const isValid = value.match(reg) // 返回匹配到的值 + if (value && value.length < 8) { + callback(new Error(this.$t('validate.atLeastEight'))) + } else if (!isValid || this.passwordLevel(this.editObject.pin) === 1) { + callback(new Error(handleSpecialCode(this.$t('validate.passwordError')))) + } else { + callback() + } + } else if (this.editObject.id) { // 编辑时不输入密码则不做校验 callback() } } const validateConfirmPin = (rule, value, callback) => { // 确认密码的二次校验 - if (_.isEmpty(value) && !_.isEmpty(this.editObject.pin)) { // 密码有内容,确认密码没内容 + if (this.editObject.id && _.isEmpty(value) && _.isEmpty(this.editObject.pin)) { // 编辑时,密码和确认密码均没内容则不做校验 + callback() + } else if (_.isEmpty(value) && !_.isEmpty(this.editObject.pin)) { // 密码有内容,确认密码没内容 callback(new Error(this.$t('config.user.confirmPin'))) } else if (!_.isEmpty(value) && value !== this.editObject.pin) { // 密码有内容,确认密码也有内容,内容不一致 callback(new Error(this.$t('config.user.confirmPinErr'))) @@ -189,6 +195,9 @@ export default { { required: true, message: this.$t('validate.userNameLength'), trigger: 'blur' }, { validator: validateUserName, trigger: 'blur' } ], + pin: [ + { validator: validatePin, trigger: 'blur' } + ], pinChange: [ { validator: validateConfirmPin, trigger: 'blur' }, { validator: validatePin, trigger: 'blur' }