|
@@ -13,19 +13,90 @@
|
|
|
<el-dropdown-item @click.native="logout">退出登录</el-dropdown-item>
|
|
|
</el-dropdown-menu>
|
|
|
</el-dropdown>
|
|
|
+
|
|
|
+ <!-- 用户密码修改 -->
|
|
|
+ <el-dialog
|
|
|
+ title="修改密码"
|
|
|
+ width="500px"
|
|
|
+ center
|
|
|
+ :before-close="dialogClose"
|
|
|
+ :visible.sync="dialogPwdVisible"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ :append-to-body="true">
|
|
|
+ <div>
|
|
|
+ <el-form ref="userPwdForm" :model='userPwdForm' :rules="userPwdRules" label-width='100px'>
|
|
|
+ <el-form-item label='原密码' prop="password">
|
|
|
+ <el-input v-model='userPwdForm.password'
|
|
|
+ type="password"
|
|
|
+ auto-complete="off"
|
|
|
+ placeholder="请输入原密码"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label='新密码' prop="newPassword">
|
|
|
+ <el-input v-model='userPwdForm.newPassword'
|
|
|
+ type="password"
|
|
|
+ auto-complete="off"
|
|
|
+ placeholder="请输入新密码"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label='确认密码' prop="confirmPassword">
|
|
|
+ <el-input v-model='userPwdForm.confirmPassword'
|
|
|
+ type="password"
|
|
|
+ auto-complete="off"
|
|
|
+ placeholder="请再次输入密码"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ <div style="text-align: center; margin-top: 40px;">
|
|
|
+ <el-button type="primary" @click="updateUserPwdEvent">确定</el-button>
|
|
|
+ <el-button @click="dialogClose">取消</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import avatarDefault from '@/assets/images/default.png'
|
|
|
-import { mapGetters } from 'vuex'
|
|
|
-import { Message } from 'element-ui'
|
|
|
+import {mapGetters} from 'vuex'
|
|
|
+import {updatePwd} from '@/api/user'
|
|
|
+import {getPubKey} from '@/utils/auth'
|
|
|
+import {encrypt} from '@/utils/jsencrypt'
|
|
|
+import {showLoading} from '@/utils/cqcy'
|
|
|
|
|
|
export default {
|
|
|
name: "HeaderPersonal",
|
|
|
data() {
|
|
|
+ let checkPwd = ((rule, value, callback) => {
|
|
|
+ if (value.trim().length == 0) {
|
|
|
+ callback(new Error("请输入确认密码"))
|
|
|
+ } else if (value != this.userPwdForm.newPassword) {
|
|
|
+ callback(new Error("两次密码不一致"))
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ })
|
|
|
return {
|
|
|
- avatarDefault: avatarDefault
|
|
|
+ avatarDefault: avatarDefault,
|
|
|
+ dialogPwdVisible: false,
|
|
|
+ userPwdForm: {
|
|
|
+ password: '',
|
|
|
+ newPassword: '',
|
|
|
+ confirmPassword: ''
|
|
|
+ },
|
|
|
+ userPwdRules: {
|
|
|
+ password: [
|
|
|
+ {required: true, message: '原密码不能为空', trigger: 'blur'},
|
|
|
+ {min: 6, max: 20, message: '原密码长度必须介于 6 和 20 之间', trigger: 'blur'}
|
|
|
+ ],
|
|
|
+ newPassword: [
|
|
|
+ {required: true, message: '新密码不能为空', trigger: 'blur'},
|
|
|
+ {min: 6, max: 20, message: '新密码长度必须介于 6 和 20 之间', trigger: 'blur'}
|
|
|
+ ],
|
|
|
+ confirmPassword: [
|
|
|
+ {required: true, message: '新密码不能为空', trigger: 'blur'},
|
|
|
+ {min: 6, max: 20, message: '新密码长度必须介于 6 和 20 之间', trigger: 'blur'},
|
|
|
+ {validator: checkPwd, required: true, trigger: 'blur'}
|
|
|
+ ]
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -45,12 +116,45 @@ export default {
|
|
|
* 修改密码
|
|
|
*/
|
|
|
updateUserPwd() {
|
|
|
- Message.success("敬请期待")
|
|
|
+ if (this.$refs['userPwdForm'])
|
|
|
+ this.$refs['userPwdForm'].resetFields()
|
|
|
+ this.dialogPwdVisible = true
|
|
|
+ },
|
|
|
+ updateUserPwdEvent() {
|
|
|
+ this.$refs['userPwdForm'].validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ const loading = showLoading(this, '修改中,请稍候···')
|
|
|
+ let pubKey = getPubKey()
|
|
|
+ let data = {
|
|
|
+ 'password': encrypt(this.userPwdForm.password, pubKey),
|
|
|
+ 'newPassword': encrypt(this.userPwdForm.newPassword, pubKey),
|
|
|
+ 'userName': this.name,
|
|
|
+ 'userId': this.uid
|
|
|
+ }
|
|
|
+ updatePwd(data).then(res => {
|
|
|
+ loading.close()
|
|
|
+ if (res.code != 200) {
|
|
|
+ this.$message({
|
|
|
+ message: res.msg,
|
|
|
+ type: 'error'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.$message({
|
|
|
+ message: '修改成功!',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ this.dialogClose()
|
|
|
+ }).catch((e) => {
|
|
|
+ loading.close()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
/**
|
|
|
* 退出登录
|
|
|
*/
|
|
|
- logout() {
|
|
|
+ logout() {
|
|
|
this.$confirm('您确定要退出系统吗?', '提示', {
|
|
|
confirmButtonText: '确定',
|
|
|
cancelButtonText: '取消',
|
|
@@ -62,6 +166,16 @@ export default {
|
|
|
})
|
|
|
}).catch(() => {
|
|
|
});
|
|
|
+ },
|
|
|
+ /** 弹出层关闭事件 */
|
|
|
+ dialogClose(done) {
|
|
|
+ if (this.$refs['userPwdForm'])
|
|
|
+ this.$refs['userPwdForm'].resetFields()
|
|
|
+ if (typeof (done) === 'function') {
|
|
|
+ done()
|
|
|
+ } else {
|
|
|
+ this.dialogPwdVisible = false
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|