base-set.vue
4.1 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
<template>
<div class="content">
<div class="user-info">
<el-form
ref="form"
label-width="100px"
:model="form"
class="form-wrapper"
:rules="rules">
<el-form-item label="用户名:" required>
<el-input v-model="form.loginName" clearable disabled />
</el-form-item>
<el-form-item label="姓名:">
<el-input v-model="form.name" clearable />
</el-form-item>
<el-form-item label="性别:">
<el-radio-group v-model="form.sex">
<el-radio
v-for="(item, index) in sexList"
:key="index"
:label="item.value">{{ item.name }}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="身份证号:" prop="idCard">
<el-input v-model="form.idCard" clearable />
</el-form-item>
<el-form-item label="手机号码:" prop="mobilePhone">
<el-input v-model="form.mobilePhone" clearable />
</el-form-item>
<el-form-item label="办公电话:">
<el-input v-model="form.telephone" clearable />
</el-form-item>
<el-form-item label="办公地址:">
<el-input v-model="form.address" clearable />
</el-form-item>
</el-form>
<div class="bottom-wrapper">
<el-button type="primary" @click="updateInfo">更新信息</el-button>
</div>
</div>
</div>
</template>
<script>
import { api, getAction, putAction, getDictItems } from '@/api/manageApi'
export default {
props: {
userInfo: {
type: Object,
default: null
}
},
data () {
return {
form: {},
sexList: [],
rules: {
mobilePhone: [
{
pattern:
/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/,
message: '手机号码格式有误',
trigger: 'blur'
}
],
idCard: [
{
pattern: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,
message: '身份证号格式有误',
trigger: 'blur'
}
]
}
}
},
watch: {
userInfo: {
handler: function (val) {
if (val) {
this.getUserInfo(val.id)
}
}
}
},
mounted () {
if (this.userInfo) {
this.getUserInfo(this.userInfo)
}
this.sexList = [
{
"name": "男",
"value": "0",
},
{
"name": "女",
"value": "1",
},
{
"name": "保密",
"value": "2",
}
]
},
methods: {
getUserInfo (p) {
getAction(`${api.users}/${p.id}`).then((res) => {
if (res.status === 1) {
this.form = res.content
} else {
this.$message.error({ message: res.message, showClose: true })
}
})
},
updateInfo () {
this.$refs.form.validate((valid) => {
if (valid) {
putAction(`${api.users}/${this.form.id}`, this.form).then((res) => {
if (res.status === 1) {
this.$message.success({ message: res.message, showClose: true })
this.getUserInfo(this.form.id)
} else {
this.$message.error({ message: res.message, showClose: true })
}
})
}
})
}
}
}
</script>
<style scoped lang="scss">
.user-info {
margin: 0.1875rem 1.0417rem;
background: #ffffff;
overflow-y: auto;
.form-wrapper {
padding: 0px 120px 0px;
.el-form-item {
/deep/.el-form-item__label {
color: #ffffff;
}
::v-deep .el-input .el-input__inner {
padding: 0 8px;
height: 40px;
line-height: 40px;
border: 1px solid #6bc1fc;
}
}
.el-form-item--small.el-form-item {
margin-bottom: 16px;
}
}
.bottom-wrapper {
padding: 0px 120px 0px;
text-align: right;
}
}
</style>