Browse Source

bug修复,经销商账号编辑时,若输入密码则对密码进行规则校验

chenrui 3 years ago
parent
commit
2985ee94eb

+ 37 - 4
src/views/dealerManagement/dealerAccountManagement/editModal.vue

@@ -47,7 +47,7 @@
               placeholder="请输入管理员账号,字母/数字(最多50个字符)"
               allowClear />
           </a-form-model-item>
-          <a-form-model-item label="管理员密码" :prop="itemId=='' ? 'password' : ''" :extra="itemId ? '说明:已录入的密码不会显示,录入新密码将会覆盖原有密码' : ''" >
+          <a-form-model-item label="管理员密码" prop="password" :extra="itemId ? '说明:已录入的密码不会显示,录入新密码将会覆盖原有密码' : ''" >
             <a-input
               id="dealerAccountEdit-password"
               :maxLength="50"
@@ -117,9 +117,10 @@ export default {
         phone: [{ required: true, message: '请输入管理员手机', trigger: 'blur' }, { pattern: /^\d{11}$/, message: '请输入正确的手机号' }],
         loginName: [{ required: true, message: '请输入管理员账号', trigger: 'blur' }, { pattern: /^[0-9a-zA-Z]+$/, message: '管理员账号由字母和数字组成' }],
         password: [
-          { required: true, message: '请输入管理员密码', trigger: 'blur' },
-          { pattern: /^[0-9a-zA-Z]+$/, message: '管理员密码由字母和数字组成' },
-          { min: 6, message: '管理员密码为6~50位' }
+        //   { validator: this.passwordValid }
+        //   // { required: true, message: '请输入管理员密码', trigger: 'blur' },
+        //   // { pattern: /^[0-9a-zA-Z]+$/, message: '管理员密码由字母和数字组成' },
+        //   // { min: 6, message: '管理员密码为6~50位' }
         ],
         'org.childUserMaxNum': [{ required: true, message: '请输入最大可开通用户数', trigger: 'blur' }]
       },
@@ -127,6 +128,27 @@ export default {
     }
   },
   methods: {
+    //  密码位数校验
+    passwordValid (rule, value, callback) {
+      if ((this.itemId && value) || (!this.itemId && value)) {
+        var reg = /^[0-9a-zA-Z]+$/
+        if ((reg.test(value)) && !(value.length < 6 || value.length > 50)) {
+          callback()
+        }
+        if (!reg.test(value)) {
+          callback('管理员密码由字母和数字组成')
+        }
+        if (value.length < 6 || value.length > 50) {
+          callback('管理员密码为6~50位')
+        }
+      } else {
+        if (!this.itemId && !value) {
+          callback('请输入管理员密码')
+        } else {
+          callback()
+        }
+      }
+    },
     custChange (val) {
       this.form.tenantSn = val.key
     },
@@ -178,6 +200,17 @@ export default {
   watch: {
     //  父页面传过来的弹框状态
     openModal (newValue, oldValue) {
+      if (this.itemId) {
+        this.rules.password = [
+          { required: false },
+          { validator: this.passwordValid }
+        ]
+      } else {
+        this.rules.password = [
+          { required: true, message: '请输入管理员密码', trigger: 'blur' },
+          { validator: this.passwordValid }
+        ]
+      }
       this.isShow = newValue
     },
     //  重定义的弹框状态

+ 1 - 2
src/views/user/ResetPwd.vue

@@ -12,9 +12,8 @@
           type="password"
           v-model.trim="form.oldPwd"
           id="change-pwd-oldPwd"
-          :maxLength="50"
           allowClear
-          placeholder="请输入原始密码(6~50位)" />
+          placeholder="请输入原始密码" />
       </a-form-model-item>
       <a-form-model-item label="新密码" prop="passwd">
         <a-input