| | |
| | | label="确认新密码"> |
| | | <a-input type="password" @blur="handleConfirmBlur" placeholder="请确认新密码" v-decorator="[ 'confirmpassword', validatorRules.confirmpassword]"/> |
| | | </a-form-item> |
| | | |
| | | </a-form> |
| | | </a-spin> |
| | | </a-modal> |
| | | </template> |
| | | |
| | | <script> |
| | | |
| | | import { ajaxGetDictItems, getDictItemsFromCache } from '@/api/api' |
| | | import { putAction } from '@/api/manage' |
| | | |
| | | export default { |
| | |
| | | }, |
| | | password:{ |
| | | rules: [{ |
| | | required: true, message: '请输入新密码!', |
| | | required: true, message: '请输入新密码!',trigger:'blur' |
| | | }, { |
| | | validator: this.validateToNextPassword, |
| | | }], |
| | | }, |
| | | { |
| | | pattern: /^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,./]).{8,}$/, |
| | | message: '密码由8位数字、大小写字母和特殊符号组成!', |
| | | }], |
| | | }, |
| | | confirmpassword:{ |
| | | rules: [{ |
| | |
| | | username:"", |
| | | } |
| | | }, |
| | | created(){ |
| | | // this.initDictData('password_length') |
| | | }, |
| | | methods: { |
| | | show(uname){ |
| | | if(!uname){ |
| | |
| | | this.form.resetFields(); |
| | | this.visible = true; |
| | | } |
| | | }, |
| | | initDictData(dictCode) { |
| | | //优先从缓存中读取字典配置 |
| | | if (getDictItemsFromCache(dictCode)) { |
| | | return getDictItemsFromCache(dictCode); |
| | | } |
| | | //根据字典Code, 初始化字典数组 |
| | | ajaxGetDictItems(dictCode, null).then((res) => { |
| | | if (res.success) { |
| | | const regx = new RegExp(/^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,./]).{12,}$/); |
| | | this.validatorRules.password.rules[2]={ |
| | | pattern: regx, |
| | | message: '密码由8位数字、大小写字母和特殊符号组成!', |
| | | } |
| | | return res.result |
| | | } |
| | | }) |
| | | }, |
| | | handleCancel () { |
| | | this.close() |
| | |
| | | // 触发表单验证 |
| | | this.form.validateFields((err, values) => { |
| | | if (!err) { |
| | | that.confirmLoading = true; |
| | | let params = Object.assign({username:this.username},values) |
| | | console.log("修改密码提交数据",params) |
| | | putAction(this.url,params).then((res)=>{ |
| | | if(res.success){ |
| | | console.log(res) |
| | | that.$message.success(res.message); |
| | | that.close(); |
| | | }else{ |
| | | that.$message.warning(res.message); |
| | | } |
| | | }).finally(() => { |
| | | that.confirmLoading = false; |
| | | }) |
| | | if(values.oldpassword!==values.confirmpassword){ |
| | | that.confirmLoading = true; |
| | | let params = Object.assign({username:this.username},values) |
| | | console.log("修改密码提交数据",params) |
| | | putAction(this.url,params).then((res)=>{ |
| | | if(res.success){ |
| | | console.log(res) |
| | | that.$message.success(res.message); |
| | | that.close(); |
| | | }else{ |
| | | that.$message.warning(res.message); |
| | | } |
| | | }).finally(() => { |
| | | that.confirmLoading = false; |
| | | }) |
| | | }else{ |
| | | that.$message.warning('新密码与旧密码不能相同'); |
| | | } |
| | | } |
| | | }) |
| | | }, |