|
|
|
@ -1,14 +1,19 @@ |
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<div> |
|
|
|
<div> |
|
|
|
<basic-container> |
|
|
|
<basic-container> |
|
|
|
<avue-form :option="option" v-model="form" @tab-click="handleTabClick" |
|
|
|
<avue-tabs :option="tabOption" @change="handleTabClick"></avue-tabs> |
|
|
|
@submit="handleSubmit"></avue-form> |
|
|
|
<div v-if="index === 0"> |
|
|
|
|
|
|
|
<avue-form :option="userInfoOption" v-model="form" @submit="handleSubmit"></avue-form> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
<div v-else-if="index === 1"><avue-form ref="pwdForm" :option="userPwdOption" v-model="pwdform" @submit="handleSubmit2"> |
|
|
|
|
|
|
|
</avue-form> |
|
|
|
|
|
|
|
</div> |
|
|
|
</basic-container> |
|
|
|
</basic-container> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
<script> |
|
|
|
import option from "@/option/user/info"; |
|
|
|
import { userInfoOption } from "@/option/user/info"; |
|
|
|
import { getUserInfo, updateInfo, updatePassword } from "@/api/system/user"; |
|
|
|
import { getUserInfo, updateInfo, updatePassword } from "@/api/system/user"; |
|
|
|
import md5 from 'js-md5'; |
|
|
|
import md5 from 'js-md5'; |
|
|
|
import func from "@/util/func"; |
|
|
|
import func from "@/util/func"; |
|
|
|
@ -16,10 +21,61 @@ import func from "@/util/func"; |
|
|
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
export default { |
|
|
|
data() { |
|
|
|
data() { |
|
|
|
|
|
|
|
var validatePass2 = (rule, value, callback) => { |
|
|
|
|
|
|
|
if (value === '') { |
|
|
|
|
|
|
|
callback(new Error('请再次输入密码')); |
|
|
|
|
|
|
|
} else if (value !== this.pwdform.newPassword1) { |
|
|
|
|
|
|
|
callback(new Error('两次输入密码不一致!')); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
callback(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
return { |
|
|
|
return { |
|
|
|
index: 0, |
|
|
|
index: 0, |
|
|
|
option: option, |
|
|
|
tabOption: { |
|
|
|
form: {} |
|
|
|
column: [{ |
|
|
|
|
|
|
|
label: '个人信息', |
|
|
|
|
|
|
|
prop: '0', |
|
|
|
|
|
|
|
}, { |
|
|
|
|
|
|
|
label: '修改密码', |
|
|
|
|
|
|
|
prop: '1', |
|
|
|
|
|
|
|
},] |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
userInfoOption: userInfoOption, |
|
|
|
|
|
|
|
userPwdOption: { |
|
|
|
|
|
|
|
column: [{ |
|
|
|
|
|
|
|
label: '原密码', |
|
|
|
|
|
|
|
span: 12, |
|
|
|
|
|
|
|
row: true, |
|
|
|
|
|
|
|
type: 'password', |
|
|
|
|
|
|
|
prop: 'oldPassword', |
|
|
|
|
|
|
|
rules: [{ |
|
|
|
|
|
|
|
required: true, |
|
|
|
|
|
|
|
message: "请输入原密码", |
|
|
|
|
|
|
|
trigger: "blur" |
|
|
|
|
|
|
|
}] |
|
|
|
|
|
|
|
}, { |
|
|
|
|
|
|
|
label: '新密码', |
|
|
|
|
|
|
|
span: 12, |
|
|
|
|
|
|
|
row: true, |
|
|
|
|
|
|
|
type: 'password', |
|
|
|
|
|
|
|
prop: 'newPassword', |
|
|
|
|
|
|
|
rules: [{ |
|
|
|
|
|
|
|
required: true, |
|
|
|
|
|
|
|
message: "请输入新密码", |
|
|
|
|
|
|
|
trigger: "blur" |
|
|
|
|
|
|
|
}] |
|
|
|
|
|
|
|
}, { |
|
|
|
|
|
|
|
label: '确认密码', |
|
|
|
|
|
|
|
span: 12, |
|
|
|
|
|
|
|
row: true, |
|
|
|
|
|
|
|
type: 'password', |
|
|
|
|
|
|
|
prop: 'newPassword1', |
|
|
|
|
|
|
|
rules: [{ validator: validatePass2, trigger: 'blur' }] |
|
|
|
|
|
|
|
}] |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
form: {}, |
|
|
|
|
|
|
|
pwdform: {} |
|
|
|
}; |
|
|
|
}; |
|
|
|
}, |
|
|
|
}, |
|
|
|
created() { |
|
|
|
created() { |
|
|
|
@ -27,7 +83,6 @@ export default { |
|
|
|
}, |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
methods: { |
|
|
|
handleSubmit(form, done) { |
|
|
|
handleSubmit(form, done) { |
|
|
|
if (this.index === 0) { |
|
|
|
|
|
|
|
updateInfo(form).then(res => { |
|
|
|
updateInfo(form).then(res => { |
|
|
|
if (res.data.success) { |
|
|
|
if (res.data.success) { |
|
|
|
this.$message({ |
|
|
|
this.$message({ |
|
|
|
@ -45,7 +100,8 @@ export default { |
|
|
|
window.console.log(error); |
|
|
|
window.console.log(error); |
|
|
|
done(); |
|
|
|
done(); |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
}, |
|
|
|
|
|
|
|
handleSubmit2(form, done) { |
|
|
|
updatePassword(md5(form.oldPassword), md5(form.newPassword), md5(form.newPassword1)).then(res => { |
|
|
|
updatePassword(md5(form.oldPassword), md5(form.newPassword), md5(form.newPassword1)).then(res => { |
|
|
|
if (res.data.success) { |
|
|
|
if (res.data.success) { |
|
|
|
this.$message({ |
|
|
|
this.$message({ |
|
|
|
@ -63,7 +119,6 @@ export default { |
|
|
|
window.console.log(error); |
|
|
|
window.console.log(error); |
|
|
|
done(); |
|
|
|
done(); |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
handleWitch() { |
|
|
|
handleWitch() { |
|
|
|
if (this.index === 0) { |
|
|
|
if (this.index === 0) { |
|
|
|
@ -81,7 +136,10 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
handleTabClick(tabs) { |
|
|
|
handleTabClick(tabs) { |
|
|
|
this.index = func.toInt(tabs.index); |
|
|
|
if(tabs.prop != '1'){ |
|
|
|
|
|
|
|
this.$refs.pwdForm.resetForm(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.index = func.toInt(tabs.prop); |
|
|
|
this.handleWitch(); |
|
|
|
this.handleWitch(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|