driver-info.vue
7.99 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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<!-- 司机详情基本信息 -->
<template>
<el-container
class="customer-details-box"
:class="isShow?'read':'edit'"
>
<el-card
shadow="never"
style="width: 100%"
class="outCard"
>
<div class="block">
<el-card
shadow="never"
class="form-box"
>
<div class="form-item-box">
<div class="form-item">
<span class="span-title">员工编号:</span>
<el-input
v-model="driverInfos.id"
:disabled="disabled"
:placeholder="isShow?'--':'请输入员工编号'"
maxlength="20"
/>
</div>
<div class="form-item">
<span class="span-title">司机名称:</span>
<el-input
v-model="driverInfos.name"
:disabled="disabledName"
:placeholder="isShow?'--':'请输入司机名称'"
maxlength="15"
/>
</div>
<div class="form-item">
<span class="span-title">所属机构:</span>
<el-input
v-model="driverInfos.agencyName"
:disabled="disabledAvatar"
:placeholder="isShow?'--':'请输入所属机构'"
maxlength="20"
/>
</div>
<div class="form-item">
<span class="span-title">电话:</span>
<el-input
v-model="driverInfos.mobile"
:disabled="disabledMobile"
:placeholder="isShow?'--':'请输入电话'"
maxlength="20"
/>
</div>
<div class="form-item">
<span class="span-title">年龄:</span>
<el-input
v-model="driverInfos.age"
:disabled="disabledAge"
maxlength="4"
:placeholder="isShow?'--':'请输入年龄'"
>
</el-input>
</div>
</div>
</el-card>
</div>
</el-card>
<div
v-if="isShow"
style="text-align: center"
class="footer-box"
>
<el-button
class="save-btn"
type="warning"
@click="handleEditDriverInfo()"
>编辑</el-button>
</div>
<div
v-else
style="text-align: center"
class="footer-box"
>
<el-button
class="save-btn"
type="warning"
@click="handleSubDriverInfo()"
>保存</el-button>
<el-button
class="cancel-btn"
@click="handleCanDriverInfo()"
>取消</el-button>
</div>
</el-container>
</template>
<script>
import { driverDetail, driverDetailUpdate } from '@/api/transit'
export default {
data() {
return {
disabled: true,
pdfData: {
bizType: 'driver'
},
isShow: true,
dialogVisible: false,
disabledName: true,
disabledMobile: true,
disabledAge: true,
disabledAvatar: true,
driverInfos: {
id: '',
name: '',
agencyName: '',
fleetName: '',
mobile: '',
age: '',
avatar: ''
}
}
},
created() {
this.id = this.$route.query.id
this.getList(this.id)
},
methods: {
goBack() {},
handleAvatarSuccess(res, file) {
const _this = this
if (res.code === 0) {
_this.driverInfos.avatar = res.data.url
}
},
// 获取司机详情基本信息
async getList(id) {
const { data: res } = await driverDetail(id)
this.driverInfos.id = res.userId
this.driverInfos.name = res.name
if (res.fleet != null) {
this.driverInfos.fleetId = res.fleet.id
this.driverInfos.fleetName = res.fleet.name
}
if (res.agency != null) {
this.driverInfos.agencyId = res.agency.id
this.driverInfos.agencyName = res.agency.name
}
this.driverInfos.mobile = res.mobile
this.driverInfos.age = res.age
this.driverInfos.avatar = res.avatar
},
// 编辑基本信息
async handleEditDriverInfo() {
this.isShow = false
this.disabledName = true
this.disabledMobile = true
this.disabledAvatar = true
this.disabledAge = false
},
// 保存
async handleSubDriverInfo() {
const data = {
name: this.driverInfos.name,
mobile: this.driverInfos.mobile,
age: this.driverInfos.age,
userId: this.driverInfos.id,
agency: {
id: this.driverInfos.agencyId,
name: this.driverInfos.agencyName
},
fleet: {
id: this.driverInfos.fleetId,
name: this.driverInfos.fleetName
},
avatar: this.driverInfos.avatar
}
await driverDetailUpdate(this.id, data).then(() => {
this.$message({
message: '保存成功!',
type: 'success'
})
this.isShow = true
this.disabledName = true
this.disabledAvatar = true
this.disabledMobile = true
this.disabledAge = true
})
},
// 取消
handleCanDriverInfo() {
this.isShow = true
this.disabledName = true
this.disabledMobile = true
this.disabledAvatar = true
this.disabledAge = true
}
}
}
</script>
<style lang="scss" scoped>
/deep/ .el-card{
height: 100%;
}
.avatar-uploader .el-upload {
border: 1px dashed #d9d9d9;
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
}
.avatar-uploader .el-upload:hover {
border-color: #409eff;
}
.avatar-uploader-icon {
font-size: 28px;
color: #8c939d;
width: 178px;
height: 178px;
line-height: 178px;
text-align: center;
}
.avatar {
width: 178px;
height: 178px;
display: block;
}
.el-aside {
color: #333;
}
/deep/ .el-row {
margin-bottom: 20px;
}
.customer-details-box {
height: 100%;
margin-left: 20px;
.block {
background-color: #ffffff;
width: 100%;
padding: 0 24px;
}
.car-base {
color: #2a2929;
font-size: 16px;
margin: 15px 0;
font-weight: 700;
}
.car-img-base {
margin: 25px 0;
border-bottom: 1px solid #e5e7ec;
.info-box {
border: 0 !important;
padding: 35px 0;
width: 100%;
}
}
.form-box {
border: 0 !important;
/deep/ .el-card__body {
padding: 15px 26px;
padding-top: 16px!important;
.form-item-box {
display: flex;
flex-wrap: wrap;
.form-item {
width: 50%;
display: flex;
align-items: center;
margin-top: 24px;
box-sizing: border-box;
&:nth-child(1),
&:nth-child(2),
&:nth-child(3) {
margin-top: 0;
}
&:nth-child(odd) {
padding-left: 35px;
}
&:nth-child(even) {
padding-left: 35px;
}
.span-title {
min-width: 80px;
font-weight: 400;
text-align: right;
color: #20232a;
font-size: 14px;
}
/deep/ .el-input {
flex: 1;
margin-left: 10px;
}
/deep/.el-input.is-disabled .el-input__inner {
background: #eff3f8;
border: 1px solid #d8dde3;
border-radius: 5px;
font-weight: 400;
color: #bac0cd;
}
}
}
}
}
.footer-box {
text-align: center;
margin-top: 20px;
padding: 30px 0 16px;
border-top: 1px solid #e5e7ec;
.save-btn {
background-color: #e15536;
color: #ffffff;
width: 110px;
border-radius: 5px;
font-weight: 400;
border: 1px solid #e15536;
&:hover {
background: #ffab98;
border: 1px solid #ffab98;
}
}
.cancel-btn {
width: 110px;
color: #2a2929;
border: 1px solid #d8dde3;
border-radius: 5px;
font-weight: 400;
&:hover {
background: #ffeeeb;
border: 1px solid #f3917c;
color: #e15536;
}
}
}
}
</style>