Trailer.vue
23.9 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
<template>
<el-container>
<el-main>
<el-card style="background-color: #F5F7FA">
<!-- 搜素区域 -->
<div>
<el-row :gutter="10">
<el-col :span="4">
<el-input v-model="trailer_queryInfo.trailerLicenseNo" prefix-icon="el-icon-search" size="small"
placeholder="挂车牌号" clearable></el-input>
</el-col>
<el-col :span="8">
<el-button type="success" style="width:120px" size="small" @click="trailer_getList">
查询
</el-button>
<el-button type="primary" style="width:120px" size="small" @click="trailer_toAddDialog">
备案添加
</el-button>
</el-col>
</el-row>
</div>
<!-- 列表区域 -->
<div style="margin-top: 20px;">
<el-table :data="trailer_page.trailerList" border size="mini" @selection-change="trailer_selectChange"
v-loading="trailer_loading.listLoading" element-loading-text="获取挂车列表,拼命加载中">
<el-table-column type="selection" width="55" align="center"></el-table-column>
<el-table-column type="index" align="center"></el-table-column>
<el-table-column label="主管海关代码" prop="mainPort" align="center" width="100"></el-table-column>
<el-table-column label="挂车车牌号" prop="trailerLicenseNo" align="center" width="110"></el-table-column>
<el-table-column label="挂车车架号" prop="frameNo" align="center" width="150"></el-table-column>
<el-table-column label="挂车注册地" prop="trailerRegPlace" align="center" width="120"></el-table-column>
<el-table-column label="挂车重量" prop="trailerWt" align="center" width="80"></el-table-column>
<el-table-column label="挂车类型" prop="trailerClassFlag" align="center" width="100"></el-table-column>
<el-table-column label="挂车颜色" prop="trailerColor" align="center" width="100"></el-table-column>
<el-table-column label="更新时间" prop="updateDate" align="center" width="140"></el-table-column>
<el-table-column label="操作" width="180px" align="center" fixed="right">
<template slot-scope="scope">
<el-tooltip effect="dark" content="编辑" placement="top-start" :enterable="false">
<el-button type="text" icon="el-icon-edit" size="mini"
@click="trailer_toEditDialog(scope.$index,scope.row)">编辑
</el-button>
</el-tooltip>
<el-tooltip effect="dark" content="删除" placement="top-start" :enterable="false">
<el-button type="text" icon="el-icon-delete" size="mini"
:loading="trailer_loading.delLoading"
@click="trailer_delete(scope.$index,scope.row)">删除
</el-button>
</el-tooltip>
</template>
</el-table-column>
</el-table>
</div>
<!-- 分页区域 -->
<div style="margin-top: 10px">
<el-row :gutter="24">
<el-col :span="5">
<el-button type="danger" icon="el-icon-delete"
:loading="trailer_loading.listLoading"
:disabled="this.trailer_page.selectList.length===0"
size="small"
@click="trailer_batchRemove">批量删除
</el-button>
</el-col>
<el-col :span="10" style="margin-top: 5px">
<el-pagination
@size-change="trailer_handleSizeChange"
@current-change="trailer_handleCurrentChange"
:current-page="trailer_queryInfo.pageNum"
:page-sizes="[10,30,50,100]"
:page-size="trailer_queryInfo.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="trailer_page.total">
</el-pagination>
</el-col>
</el-row>
</div>
</el-card>
</el-main>
<!-- 备案添加 -->
<div>
<el-dialog title="挂车信息:备案添加"
:visible.sync="trailer_dialog.addDialog"
style="margin-top: -80px" text-align="center" width="65%"
@close="trailer_addDialogClosed">
<el-form :inline="true" label-width="150px" status-icon style="margin-top: -10px;margin-left: 60px"
:model="trailer_addForm" :rules="trailer_addFormRules" ref="trailer_addFormRef">
<el-form-item label="海关代码:" prop="mainPort">
<el-input v-model="trailer_addForm.mainPort" style="width:240px" size="mini" clearable
placeholder="请输入海关代码">
</el-input>
</el-form-item>
<el-form-item label="挂车牌号:" prop="trailerLicenseNo">
<el-input v-model="trailer_addForm.trailerLicenseNo" style="width:240px" size="mini" clearable
placeholder="请输入挂车牌号">
</el-input>
</el-form-item>
<el-form-item label="挂车注册地:" prop="trailerRegPlace">
<el-input v-model="trailer_addForm.trailerRegPlace" style="width:240px" size="mini" clearable
placeholder="请输入挂车注册地">
</el-input>
</el-form-item>
<el-form-item label="车架号码:" prop="frameNo">
<el-input v-model="trailer_addForm.frameNo" style="width:240px" size="mini" clearable
placeholder="请输入车架号码">
</el-input>
</el-form-item>
<el-form-item label="挂车重量:" prop="trailerWt">
<el-input v-model="trailer_addForm.trailerWt" style="width:240px" size="mini" clearable
placeholder="请输入挂车重量">
</el-input>
</el-form-item>
<el-form-item label="挂车颜色:" prop="trailerColor">
<el-input v-model="trailer_addForm.trailerColor" style="width:240px" size="mini" clearable
placeholder="请输入挂车颜色">
</el-input>
</el-form-item>
<el-form-item label="申请人:" prop="proposer">
<el-input v-model="trailer_addForm.proposer" style="width:240px" size="mini" clearable
placeholder="请输入申请人">
</el-input>
</el-form-item>
<el-form-item label="申请时间:" prop="proposeTime">
<el-date-picker v-model="trailer_addForm.proposeTime" clearable type="datetime"
value-format="yyyy-MM-dd HH:mm:ss" placeholder="申请时间" size="mini" style="width:240px"></el-date-picker>
</el-form-item>
<el-form-item label="挂车备案类别:" prop="trailerClassFlag">
<el-input v-model="trailer_addForm.trailerClassFlag" style="width:240px" size="mini" clearable
placeholder="请输入挂车备案类别">
</el-input>
</el-form-item>
<el-form-item label="数据操作类型:" prop="operationType">
<el-input v-model="trailer_addForm.operationType" style="width:240px" size="mini" clearable
placeholder="请输入数据操作类型">
</el-input>
</el-form-item>
<el-form-item label="挂车牌号图片:" prop="trailerLicenseNoPic">
<img v-if="!trailer_config.progressFlag" style="width: 100px;height: 100px" :src="trailer_config.imageUrl"/>
<el-upload
style="display: inline; margin-left: 10px;margin-right: 10px;"
action=""
:show-file-list="true"
:http-request="uploadFile"
:limit=1
:on-preview="handPreView"
:on-exceed="fileExceed"
accept="image/jpeg,image/jpg,image/png"
ref="fileupload">
<el-button slot="trigger" size="small" type="primary">上传图片</el-button>
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>
</el-upload>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer" style="text-align: center;margin-top: -30px">
<el-button type="info" @click="trailer_dialog.addDialog = false" size="medium"
style="width: 100px">取消
</el-button>
<el-button type="primary" @click="trailer_add" :loading="trailer_loading.addLoading"
size="medium" style="width: 100px">保存
</el-button>
</div>
</el-dialog>
</div>
<!-- 修改,对话框 -->
<div>
<el-dialog title="挂车信息:备案修改"
:visible.sync="trailer_dialog.editDialog"
style="margin-top: -80px" text-align="center" width="65%"
@close="trailer_editDialogClosed">
<el-form :inline="true" label-width="150px" status-icon style="margin-top: -10px;margin-left: 60px"
:model="trailer_editForm" :rules="trailer_editFormRules" ref="trailer_editFormRef">
<el-form-item label="海关代码:" prop="mainPort">
<el-input v-model="trailer_editForm.mainPort" style="width:240px" size="mini" clearable
placeholder="请输入海关代码">
</el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer" style="text-align: center;margin-top: -30px">
<el-button type="info" @click="trailer_dialog.editDialog = false" size="medium"
style="width: 100px">取消
</el-button>
<el-button type="primary" @click="trailer_edit" :loading="trailer_loading.editLoading"
size="medium" style="width: 100px">保存
</el-button>
</div>
</el-dialog>
</div>
</el-container>
</template>
<script>
import {
selectTrailerList,
insertTrailer,
updateTrailer,
deleteTrailer,
batchRemoveTrailer, uploadFileImage
} from "../../api/vehicle_dispatch";
import {Message} from "element-ui";
export default {
name: "Trailer",
data() {
return {
trailerUpload: '',
trailer_config: {
progressFlag: true,
imageUrl: '',
},
/**
* 搜索参数
*/
trailer_queryInfo: {
// 挂车车牌号
trailerLicenseNo: '',
// 当前页数
pageNum: 1,
// 每页大小
pageSize: 10,
},
/**
* trailer,分页
*/
trailer_page: {
trailerList: [],
total: 0,
selectList: [],
},
/**
* 加载
*/
trailer_loading: {
listLoading: false,
addLoading: false,
editLoading: false,
delLoading: false,
batchDelLoading: false,
},
/**
* 对话框
*/
trailer_dialog: {
addDialog: false,
editDialog: false,
},
/**
* 备案添加,表单
*/
trailer_addForm: {
// 海关代码
mainPort: '',
// 挂车牌号
trailerLicenseNo: '',
// 挂车注册地
trailerRegPlace: '',
// 车架号码
frameNo: '',
// 挂车重量
trailerWt: '',
// 挂车颜色
trailerColor: '',
// 申请人
proposer: '',
// 申请时间
proposeTime: undefined,
// 挂车备案类别
trailerClassFlag: '',
// 数据操作类型
operationType: '',
// 挂车牌号图片
trailerLicenseNoPic: '',
},
/**
* 备案添加,表单验证规则
*/
trailer_addFormRules: {},
/**
* 车辆属性,(使用的是 车辆分类 字段)一错全错
*/
veClassFlagList: [
{
value: '1',
label: '普通车辆'
},
{
value: '2',
label: '调拨车辆'
},
],
/**
* 备案修改,表单
*/
trailer_editForm: {},
/**
* 备案修改,表单验证规则
*/
trailer_editFormRules: {},
}
},
methods: {
/**
* 分页查询,监听 pageSize 改变的事件
* 刷新列表
*/
trailer_handleSizeChange(newSize) {
this.trailer_queryInfo.pageSize = newSize;
this.trailer_getList();
},
/**
* 分页查询,监听 pageNum 改变的事件
* 刷新列表
*/
trailer_handleCurrentChange(newPage) {
this.trailer_queryInfo.pageNum = newPage;
this.trailer_getList();
},
/**
* 列表查询
*/
trailer_getList() {
this.trailer_loading.listLoading = true;
selectTrailerList(this.trailer_queryInfo).then((response) => {
let res = response.data;
if (res.code !== '200') {
this.trailer_loading.listLoading = false;
return this.$message.error(res.msg);
}
this.trailer_page.trailerList = res.data.list;
this.trailer_page.total = res.data.total;
this.trailer_loading.listLoading = false;
}).catch(error => {
this.trailer_loading.listLoading = false;
this.$message.error(error.toString());
});
},
/**
* 对话框,备案添加,打开事件
*/
trailer_toAddDialog() {
this.trailer_dialog.addDialog = true;
},
/**
* 对话框,备案添加,关闭事件
*/
trailer_addDialogClosed() {
this.$refs.trailer_addFormRef.resetFields();
},
/**
* 备案添加
*/
trailer_add() {
this.$refs.trailer_addFormRef.validate(valid => {
if (!valid) return;
this.trailer_loading.addLoading = true;
insertTrailer(this.trailer_addForm).then((response) => {
let res = response.data;
if (res.code !== '200') {
this.trailer_loading.addLoading = false;
return this.$message.error(res.msg);
}
this.$message.success(res.msg);
this.trailer_loading.addLoading = false;
this.trailer_dialog.addDialog = false;
this.trailer_getList();
}).catch(error => {
this.trailer_loading.addLoading = false;
this.$message.error(error.toString());
});
})
},
/**
* 备案修改,对话框,打开事件
*/
trailer_toEditDialog(index, row) {
this.trailer_editForm = Object.assign({}, row);
this.trailer_dialog.editDialog = true;
},
/**
* 备案修改,对话框,关闭事件
*/
trailer_editDialogClosed() {
this.$refs.trailer_editFormRef.resetFields();
},
/**
* 备案修改
*/
trailer_edit() {
this.$refs.trailer_editFormRef.validate(valid => {
if (!valid) return;
this.trailer_loading.editLoading = true;
updateTrailer(this.trailer_editForm).then((response) => {
let res = response.data;
if (res.code !== '200') {
this.trailer_loading.editLoading = false;
return this.$message.error(res.msg);
}
this.$message.success(res.msg);
this.trailer_loading.editLoading = false;
this.trailer_dialog.editDialog = false;
this.trailer_getList();
}).catch(error => {
this.trailer_loading.editLoading = false;
this.$message.error(error.toString());
});
})
},
/**
* trailer,批量删除---选中
*/
trailer_selectChange: function (selectList) {
this.trailer_page.selectList = selectList;
},
/**
* trailer,批量删除功能
*/
trailer_batchRemove() {
const ids = this.trailer_page.selectList.map(item => item.id).toString();
this.$confirm('此操作将永久删除选中的挂车信息, 是否继续?', '警告', {
confirmButtonText: '确定删除',
cancelButtonText: '取消',
type: 'warning'
}
).then(() => {
this.trailer_loading.listLoading = true;
let params = {id: ids};
batchRemoveTrailer(params).then(response => {
let res = response.data;
if (res.code !== '200') {
this.trailer_loading.listLoading = false;
return this.$message.error(res.msg);
}
this.$message.success(res.msg);
this.trailer_loading.listLoading = false;
this.trailer_getList();
}).catch(error => {
this.trailer_loading.listLoading = false;
this.$message.error(error.toString());
});
}).catch(() => {
});
},
/**
* trailer,删除功能
*/
trailer_delete(index, row) {
this.$confirm('此操作永久删除该挂车信息, 是否继续?', '警告', {
confirmButtonText: '确定删除',
cancelButtonText: '取消',
type: 'warning'
}
).then(() => {
this.trailer_loading.delLoading = true;
deleteTrailer(row).then((response) => {
let res = response.data;
if (res.code !== '200') {
this.trailer_loading.delLoading = false;
return this.$message.error(res.msg);
}
this.trailer_loading.delLoading = false;
this.$message.success(res.msg);
this.trailer_getList();
}).catch(error => {
this.trailer_loading.delLoading = false;
this.$message.error(error.toString());
});
}).catch(() => {
});
},
// 自定义上传
uploadFile(item) {
const form = new FormData()
form.append('file', item.file)
uploadFileImage(form).then(response => {
let res = response.data;
if (res.code !== '200') {
this.$message.error(res.msg)
}
this.$message.success(res.msg);
item.onSuccess()
this.trailer_config.progressFlag = false;
this.trailer_config.imageUrl = res.data;
})
},
fileExceed() {
this.$message.error('别贪心!一次只能上传一个哦~');
},
handPreView(file) {
}
},
created() {
},
mounted() {
},
}
</script>
<style scoped>
.avatar-uploader .avatar-uploader-icon {
border: 1px dashed #d9d9d9;
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
font-size: 28px;
color: #8c939d;
width: 178px;
height: 178px;
line-height: 178px;
text-align: center;
}
.avatar-uploader .avatar-uploader-icon:hover {
border-color: #409EFF;
}
.avatar-uploader img {
width: 178px;
height: 178px;
display: block;
}
</style>