index.vue
6.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<template>
<div class="personal">
<div class="personal-panel">
<div class="personal-desc" v-if="user">
<div class="avatar-container">
<el-avatar
:size="'large'"
:src="'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png'"
></el-avatar>
</div>
<div class="name-role">
<span class="sender">{{ user.userName }} - {{ ['超级管理员','管理员'][+user.roleType] }}</span>
</div>
<div class="registe-info">
<span class="registe-info">
<li class="fa fa-clock-o"></li>
有效期:{{user.validTime || '未知' }}
</span>
</div>
</div>
<!-- <div class="personal-relation">
<span class="relation-item">followers</span>
<span class="relation-item">watches</span>
<span class="relation-item">friends</span>
</div>-->
<div class="main-operation">
<span class="main-operation-item">
<el-button size="small" icon="fa fa-male" @click="openPersonalDialog"> 查看个人信息</el-button>
</span>
<span class="main-operation-item">
<el-button size="small" icon="fa fa-key" @click="openPasswordDialog"> 修改密码</el-button>
</span>
</div>
<div class="other-operation" @click="clear">
<div class="other-operation-item">
<i class="fa fa-eraser"></i>
清空本地缓存
</div>
</div>
<div class="personal-footer" @click="logOut">
<el-button type="text">
<i class="fa fa-sign-out"></i>注销
</el-button>
</div>
</div>
<personal-dialog :visible="personalVisible" :user="info" />
<password-dialog :visible="passwordVisible" :user="info" />
</div>
</template>
<script>
import { mapState, mapActions } from 'vuex'
import { Message, MessageBox } from 'element-ui'
export default {
name: 'PersonalPanel',
props: {
user: Object
},
computed: {
...mapState('d2admin/user', ['info'])
},
data () {
return {
personalVisible: false,
passwordVisible: false
}
},
mounted () {
this.$event.$on('e-ps-close', is2Login => {
this.passwordVisible = false
if (!is2Login) return
this.$message(`修改密码成功,2秒后退回登录页`)
setTimeout(async () => {
await this.logout()
this.$router.push('/login')
}, 2000)
})
this.$event.$on('e-pd-close', () => this.personalVisible = false)
},
components: {
personalDialog: () => import('./personalDialog'),
passwordDialog: () => import('./passwordDialog')
},
methods: {
...mapActions('d2admin/account', ['logout']),
/**
* @description 登出
*/
logOut () {
this.$store.commit('d2admin/gray/set', true)
MessageBox.confirm('确定要注销当前用户吗', '注销用户', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(async () => {
await this.$store.commit('d2admin/gray/set', false)
// await this.$store.dispatch('d2admin/user/set', {})
await this.logout()
this.$router.push('/login')
})
.catch(() => {
this.$store.commit('d2admin/gray/set', false)
// Message({
// message: '取消注销操作'
// })
})
},
clear () {
this.$store.commit('d2admin/gray/set', true)
MessageBox.confirm(
'清空本地缓存将重置所有个性化设置并退出到登录界面',
'清空本地缓存',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}
)
.then(async () => {
await this.$store.commit('d2admin/gray/set', false)
localStorage.clear()
window.location.reload()
})
.catch(() => {
this.$store.commit('d2admin/gray/set', false)
// Message({
// message: '取消清除缓存操作'
// })
})
},
comfirm (text, title, cancleText) {
return new Promise((reject, resolve) => {
this.$store.commit('d2admin/gray/set', true)
MessageBox.confirm(text, title, {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(async () => {
await this.$store.commit('d2admin/gray/set', false)
resolve(true)
})
.catch(() => {
this.$store.commit('d2admin/gray/set', false)
Message({
message: cancleText
})
reject()
})
})
},
// 打开个人信息弹出框
openPersonalDialog: function () {
this.personalVisible = true
},
openPasswordDialog: function () {
this.passwordVisible = true
}
}
}
</script>
<style lang="scss" scoped>
.personal-panel {
font-size: 14px;
width: 248px;
text-align: center;
border-color: rgba(180, 190, 190, 0.2);
border-width: 1px;
border-style: solid;
background: rgba(182, 172, 172, 0.1);
margin: -14px;
}
.personal-desc {
/* padding: 15px;
color: #fff; */
padding: 24px 0;
}
.avatar {
width: 80px;
height: 80px;
border-radius: 90px;
}
.avatar-container {
display: inline-block;
text-align: center;
}
.name-role {
font-size: 14px;
padding: 5px;
}
.personal-relation {
font-size: 16px;
padding: 12px;
margin-right: 1px;
background: rgba(200, 209, 204, 0.3);
}
.relation-item {
padding: 12px;
}
.relation-item:hover {
cursor: pointer;
color: rgb(19, 138, 156);
}
.main-operation {
padding: 8px;
/* background: rgba(175, 182, 179, 0.3); */
border-color: rgba(201, 206, 206, 0.2);
border-top-width: 1px;
border-top-style: solid;
display: flex;
justify-content: space-between;
}
.main-operation-item {
margin: 4px;
}
.other-operation {
padding: 0;
margin-right: 1px;
text-align: left;
border-color: rgba(180, 190, 190, 0.2);
border-top-width: 1px;
border-top-style: solid;
&-item {
padding: 12px 16px;
}
&:hover {
cursor: pointer;
color: rgb(19, 138, 156);
background: #b1a6a61e;
}
}
.personal-footer {
margin-right: 1px;
font-size: 14px;
text-align: center;
padding:2px 0;
border-color: rgba(180, 190, 190, 0.2);
border-top-width: 1px;
border-top-style: solid;
&:hover {
cursor: pointer;
color: rgb(19, 138, 156);
background: #b1a6a61e;
}
}
</style>