c1dfa424
monkeyhouyi
添加页面
|
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
|
<template>
<el-dialog
title="修改信息"
:close-on-click-modal="false"
:visible.sync="visible"
class="NCC-dialog NCC-dialog_center userInfo"
lock-scroll
width="600px"
v-loading="loading"
>
<el-row class="infoContent">
<div class="head">
<el-upload
class="avatar-uploader"
:action="define.comUploadUrl + '/userAvatar'"
:headers="uploadHeaders"
:on-success="handleSuccess"
:show-file-list="false"
accept="image/*"
>
<div class="avatar-box">
<el-avatar :size="80" :src="avatar" class="avatar" v-if="avatar"/>
<div class="avatar-hover">更换头像</div>
</div>
</el-upload>
<!-- <span class="username">{{ user.realName }}</span> -->
</div>
<el-form class="infoForm" ref="form" :model="user" :rules="rules" label-width="80px">
<el-form-item label="用户名" prop="realName">
<el-input
v-model="user.realName"
placeholder="请输入用户名"
|
46bce7e6
monkeyhouyi
10/14号需求完善
|
33
|
disabled
|
c1dfa424
monkeyhouyi
添加页面
|
34
35
36
37
38
39
40
|
/>
</el-form-item>
</el-form>
</el-row>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="dataFormSubmit()" :loading="btnLoading">保存</el-button>
|
5ed26527
monkeyhouyi
1
|
41
|
<el-button type="danger" @click="close()">关闭</el-button>
|
c1dfa424
monkeyhouyi
添加页面
|
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
|
</span>
</el-dialog>
</template>
<script>
import {
UserSettingInfo,
UpdateAvatar,
} from "@/api/permission/userSetting";
import request from "@/utils/request";
import define from "@/utils/define";
export default {
components: {},
props: [],
data() {
return {
loading: false,
visible: false,
btnLoading: false,
user: {
realName: '',
},
uploadHeaders: { Authorization: this.$store.getters.token },
rules: {
realName: [
{ required: true, message: "用户名不能为空", trigger: "blur" },
],
}
};
},
computed: {
avatar() {
return define.comUrl + this.$store.state.user.avatar;
}
},
watch: {},
created() {},
mounted() {},
methods: {
goBack() {
this.$emit("refresh");
},
init() {
this.visible = true;
this.loading = true;
this.getInfo();
},
getInfo() {
UserSettingInfo().then((res) => {
this.user = res.data;
this.loading = false;
}).catch(() => this.loading = false);
},
// 头像
handleSuccess(res, file) {
if (res.code == 200) {
this.updateAvatar(res.data);
|
5ed26527
monkeyhouyi
1
|
98
99
|
this.$emit('changeAvatar', res.data);
// this.logout();
|
c1dfa424
monkeyhouyi
添加页面
|
100
101
102
103
104
105
106
107
|
} else {
this.$message({
message: "上传失败",
type: "error",
duration: 1000,
});
}
},
|
5ed26527
monkeyhouyi
1
|
108
109
110
111
|
async logout() {
await this.$store.dispatch("LogOut");
this.$router.push({ path: "/login" });
},
|
c1dfa424
monkeyhouyi
添加页面
|
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
updateAvatar(data) {
UpdateAvatar(data.name).then((res) => {
this.user.avatar = data.url;
this.$store.commit("SET_AVATAR", data.url);
this.$message({
message: res.msg,
type: "success",
duration: 1000,
});
});
},
dataFormSubmit() {
this.btnLoading = true;
this.$refs["form"].validate(async (valid) => {
if(valid) {
request({
|
65aeaaa1
monkeyhouyi
样式修改
|
128
|
url: `/permission/Users/${this.user.id}/UpdateUserInfo`,
|
c1dfa424
monkeyhouyi
添加页面
|
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
method: 'PUT',
data: { realName: this.user.realName }
}).then((res) => {
this.$store.commit("SET_NAME", this.user.realName);
this.$message({
message: res.msg,
type: "success",
duration: 1000,
});
this.visible = false;
this.$emit("refresh");
}).catch(() => this.btnLoading = false)
}
})
},
|
5ed26527
monkeyhouyi
1
|
145
146
147
148
|
close() {
this.visible = false;
this.$emit("refresh");
}
|
c1dfa424
monkeyhouyi
添加页面
|
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
|
},
};
</script>
<style lang="scss" scoped>
.userInfo {
.infoContent {
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
height: 100px;
margin-bottom: 20px;
.infoForm {
flex: 1;
margin-top: 30px;
}
}
.head {
position: relative;
left: 10px;
top: 10px;
height: 90px;
width: 100px;
padding-top: 10px;
.avatar-uploader {
display: inline-block;
vertical-align: top;
.avatar-hover {
position: absolute;
left: 0;
top: 0;
font-size: 12px;
display: none;
overflow: hidden;
width: 80px;
height: 80px;
text-align: center;
border-radius: 50%;
line-height: 80px;
color: #fff;
cursor: pointer;
background: rgba(0, 0, 0, 0.5);
}
&:hover {
& .avatar-hover {
display: block;
}
}
}
.avatar-box {
position: relative;
}
.avatar {
display: inline-block;
width: 80px;
height: 80px;
overflow: hidden;
border-radius: 50%;
vertical-align: top;
margin-right: 10px;
}
.el-avatar>img {
width: 100%;
}
.username {
line-height: 80px;
font-size: 20px;
}
}
}
</style>
|