修改密码功能

This commit is contained in:
hyt 2024-06-05 09:47:30 +08:00
parent 57d2c04cee
commit e99bb385b6
2 changed files with 285 additions and 260 deletions

View File

@ -1,60 +1,60 @@
<template>
<div class="box" v-loading="loading">
<el-row :gutter="12" style="height: 100%;">
<el-col :span="8" :xs="24">
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>个人信息</span>
<img src="/images/头像/20230614060011blob" alt="">
</div>
<div class="box-card-center">
<!-- 头像👤 -->
<div class="text-center">
<userAvatar :user="user" />
</div>
<ul class="list-group list-group-striped">
<li class="list-group-item">
<svg-icon icon-class="user" style="margin-right:10px;" />用户名称
<div class="pull-right">{{ user.p_PersonName }}</div>
</li>
<li class="list-group-item">
<svg-icon icon-class="tree" style="margin-right:10px;" />工号
<div class="pull-right">{{ user.p_IDCard }}</div>
</li>
<li class="list-group-item">
<svg-icon icon-class="build" style="margin-right:10px;" />所属部门
<div class="pull-right">{{ user.orgainName }}</div>
</li>
<li class="list-group-item">
<svg-icon icon-class="date" style="margin-right:10px;" />入职日期
<div class="pull-right">{{ user.p_EntryTime | timeSplit }}</div>
</li>
<li class="list-group-item">
<div class="right">
<svg-icon icon-class="date" style="margin-right:10px;width: 5%;" />
<span style="width: 96%;">生日</span>
<!-- <div class="pull-right">{{ user.p_BirthDay| timeSplit }}</div> -->
<el-date-picker class="date-picker" size="mini" v-model="user.p_BirthDay" type="date"
:clearable='false' placeholder="选择日期">
</el-date-picker>
</div>
<!-- <el-col :span="8" :xs="24">-->
<!-- <el-card class="box-card">-->
<!-- <div slot="header" class="clearfix">-->
<!-- <span>个人信息</span>-->
<!-- <img src="/images/头像/20230614060011blob" alt="">-->
<!-- </div>-->
<!-- <div class="box-card-center">-->
<!-- &lt;!&ndash; 头像👤 &ndash;&gt;-->
<!-- <div class="text-center">-->
<!-- <userAvatar :user="user" />-->
<!-- </div>-->
<!-- <ul class="list-group list-group-striped">-->
<!-- <li class="list-group-item">-->
<!-- <svg-icon icon-class="user" style="margin-right:10px;" />用户名称-->
<!-- <div class="pull-right">{{ user.p_PersonName }}</div>-->
<!-- </li>-->
<!-- <li class="list-group-item">-->
<!-- <svg-icon icon-class="tree" style="margin-right:10px;" />工号-->
<!-- <div class="pull-right">{{ user.p_IDCard }}</div>-->
<!-- </li>-->
<!-- <li class="list-group-item">-->
<!-- <svg-icon icon-class="build" style="margin-right:10px;" />所属部门-->
<!-- <div class="pull-right">{{ user.orgainName }}</div>-->
<!-- </li>-->
<!-- <li class="list-group-item">-->
<!-- <svg-icon icon-class="date" style="margin-right:10px;" />入职日期-->
<!-- <div class="pull-right">{{ user.p_EntryTime | timeSplit }}</div>-->
<!-- </li>-->
<!-- <li class="list-group-item">-->
<!-- <div class="right">-->
<!-- <svg-icon icon-class="date" style="margin-right:10px;width: 5%;" />-->
<!-- <span style="width: 96%;">生日</span>-->
<!-- &lt;!&ndash; <div class="pull-right">{{ user.p_BirthDay| timeSplit }}</div> &ndash;&gt;-->
<!-- <el-date-picker class="date-picker" size="mini" v-model="user.p_BirthDay" type="date"-->
<!-- :clearable='false' placeholder="选择日期">-->
<!-- </el-date-picker>-->
<!-- </div>-->
</li>
<li class="list-group-item">
<div class="right">
<svg-icon icon-class="phone" style="margin-right:10px;width: 5%;" />
<span style="width:96%;">联系电话</span>
<el-input class="input" maxlength='11' v-model="user.p_Telphone" size="mini"
oninput="value=value.replace(/^(0+)|[^\d]+/g,'')"></el-input>
</div>
</li>
</ul>
<!-- </li>-->
<!-- <li class="list-group-item">-->
<!-- <div class="right">-->
<!-- <svg-icon icon-class="phone" style="margin-right:10px;width: 5%;" />-->
<!-- <span style="width:96%;">联系电话</span>-->
<!-- <el-input class="input" maxlength='11' v-model="user.p_Telphone" size="mini"-->
<!-- oninput="value=value.replace(/^(0+)|[^\d]+/g,'')"></el-input>-->
<!-- </div>-->
<!-- </li>-->
<!-- </ul>-->
<el-button type="primary" size="mini" @click="updateData"
style="margin-top: 30px ;position: absolute;right: 0;">更新个人信息</el-button>
</div>
</el-card>
</el-col>
<!-- <el-button type="primary" size="mini" @click="updateData"-->
<!-- style="margin-top: 30px ;position: absolute;right: 0;">更新个人信息</el-button>-->
<!-- </div>-->
<!-- </el-card>-->
<!-- </el-col>-->
<el-col :span="8" :xs="24">
<el-card class="box-card">
<div slot="header" class="clearfix">
@ -70,21 +70,22 @@
</template>
<script>
import userAvatar from "./userAvatar";
import userInfo from "./userInfo";
import resetPwd from "./resetPwd";
import userAvatar from './userAvatar'
import userInfo from './userInfo'
import resetPwd from './resetPwd'
import {
PersonDetail,
PersonSaveData
} from '@/api/apis/personnelSettings'
import {
getUserProfile
} from "@/api/system/user";
} from '@/api/system/user'
import {
getInfo
} from '@/utils/auth.js'
export default {
name: "Profile",
name: 'Profile',
components: {
userAvatar,
userInfo,
@ -95,9 +96,9 @@ export default {
user: {},
roleGroup: {},
postGroup: {},
activeTab: "resetPwd",
activeTab: 'resetPwd',
loading: false
};
}
},
mounted() {
// this.getUser();
@ -112,7 +113,7 @@ export default {
if (!val) {
return
} else {
let time = val.split("T")[0]
let time = val.split('T')[0]
return time
}
}
@ -137,11 +138,11 @@ export default {
let dataMain = this.user
let res = await PersonSaveData({ dataMain })
if (res.code == 1) {
this.$vmNews('更新资料成功', "success")
this.$vmNews('更新资料成功', 'success')
}
}
}
}
};
</script>
<style lang="scss" scoped>
.box {

View File

@ -24,17 +24,21 @@
<script>
import {
userChangePwd
} from "@/api/apis/userInformation";
} from '@/api/apis/userInformation'
import { authApi } from '@/api/apis/auth'
import store from '@/store'
import route from '@/router'
import Cookies from 'js-cookie'
export default {
data() {
const equalToPassword = (rule, value, callback) => {
if (this.user.newPassword !== value) {
callback(new Error("两次输入的密码不一致"));
callback(new Error('两次输入的密码不一致'))
} else {
callback();
callback()
}
}
};
return {
user: {
oldPassword: undefined,
@ -45,56 +49,76 @@ export default {
rules: {
oldPassword: [{
required: true,
message: "旧密码不能为空",
trigger: "blur"
message: '旧密码不能为空',
trigger: 'blur'
}],
newPassword: [{
required: true,
message: "新密码不能为空",
trigger: "blur"
message: '新密码不能为空',
trigger: 'blur'
},
{ min: 8, max: 20, message: "长度在 8 到 20 个字符", trigger: "blur" }
{ min: 8, max: 20, message: '长度在 8 到 20 个字符', trigger: 'blur' }
],
confirmPassword: [{
required: true,
message: "确认密码不能为空",
trigger: "blur"
message: '确认密码不能为空',
trigger: 'blur'
},
{
required: true,
validator: equalToPassword,
trigger: "blur"
trigger: 'blur'
}
]
}
};
}
},
methods: {
submit() {
let that = this
this.$refs["form"].validate(valid => {
this.$refs['form'].validate(async(valid) => {
if (valid) {
let params = {
id: that.$store.state.user.info.userID,
oldpwd: that.user.oldPassword,
newpwd: that.user.newPassword
//
// let params = {
// id: that.$store.state.user.info.userID,
// oldpwd: that.user.oldPassword,
// newpwd: that.user.newPassword
// }
const res = await authApi('sysUserService', '', 'userResetPassword', '', {
OldPassword: that.user.oldPassword,
password: that.user.newPassword
})
if(res.status==='200'){
this.$vmNews('修改成功!即将退出登录', 'success')
setTimeout(() => {
// 2024 06 06
this.$store.dispatch('LogOut').then(() => {
Cookies.remove('automaticLogin')
this.$store.commit('REMOVE_ROUTER')
this.$store.dispatch('tagsView/delAllViews')
this.$router.replace({ path: '/login' })
})
}, 1000)
}
userChangePwd(params).then(response => {
this.$modal.msgSuccess("修改成功");
for (let i in this.user) {
this.user[i] = ""
//
// userChangePwd(params).then(response => {
// this.$modal.msgSuccess("");
// for (let i in this.user) {
// this.user[i] = ""
// }
// });
}
});
}
});
})
},
close() {
this.$tab.closePage();
this.$tab.closePage()
},
resetForm(formName) {
this.$refs[formName].resetFields();
this.$refs[formName].resetFields()
}
}
};
}
</script>