VehicleInfo.vue
34.2 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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
<template>
<el-container>
<el-main>
<!--面包屑导航区域-->
<!-- <div>-->
<!-- <el-breadcrumb separator-class="el-icon-arrow-right">-->
<!-- <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>-->
<!-- <el-breadcrumb-item>车辆调度</el-breadcrumb-item>-->
<!-- <el-breadcrumb-item>车辆信息</el-breadcrumb-item>-->
<!-- </el-breadcrumb>-->
<!-- </div>-->
<el-card style="background-color: #F5F7FA">
<!--搜索区域-->
<div>
<el-row :gutter="24">
<el-col :span="5">
<el-input v-model="queryInfo.licensePlateNumber" clearable prefix-icon="el-icon-search"
placeholder="请输入车牌号码"></el-input>
</el-col>
<el-col :span="5">
<el-input v-model="queryInfo.vehicleCompany" clearable prefix-icon="el-icon-search"
placeholder="请输入车辆公司"></el-input>
</el-col>
<el-col :span="5">
<el-select v-model="queryInfo.vehicleStatus" clearable placeholder="请选择车辆状态">
<el-option
v-for="item in vehicleStatusList"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-col>
<el-col :span="5">
<el-select v-model="queryInfo.vehicleType" clearable placeholder="请选择车辆类型">
<el-option
v-for="item in vehicleTypeList"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-col>
</el-row>
<el-row style="margin-top: 20px;">
<el-button type="primary" @click="getVehicleInfoList">查询车辆信息</el-button>
<el-button type="success" @click="addVehicleInfoFormVisible = true">增加车辆信息</el-button>
</el-row>
</div>
<!--车辆信息列表区域-->
<div style="margin-top: 20px;">
<el-table :data="vehicleInfoList" border stripe highlight-current-row v-loading="listLoading"
@selection-change="selsChange"
element-loading-text="拼命加载中">
<el-table-column type="selection" width="55" :selectable="isSelectable"
align="center"></el-table-column>
<el-table-column type="index" align="center"></el-table-column>
<el-table-column label="车辆类型" prop="vehicleType" align="center" width="120">
<template slot-scope="scope">
<span v-if="scope.row.vehicleType ==='1'">重型货车</span>
<span v-if="scope.row.vehicleType ==='2'">中型货车</span>
<span v-if="scope.row.vehicleType ==='3'">轻型货车</span>
<span v-if="scope.row.vehicleType ==='4'">微型货车</span>
<span v-if="scope.row.vehicleType ==='5'">拖车</span>
<span v-if="scope.row.vehicleType ==='6'">叉车</span>
</template>
</el-table-column>
<el-table-column label="车牌号码" prop="licensePlateNumber" align="center"
width="130"></el-table-column>
<el-table-column label="车辆状态" prop="vehicleStatus" align="center" width="100">
<template slot-scope="scope">
<span v-if="scope.row.vehicleStatus ==='1'">空闲状态</span>
<span v-if="scope.row.vehicleStatus ==='2'">执行状态</span>
<span v-if="scope.row.vehicleStatus ==='3'">在修状态</span>
<span v-if="scope.row.vehicleStatus ==='4'">损坏未修</span>
<span v-if="scope.row.vehicleStatus ==='5'">保养状态</span>
</template>
</el-table-column>
<el-table-column label="车辆载重/Kg" prop="vehicleLoad" align="center"
width="110"></el-table-column>
<el-table-column label="挂车与否" prop="isTrailer" align="center" width="110">
<template slot-scope="scope">
<span v-if="scope.row.isTrailer ==='1'">有挂车</span>
<span v-if="scope.row.isTrailer ==='2'">没有挂车</span>
</template>
</el-table-column>
<el-table-column label="开始空闲时间" prop="freetime" align="center" width="160"></el-table-column>
<el-table-column label="车辆公司" prop="vehicleCompany" align="center"
width="200"></el-table-column>
<el-table-column label="行驶证号" prop="drivingLicenseNumber" align="center"
width="160"></el-table-column>
<el-table-column label="操作" width="200px" align="center" fixed="right">
<template slot-scope="scope">
<!--查看按钮-->
<el-tooltip effect="dark" content="编辑" placement="top-start" :enterable="false">
<el-button type="primary" icon="el-icon-edit" size="mini"
@click="showEditDialogVisible(scope.$index,scope.row)">编辑
</el-button>
</el-tooltip>
<!--取消调度按钮-->
<el-tooltip effect="dark" content="删除" placement="top-start" :enterable="false">
<el-button type="danger" icon="el-icon-delete" size="mini"
:loading="delLoading"
:disabled="scope.row.vehicleStatus==='2'"
@click="removeVehicleInfo(scope.$index,scope.row)">删除
</el-button>
</el-tooltip>
</template>
</el-table-column>
</el-table>
<!--分页区域-->
<div style="margin-top: 10px">
<el-row :gutter="24">
<el-col :span="5">
<el-button type="danger" icon="el-icon-delete" @click="batchRemove"
:disabled="this.sels.length===0">批量删除
</el-button>
</el-col>
<el-col :span="10" style="margin-top: 5px">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="queryInfo.pageNum"
:page-sizes="[10,20,30,50]"
:page-size="queryInfo.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</el-col>
</el-row>
</div>
</div>
</el-card>
<!-- 增加车辆信息对话框 -->
<div>
<el-dialog
style="margin-top: -50px"
title="增加车辆信息"
:visible.sync="addVehicleInfoFormVisible"
width="50%" @close="addVehicleInfoDialogClosed">
<el-form :model="addVehicleInfoForm" label-width="100px" status-icon
:rules="addVehicleInfoFormRules" ref="addVehicleInfoFormRef"
style="margin-left:10%;margin-right:10%;background-color: #F5F7FA">
<div style="margin-left: 30px">
<br>
<el-form-item label="车牌号码:" prop="licensePlateNumber">
<el-input v-model="addVehicleInfoForm.licensePlateNumber" clearable
style="width: 300px;"
placeholder="请输入车牌号码"></el-input>
</el-form-item>
<el-form-item label="行驶证号:" prop="drivingLicenseNumber">
<el-input v-model="addVehicleInfoForm.drivingLicenseNumber" clearable
style="width: 300px;"
placeholder="请输入车辆行驶证号"></el-input>
</el-form-item>
<el-form-item label="车辆类型:" prop="vehicleType">
<el-select v-model="addVehicleInfoForm.vehicleType" style="width: 300px" clearable
placeholder="请选择车辆类型">
<el-option
v-for="item in vehicleTypeList"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="车辆载重:" prop="vehicleLoad">
<el-input-number style="width: 200px" v-model="addVehicleInfoForm.vehicleLoad"
:min="10" :max="10000" controls-position="right">
</el-input-number>
<span style="margin-left:5px;font-size: 18px">Kg</span>
</el-form-item>
<el-form-item label="有无挂车:" prop="vehicleType">
<el-select v-model="addVehicleInfoForm.isTrailer" style="width: 300px" clearable
placeholder="请选择有无挂车">
<el-option
v-for="item in isTrailerList"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="车辆公司:" prop="vehicleCompany">
<el-input v-model="addVehicleInfoForm.vehicleCompany" clearable style="width: 300px;"
placeholder="请输入车辆公司"></el-input>
</el-form-item>
<br>
</div>
</el-form>
<!--底部按钮区域-->
<span slot="footer" class="dialog-footer">
<el-button @click="addVehicleInfoFormVisible = false">取 消</el-button>
<el-button type="primary" :loading="addLoading" @click="addVehicleInfo">增 加</el-button>
</span>
</el-dialog>
</div>
<!-- 编辑车辆信息,对话框 -->
<div>
<el-dialog
title="编辑车辆信息"
text-align="center"
:visible.sync="editDialogVisible"
width="60%" @close="editVehicleInfoDialogClosed">
<el-form :model="editVehicleInfoForm" label-width="100px" status-icon
:rules="editVehicleInfoFormRules" ref="editVehicleInfoFormRef"
:inline="true" align="center"
style="background-color: #F5F7FA">
<div>
<br>
<el-form-item label="车牌号码:" prop="licensePlateNumber">
<el-input v-model="editVehicleInfoForm.licensePlateNumber" clearable readonly
style="width:250px"
placeholder="请输入车牌号码"></el-input>
</el-form-item>
<el-form-item label="行驶证号:" prop="drivingLicenseNumber">
<el-input v-model="editVehicleInfoForm.drivingLicenseNumber" clearable
style="width:250px"
placeholder="请输入车辆行驶证号"></el-input>
</el-form-item>
<el-form-item label="车辆类型:" prop="vehicleType">
<el-select v-model="editVehicleInfoForm.vehicleType" clearable
style="width:250px"
placeholder="请选择车辆类型">
<el-option
v-for="item in vehicleTypeList"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="车辆载重:" prop="vehicleLoad">
<el-input-number v-model="editVehicleInfoForm.vehicleLoad"
clearable style="width:220px"
:min="10" :max="10000" controls-position="right">
</el-input-number>
<span style="margin-left:5px;font-size: 18px">Kg</span>
</el-form-item>
<el-form-item label="车辆状态:" prop="vehicleStatus">
<el-select v-model="editVehicleInfoForm.vehicleStatus" clearable
style="width:250px"
clearable placeholder="请选择车辆状态">
<el-option
v-for="item in vehicleStatusList"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="有无挂车:" prop="vehicleType">
<el-select v-model="editVehicleInfoForm.isTrailer" clearable
style="width:250px" clearable
placeholder="请选择有无挂车">
<el-option
v-for="item in isTrailerList"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="车辆公司:" prop="vehicleCompany">
<el-input v-model="editVehicleInfoForm.vehicleCompany" clearable
style="width:250px"
placeholder="请输入车辆公司"></el-input>
</el-form-item>
<el-form-item label="空闲时间:" prop="freetime">
<el-date-picker v-model="editVehicleInfoForm.freetime" type="datetime"
style="width:250px"
placeholder="选择调度时间"></el-date-picker>
</el-form-item>
<br>
</div>
</el-form>
<!--底部按钮区域-->
<span slot="footer" class="dialog-footer">
<el-button @click="editDialogVisible = false">取 消</el-button>
<el-button type="primary" :loading="editLoading" @click="editVehicleInfo">编 辑</el-button>
</span>
</el-dialog>
</div>
</el-main>
</el-container>
</template>
<script>
import {
selectVehicleInfoList,
insertVehicleInfo,
updateVehicleInfo,
batchRemoveVehicleInfo,
deleteVehicleInfo, deleteDispatchNote
} from "../../api/dispatch_api";
export default {
name: "dispatch_api",
created() {
//获取车辆信息列表
this.getVehicleInfoList();
},
data() {
return {
/**
* 查询信息列表
*/
queryInfo: {
//车牌号
licensePlateNumber: '',
//车辆所属公司
vehicleCompany: '',
//车辆状态
vehicleStatus: '',
//车辆类型
vehicleType: '',
//当前的页数
pageNum: 1,
//当前每页显示多少条数据
pageSize: 10
},
/**
* 设置,总条数
*/
total: 0,
/**
* 批量删除,选中列表
*/
sels: [],
/**
* 车辆信息列表
*/
vehicleInfoList: [],
/**
* 新增车辆信息表单
*/
addVehicleInfoForm: {
vehicleType: '2',
licensePlateNumber: '',
vehicleLoad: '',
isTrailer: '2',
vehicleCompany: '',
drivingLicenseNumber: '',
},
/**
* 编辑车辆信息表单
*/
editVehicleInfoForm: {},
/**
* 控制,添加车辆信息对话框的显示与隐藏
*/
addVehicleInfoFormVisible: false,
/**
* 控制,编辑车辆信息对话框的显示与隐藏
*/
editDialogVisible: false,
/* 列表加载 */
listLoading: false,
/* 添加加载 */
addLoading: false,
/* 编辑加载 */
editLoading: false,
/* 删除加载 */
delLoading: false,
/**
* 车辆类型,选项列表
*/
vehicleTypeList: [
{
value: '1',
label: '重型货车'
},
{
value: '2',
label: '中型货车'
},
{
value: '3',
label: '经济货车'
},
{
value: '4',
label: '微型货车'
},
{
value: '5',
label: '拖车'
},
{
value: '6',
label: '叉车'
}
],
/**
* 挂车与否,列表
*/
isTrailerList: [
{
value: '1',
label: '有挂车'
},
{
value: '2',
label: '没有挂车'
},
],
/**
* 车辆状态列表
*/
vehicleStatusList: [
{
value: '1',
label: '空闲状态'
},
{
value: '2',
label: '执行状态'
},
{
value: '3',
label: '在修状态'
},
{
value: '4',
label: '损坏未修状态'
},
{
value: '5',
label: '保养状态'
},
],
/**
* 添加车辆信息表单的验证规则对象
*/
addVehicleInfoFormRules: {
vehicleType: [
{required: true, message: '请选择车辆类型', trigger: ['blur', 'change']},
],
licensePlateNumber: [
{required: true, message: '请输入车牌号', trigger: ['blur', 'change']},
],
vehicleLoad: [
{required: true, message: '请输入车辆载重', trigger: ['blur', 'change']},
],
isTrailer: [
{required: true, message: '请选择有无挂车', trigger: ['blur', 'change']},
],
vehicleCompany: [
{required: true, message: '请输入车辆公司名称', trigger: ['blur', 'change']},
],
drivingLicenseNumber: [
{required: true, message: '请输入车辆行驶证号', trigger: ['blur', 'change']},
],
},
/**
* 编辑车辆信息表单的验证规则对象
*/
editVehicleInfoFormRules: {
vehicleStatus: [
{required: true, message: '请选择车辆状态', trigger: ['blur', 'change']},
],
freetime: [
{required: true, message: '请选择开始空闲时间', trigger: ['blur', 'change']},
],
vehicleType: [
{required: true, message: '请选择车辆类型', trigger: ['blur', 'change']},
],
licensePlateNumber: [
{required: true, message: '请输入车牌号', trigger: ['blur', 'change']},
],
vehicleLoad: [
{required: true, message: '请输入车辆载重', trigger: ['blur', 'change']},
],
isTrailer: [
{required: true, message: '请选择有无挂车', trigger: ['blur', 'change']},
],
vehicleCompany: [
{required: true, message: '请输入车辆公司名称', trigger: ['blur', 'change']},
],
drivingLicenseNumber: [
{required: true, message: '请输入车辆行驶证号', trigger: ['blur', 'change']},
],
}
}
},
methods: {
/**
* 管理员端,获取车辆信息列表
*/
getVehicleInfoList() {
//开启加载
this.listLoading = true;
selectVehicleInfoList(this.queryInfo).then((response) => {
let res = response.data;
if (res.code !== '200') {
//关闭加载
this.listLoading = false;
return this.$message.error('获取车辆信息列表失败');
}
// 获取车辆信息列表数据
this.vehicleInfoList = res.data.list;
// 获取列表的总记录数
this.total = res.data.total;
//关闭加载
this.listLoading = false;
this.$message.success('获取车辆信息列表,成功');
}).catch(error => {
this.listLoading = false;
this.$message.error(error.toString());
});
},
/**
* 管理员端,增加车辆信息
*/
addVehicleInfo() {
/*进行表单的预验证*/
this.$refs.addVehicleInfoFormRef.validate(valid => {
// 未通过,表单预校验
if (!valid) return;
// 通过,表单预检验,发起添加车辆信息的网络请求,开启加载
this.addLoading = true;
insertVehicleInfo(this.addVehicleInfoForm).then((response) => {
let res = response.data;
//添加调度记录信息,失败
if (res.code !== '200') {
//关闭加载
this.addLoading = false;
if(res.code === '406'){
return this.$message.error('该车牌号已存在,请重新填写');
}
return this.$message.error('添加车辆信息,失败');
}
//关闭加载
this.addLoading = false;
this.$message.success('添加调度记录信息,成功');
//隐藏对话框
this.addVehicleInfoFormVisible = false;
//刷新车辆信息列表
this.getVehicleInfoList();
}).catch(error => {
this.addLoading = false;
this.$message.error(error.toString());
});
})
},
/**
* 管理员端,删除车辆信息
*/
removeVehicleInfo(index, row) {
//弹框询问是否删除车辆信息
this.$confirm('此操作永久删除该车辆信息, 是否继续?', '警告', {
confirmButtonText: '确定删除',
cancelButtonText: '取消',
type: 'warning'
}
).then(() => {
//开启加载
this.delLoading = true;
deleteVehicleInfo(row).then((response) => {
let res = response.data;
if (res.code !== '200') {
//关闭加载
this.delLoading = false;
return this.$message.error('删除车辆信息,失败');
}
//关闭加载
this.delLoading = false;
this.$message.success('删除车辆信息,成功!');
//刷新车辆信息列表
this.getVehicleInfoList();
}).catch(error => {
this.delLoading = false;
this.$message.error(error.toString());
});
}).catch(() => {
});
},
/**
* 批量删除,之前的选中
*/
selsChange: function (sels) {
this.sels = sels;
},
/**
* 车辆状态为执行状态的时候,无法被选中
*/
isSelectable(row, index) {
if (row.vehicleStatus === '2') {
return false;
} else {
return true;
}
},
/**
* 批量删除功能
*/
batchRemove() {
var ids = this.sels.map(item => item.id).toString();
console.log(ids);
//弹框询问是否批量删除选中的车辆调度记录
this.$confirm('此操作永久删除选中的车辆信息, 是否继续?', '警告', {
confirmButtonText: '确定删除',
cancelButtonText: '取消',
type: 'warning'
}
).then(() => {
//开启加载
this.listLoading = true;
let params = {ids: ids};
batchRemoveVehicleInfo(params).then(response => {
let res = response.data;
if (res.code !== '200') {
this.listLoading = false;
return this.$message.error('批量删除车辆信息,失败');
}
this.$message.success('批量删除车辆信息,成功!');
this.listLoading = false;
//刷新车辆信息列表
this.getVehicleInfoList();
}).catch(error => {
this.delLoading = false;
this.$message.error(error.toString());
});
}).catch(() => {
});
},
/**
* 管理员端,编辑车辆信息
*/
editVehicleInfo() {
/*进行表单的预验证*/
this.$refs.editVehicleInfoFormRef.validate(valid => {
// 未通过,表单预校验
if (!valid) return;
// 通过,表单预校验,开启加载
this.editLoading = true;
updateVehicleInfo(this.editVehicleInfoForm).then((response) => {
let res = response.data;
if (res.code !== '200') {
//关闭加载
this.editLoading = false;
return this.$message.error('修改车辆信息,失败');
}
//关闭加载
this.editLoading = false;
this.$message.success('修改车辆信息,成功!');
//关闭编辑车辆信息对话框
this.editDialogVisible = false;
//刷新车辆信息列表
this.getVehicleInfoList();
}).catch(error => {
this.editLoading = false;
this.$message.error(error.toString());
});
})
},
/**
* 添加车辆信息对话框,关闭时,重置对话框
*/
addVehicleInfoDialogClosed() {
this.$refs.addVehicleInfoFormRef.resetFields();
},
/**
* 编辑车辆信息对话框,关闭时,重置对话框
*/
editVehicleInfoDialogClosed() {
this.$refs.editVehicleInfoFormRef.resetFields();
},
/**
* 打开编辑车辆信息对话框
*/
showEditDialogVisible(index, row) {
this.editVehicleInfoForm = Object.assign({}, row);
this.editDialogVisible = true;
},
/**
* 监听pageSize改变的事件
*/
handleSizeChange(newSize) {
this.queryInfo.pageSize = newSize;
//刷新车辆信息列表
this.getVehicleInfoList();
},
/**
* 监听当前页码值改变的事件
*/
handleCurrentChange(newPage) {
this.queryInfo.pageNum = newPage;
//刷新车辆信息列表
this.getVehicleInfoList();
},
}
}
</script>
<style scoped>
</style>