|
@ -1,17 +1,29 @@ |
|
|
<template> |
|
|
<template> |
|
|
<el-form ref="form" :model="user" :rules="rules" label-width="80px"> |
|
|
<el-form ref="form" :model="user" :rules="rules" label-width="80px"> |
|
|
<el-form-item label="旧密码" prop="oldPassword"> |
|
|
<el-form-item label="旧密码" prop="oldPassword"> |
|
|
<el-input v-model="user.oldPassword" placeholder="请输入旧密码" type="password" /> |
|
|
<el-input |
|
|
|
|
|
v-model="user.oldPassword" |
|
|
|
|
|
placeholder="请输入旧密码" |
|
|
|
|
|
type="password" |
|
|
|
|
|
/> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
<el-form-item label="新密码" prop="newPassword"> |
|
|
<el-form-item label="新密码" prop="newPassword"> |
|
|
<el-input v-model="user.newPassword" placeholder="请输入新密码" type="password" /> |
|
|
<el-input |
|
|
|
|
|
v-model="user.newPassword" |
|
|
|
|
|
placeholder="请输入新密码" |
|
|
|
|
|
type="password" |
|
|
|
|
|
/> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
<el-form-item label="确认密码" prop="confirmPassword"> |
|
|
<el-form-item label="确认密码" prop="confirmPassword"> |
|
|
<el-input v-model="user.confirmPassword" placeholder="请确认密码" type="password" /> |
|
|
<el-input |
|
|
|
|
|
v-model="user.confirmPassword" |
|
|
|
|
|
placeholder="请确认密码" |
|
|
|
|
|
type="password" |
|
|
|
|
|
/> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
<el-form-item> |
|
|
<el-form-item> |
|
|
<el-button type="primary" size="mini" @click="submit">保存</el-button> |
|
|
<el-button type="primary" size="mini" @click="submit">保存</el-button> |
|
|
<!-- <el-button type="danger" size="mini" @click="close">关闭</el-button>--> |
|
|
<!-- <el-button type="danger" size="mini" @click="close">关闭</el-button>--> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
</el-form> |
|
|
</el-form> |
|
|
</template> |
|
|
</template> |
|
@ -29,8 +41,16 @@ export default { |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
const checkPassword = (rule, value, callback) => { |
|
|
const checkPassword = (rule, value, callback) => { |
|
|
if ( !new RegExp("^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$").test(value)) { |
|
|
if ( |
|
|
callback(new Error("密码必须数字和字母组成,且长度6至16位")); |
|
|
!new RegExp( |
|
|
|
|
|
"^(?![A-Z]+$)(?![a-z]+$)(?![0-9]+$)(?![!@#$%^&*]+$)[a-zA-Z0-9!@#$%^&*]{8,}$" |
|
|
|
|
|
).test(value) |
|
|
|
|
|
) { |
|
|
|
|
|
callback( |
|
|
|
|
|
new Error( |
|
|
|
|
|
"密码至少包含大写字母、小写字母、数字和符号(!@#$%^&*)中的两种,且长度至少8位" |
|
|
|
|
|
) |
|
|
|
|
|
); |
|
|
} else { |
|
|
} else { |
|
|
callback(); |
|
|
callback(); |
|
|
} |
|
|
} |
|
@ -40,44 +60,40 @@ export default { |
|
|
user: { |
|
|
user: { |
|
|
oldPassword: undefined, |
|
|
oldPassword: undefined, |
|
|
newPassword: undefined, |
|
|
newPassword: undefined, |
|
|
confirmPassword: undefined |
|
|
confirmPassword: undefined, |
|
|
}, |
|
|
}, |
|
|
// 表单校验 |
|
|
// 表单校验 |
|
|
rules: { |
|
|
rules: { |
|
|
oldPassword: [ |
|
|
oldPassword: [ |
|
|
{ required: true, message: "旧密码不能为空", trigger: "blur" } |
|
|
{ required: true, message: "旧密码不能为空", trigger: "blur" }, |
|
|
], |
|
|
], |
|
|
// |
|
|
// |
|
|
newPassword: [ |
|
|
newPassword: [ |
|
|
{ required: true, message: "新密码不能为空", trigger: "blur" }, |
|
|
{ required: true, message: "新密码不能为空", trigger: "blur" }, |
|
|
{ required: true, validator:checkPassword, trigger: "blur" }, |
|
|
{ required: true, validator: checkPassword, trigger: "blur" }, |
|
|
// { min: 8, message: "长度最低8位", trigger: "blur" } |
|
|
// { min: 8, message: "长度最低8位", trigger: "blur" } |
|
|
], |
|
|
], |
|
|
confirmPassword: [ |
|
|
confirmPassword: [ |
|
|
{ required: true, message: "确认密码不能为空", trigger: "blur" }, |
|
|
{ required: true, message: "确认密码不能为空", trigger: "blur" }, |
|
|
{ required: true, validator: equalToPassword, trigger: "blur" } |
|
|
{ required: true, validator: equalToPassword, trigger: "blur" }, |
|
|
] |
|
|
], |
|
|
} |
|
|
}, |
|
|
}; |
|
|
}; |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
submit() { |
|
|
submit() { |
|
|
this.$refs["form"].validate(valid => { |
|
|
this.$refs["form"].validate((valid) => { |
|
|
if (valid) { |
|
|
if (valid) { |
|
|
updateUserPwd(this.user.oldPassword, this.user.newPassword).then( |
|
|
updateUserPwd(this.user.oldPassword, this.user.newPassword).then( |
|
|
response => { |
|
|
(response) => { |
|
|
if (response.code === 200) { |
|
|
if (response.code === 200) { |
|
|
this.msgSuccess("密码修改成功!即将重新登录!"); |
|
|
this.msgSuccess("密码修改成功!即将重新登录!"); |
|
|
let _this = this; |
|
|
let _this = this; |
|
|
setTimeout(function (){ |
|
|
setTimeout(function () { |
|
|
_this.$store.dispatch("LogOut").then(() => { |
|
|
_this.$store.dispatch("LogOut").then(() => { |
|
|
location.href = "/index"; |
|
|
location.href = "/index"; |
|
|
}) |
|
|
}); |
|
|
} |
|
|
}, 1000); |
|
|
, |
|
|
|
|
|
1000 |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
); |
|
|
); |
|
@ -85,10 +101,10 @@ export default { |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
close() { |
|
|
close() { |
|
|
this.$emit('closeDialog') |
|
|
this.$emit("closeDialog"); |
|
|
// this.$store.dispatch("tagsView/delView", this.$route); |
|
|
// this.$store.dispatch("tagsView/delView", this.$route); |
|
|
// this.$router.push({ path: "/index" }); |
|
|
// this.$router.push({ path: "/index" }); |
|
|
} |
|
|
}, |
|
|
} |
|
|
}, |
|
|
}; |
|
|
}; |
|
|
</script> |
|
|
</script> |
|
|