| | |
| | | |
| | | <script> |
| | | import {changePassword} from '@/api/api' |
| | | import { ajaxGetDictItems, getDictItemsFromCache } from '@/api/api' |
| | | |
| | | export default { |
| | | name: "PasswordModal", |
| | |
| | | confirmLoading: false, |
| | | confirmDirty: false, |
| | | validatorRules:{ |
| | | password:{ |
| | | rules: [{ |
| | | required: true, |
| | | pattern:/^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,./]).{8,}$/, |
| | | message: '密码由8位数字、大小写字母和特殊符号组成!' |
| | | }, { |
| | | validator: this.validateToNextPassword, |
| | | }], |
| | | }, |
| | | // password:{ |
| | | // rules: [{ |
| | | // required: true, |
| | | // pattern:/^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,./]).{8,}$/, |
| | | // message: '密码由8位数字、大小写字母和特殊符号组成!' |
| | | // }, { |
| | | // validator: this.validateToNextPassword, |
| | | // }], |
| | | // }, |
| | | confirmpassword:{ |
| | | rules: [{ |
| | | required: true, message: '请重新输入登录密码!', |
| | |
| | | sm: { span: 16 }, |
| | | }, |
| | | form:this.$form.createForm(this) |
| | | } |
| | | }, |
| | | watch:{ |
| | | visible:{ |
| | | handler(value){ |
| | | if(value) this.initDictData('password_length') |
| | | } |
| | | } |
| | | }, |
| | | created () { |
| | |
| | | this.confirmLoading = true; |
| | | let formData = Object.assign(this.model, values); |
| | | changePassword(formData).then((res)=>{ |
| | | if(res.success){ |
| | | this.$message.success(res.message); |
| | | if(res.success){; |
| | | this.$notification.success({ |
| | | message:'消息', |
| | | description:res.message |
| | | }); |
| | | this.$emit('ok'); |
| | | }else{ |
| | | this.$message.warning(res.message); |
| | | this.$notification.warning({ |
| | | message:'消息', |
| | | description:res.message |
| | | }); |
| | | } |
| | | }).finally(() => { |
| | | this.confirmLoading = false; |
| | |
| | | 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> |