qushaowei
2023-12-13 41d50b20c975faeaa9e5277bdcff13b5acecb575
src/views/system/modules/PasswordModal.vue
@@ -31,6 +31,7 @@
<script>
  import {changePassword} from '@/api/api'
  import { ajaxGetDictItems, getDictItemsFromCache } from '@/api/api'
  export default {
    name: "PasswordModal",
@@ -69,6 +70,13 @@
          sm: { span: 16 },
        },
        form:this.$form.createForm(this)
      }
    },
    watch:{
      visible:{
        handler(value){
          if(value) this.initDictData('password_length')
        }
      }
    },
    created () {
@@ -136,7 +144,20 @@
      handleConfirmBlur  (e) {
        const value = e.target.value
        this.confirmDirty = this.confirmDirty || !!value
      }
      },
      initDictData(dictCode) {
        //根据字典Code, 初始化字典数组
        ajaxGetDictItems(dictCode, null).then((res) => {
          if (res.success) {
            const regExp = new RegExp("^(?=.*[a-zA-Z])(?=.*\\\d)(?=.*[~!@#$%^&*()_+`\\-={}:\";'<>?,./]).{"+Number(res.result[0].value)+",}$");
            this.validatorRules.password.rules[0]={
              required:true,
              pattern: regExp,
              message: `密码由${res.result[0].value}位数字、大小写字母和特殊符号组成!`,
            }
          }
        })
      },
    }
  }
</script>