You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
306 lines
10 KiB
306 lines
10 KiB
<template>
|
|
<div class="app-container">
|
|
<el-row class="container-main" :gutter="20">
|
|
<el-col class="container-left" :xs="24" :sm="24" :md="8" :lg="6" :xl="5">
|
|
<span class="right-top-line" />
|
|
<span class="left-bottom-line" />
|
|
<div class="user-content">
|
|
<h4 class="info-title">个人信息</h4>
|
|
<div class="el-upload">
|
|
<div class="user-img-cover">
|
|
<img :src="user.avatarName ? baseApi + '/avatar/' + user.avatarName : Avatar" title="点击上传头像" class="avatar" :onerror="defaultImg" @click="toggleShow">
|
|
</div>
|
|
<myUpload
|
|
v-model="show"
|
|
:headers="headers"
|
|
:url="updateAvatarApi"
|
|
@crop-upload-success="cropUploadSuccess"
|
|
/>
|
|
</div>
|
|
<ul class="user-info">
|
|
<li><div style="height: 100%"><i class="iconfont icon-dengluzhanghao-fanbai" /> 登录账号<div class="user-right">{{ user.username }}</div></div></li>
|
|
<li><i class="iconfont icon-yonghunicheng-fanbai" /> 用户昵称 <div class="user-right">{{ user.nickName }}</div></li>
|
|
<li><i class="iconfont icon-suoshubumen-fanbai" /> 所属部门 <div class="user-right"> {{ user.dept.name }}</div></li>
|
|
<li><i class="iconfont icon-shoujihaoma-fanbai" /> 手机号码 <div class="user-right">{{ user.phone }}</div></li>
|
|
<li><i class="iconfont icon-yonghuyouxiang-fanbai" /> 用户邮箱 <div class="user-right">{{ user.email }}</div></li>
|
|
<li>
|
|
<i class="iconfont icon-anquanshezhi-fanbai" /> 安全设置
|
|
<div class="user-right">
|
|
<a @click="$refs.pass.dialog = true">修改密码</a>
|
|
</div>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</el-col>
|
|
<el-col class="container-right tab-content" :xs="24" :sm="24" :md="16" :lg="18" :xl="19">
|
|
<span class="right-top-line" />
|
|
<span class="left-bottom-line" />
|
|
<div class="user-right-content">
|
|
<ul class="tab-nav">
|
|
<li :class="{'active-tab-nav': activeIndex == 0}" @click="handleClick(0)">用户资料<i /></li>
|
|
<li :class="{'active-tab-nav': activeIndex == 1}" @click="handleClick(1)">我的消息<i /></li>
|
|
<li :class="{'active-tab-nav': activeIndex == 2}" @click="handleClick(2)">操作日志<i /></li>
|
|
<!-- 最右侧装饰img -->
|
|
<span class="tab-right-img" />
|
|
</ul>
|
|
<div v-if="activeIndex == 0" class="tab-item">
|
|
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="65px">
|
|
<el-form-item label="昵称" prop="nickName">
|
|
<el-input v-model="form.nickName" style="width: 35%" />
|
|
<span style="color:#999;margin-left: 22px;">用户昵称不作为登录使用</span>
|
|
</el-form-item>
|
|
<el-form-item label="手机号" prop="phone">
|
|
<el-input v-model="form.phone" style="width: 35%;" />
|
|
<span style="color: #999;margin-left: 22px;">手机号码不能重复</span>
|
|
</el-form-item>
|
|
<el-form-item label="性别">
|
|
<el-radio-group v-model="form.gender" style="width: 178px">
|
|
<el-radio label="男">男</el-radio>
|
|
<el-radio label="女">女</el-radio>
|
|
</el-radio-group>
|
|
</el-form-item>
|
|
<el-form-item label="">
|
|
<el-button :loading="saveLoading" size="mini" type="primary" @click="doSubmit">保存配置</el-button>
|
|
</el-form-item>
|
|
</el-form>
|
|
</div>
|
|
<!-- 我的消息 -->
|
|
<div v-if="activeIndex == 1" class="tab-item">
|
|
<messageCenter />
|
|
</div>
|
|
<!-- 操作日志 -->
|
|
<div v-if="activeIndex == 2" class="tab-item">
|
|
<el-table v-loading="loading" :data="data" style="width: 100%;">
|
|
<el-table-column prop="description" label="行为" />
|
|
<el-table-column prop="requestIp" label="IP" />
|
|
<el-table-column :show-overflow-tooltip="true" prop="address" label="IP来源" />
|
|
<el-table-column prop="browser" label="浏览器" />
|
|
<el-table-column prop="time" label="请求耗时" align="center">
|
|
<template slot-scope="scope">
|
|
<el-tag v-if="scope.row.time <= 300">{{ scope.row.time }}ms</el-tag>
|
|
<el-tag v-else-if="scope.row.time <= 1000" type="warning">{{ scope.row.time }}ms</el-tag>
|
|
<el-tag v-else type="danger">{{ scope.row.time }}ms</el-tag>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column align="right">
|
|
<template slot="header">
|
|
<div style="display:inline-block;float: right;cursor: pointer" @click="init">创建日期<i class="el-icon-refresh" style="margin-left: 40px" /></div>
|
|
</template>
|
|
<template slot-scope="scope">
|
|
<span>{{ scope.row.createTime }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
<!--分页组件-->
|
|
<el-pagination
|
|
:total="total"
|
|
:current-page="page + 1"
|
|
style="margin-top: 8px;"
|
|
layout="total, prev, pager, next, sizes"
|
|
@size-change="sizeChange"
|
|
@current-change="pageChange"
|
|
/>
|
|
</div>
|
|
|
|
</div></el-col>
|
|
</el-row>
|
|
<updateEmail ref="email" :email="user.email" />
|
|
<updatePass ref="pass" />
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import myUpload from 'vue-image-crop-upload'
|
|
import { mapGetters } from 'vuex'
|
|
import updatePass from './center/updatePass'
|
|
import updateEmail from './center/updateEmail'
|
|
import { getToken } from '@/utils/auth'
|
|
import store from '@/store'
|
|
import { isvalidPhone } from '@/utils/validate'
|
|
import crud from '@/mixins/crud'
|
|
import { editUser } from '@/api/system/user'
|
|
import Avatar from '@/assets/images/avatar.png'
|
|
import messageCenter from './messageCenter/index.vue'
|
|
export default {
|
|
name: 'Center',
|
|
components: { updatePass, updateEmail, myUpload, messageCenter },
|
|
mixins: [crud],
|
|
data() {
|
|
// 自定义验证
|
|
const validPhone = (rule, value, callback) => {
|
|
if (!value) {
|
|
callback(new Error('请输入电话号码'))
|
|
} else if (!isvalidPhone(value)) {
|
|
callback(new Error('请输入正确的11位手机号码'))
|
|
} else {
|
|
callback()
|
|
}
|
|
}
|
|
return {
|
|
defaultImg: 'this.src="' + require('@/assets/images/avatar.png') + '"',
|
|
show: false,
|
|
Avatar: Avatar,
|
|
activeIndex: 0,
|
|
saveLoading: false,
|
|
headers: {
|
|
'Authorization': getToken()
|
|
},
|
|
form: {},
|
|
rules: {
|
|
nickName: [
|
|
{ required: true, message: '请输入用户昵称', trigger: 'blur' },
|
|
{ min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
|
|
],
|
|
phone: [
|
|
{ required: true, trigger: 'blur', validator: validPhone }
|
|
]
|
|
}
|
|
}
|
|
},
|
|
computed: {
|
|
...mapGetters([
|
|
'user',
|
|
'updateAvatarApi',
|
|
'baseApi'
|
|
])
|
|
},
|
|
created() {
|
|
this.form = { id: this.user.id, nickName: this.user.nickName, gender: this.user.gender, phone: this.user.phone }
|
|
store.dispatch('GetInfo').then(() => {})
|
|
if (this.$route.query) {
|
|
this.activeIndex = this.$route.query.activeIndex
|
|
}
|
|
},
|
|
methods: {
|
|
toggleShow() {
|
|
this.show = !this.show
|
|
},
|
|
handleClick(index) {
|
|
this.activeIndex = index
|
|
if (this.activeIndex === 2) {
|
|
this.init()
|
|
}
|
|
},
|
|
beforeInit() {
|
|
this.url = 'api/logs/user'
|
|
return true
|
|
},
|
|
cropUploadSuccess(jsonData, field) {
|
|
store.dispatch('GetInfo').then(() => {})
|
|
},
|
|
doSubmit() {
|
|
if (this.$refs['form']) {
|
|
this.$refs['form'].validate((valid) => {
|
|
if (valid) {
|
|
this.saveLoading = true
|
|
editUser(this.form).then(() => {
|
|
this.editSuccessNotify()
|
|
store.dispatch('GetInfo').then(() => {})
|
|
this.saveLoading = false
|
|
}).catch(() => {
|
|
this.saveLoading = false
|
|
})
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style rel="stylesheet/scss" lang="scss" scoped>
|
|
.user-content{
|
|
color: #fff;
|
|
.iconfont{
|
|
margin-right: 12px;
|
|
}
|
|
}
|
|
.info-title{
|
|
margin: 0;
|
|
height: 40px;
|
|
line-height: 40px;
|
|
font-size: 16px;
|
|
font-weight: bold;
|
|
color: #359AFC;
|
|
text-align: center;
|
|
letter-spacing: 2px;
|
|
background-color: #02255F;
|
|
}
|
|
.el-upload{
|
|
display: block;
|
|
width: 120px;
|
|
height: 120px;
|
|
border-radius: 50%;
|
|
margin: 40px auto 60px auto;
|
|
overflow: hidden;
|
|
.user-img-cover{
|
|
width: 120px;
|
|
height: 120px;
|
|
line-height: 120px;
|
|
}
|
|
.avatar {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
}
|
|
.user-info {
|
|
padding: 0 22px;
|
|
list-style: none;
|
|
li{
|
|
border-bottom: 1px dashed #113D72;
|
|
font-size: 14px;
|
|
height: 41px;
|
|
line-height: 40px;
|
|
}
|
|
.user-right {
|
|
float: right;
|
|
a{
|
|
margin-left: 20px;
|
|
color: #3A99FD;
|
|
}
|
|
}
|
|
}
|
|
|
|
.container-left,
|
|
.container-right{
|
|
min-height: calc(100vh - 230px);
|
|
}
|
|
|
|
.tab-content{
|
|
::v-deep .el-form{
|
|
padding: 0 20px;
|
|
.el-form-item__label{
|
|
color: #339CFF;
|
|
}
|
|
.el-input__inner{
|
|
height: 36px;
|
|
line-height: 36px;
|
|
color: #fff;
|
|
border: 1px solid #339CFF;
|
|
background: transparent;
|
|
}
|
|
.el-radio{
|
|
color: #fff;
|
|
}
|
|
.el-button{
|
|
font-size: 16px;
|
|
padding: 7px 20px;
|
|
color: #fff;
|
|
background: #3A99FD;
|
|
}
|
|
}
|
|
}
|
|
input:-webkit-autofill,
|
|
textarea:-webkit-autofill,
|
|
select:-webkit-autofill {
|
|
-webkit-text-fill-color: #fff !important;
|
|
background-color: transparent;
|
|
transition: background-color 50000s ease-in-out 0s;
|
|
}
|
|
input {
|
|
background-color: transparent;
|
|
}
|
|
.app-container{
|
|
margin-bottom: 0;
|
|
}
|
|
</style>
|