shipper.vue
20.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
<template>
<section>
<!--工具条-->
<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
<el-form :inline="true" :model="filters">
<el-form-item>
<el-input v-model="filters.fullName" placeholder="简称查询"></el-input>
</el-form-item>
<el-form-item>
<el-button type="warning" style="width:150px" size="medium" icon="el-icon-plus" v-on:click="getShipperList()">查询</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" style="width:150px" size="medium" icon="el-icon-plus" @click="companyAdd">新增</el-button>
</el-form-item>
<el-form-item>
<el-button type="danger" style="width:150px" icon="el-icon-delete" size="medium" @click="batchRemove">批量删除</el-button>
</el-form-item>
</el-form>
</el-col>
<!--列表-->
<el-table :data="shipperList" highlight-current-row v-loading="listLoading" @selection-change="selsChange"
style="border-radius: 10px 10px 0px 0px;line-height: 25px;"
:header-cell-style="{background:'#6F8294',color:'#FFFFFF'}" size="small">
<el-table-column type="selection" width="55">
</el-table-column>
<el-table-column prop="forShort" label="全称" >
</el-table-column>
<el-table-column prop="fullName" label="简称">
</el-table-column>
<el-table-column prop="theShipperType" label="类型">
<template slot-scope="scope">
<span v-if="scope.row.theShipperType == '1'" style="color: #ff4d51">发货人</span>
<span v-if="scope.row.theShipperType == '2'" style="color: #5BB75B">操作代理</span>
<span v-if="scope.row.theShipperType == '3'" style="color: #001528">订舱代理</span>
</template>
</el-table-column>
<el-table-column prop="contacts" label="联系人">
</el-table-column>
<el-table-column prop="phone" label="电话">
</el-table-column>
<el-table-column label="操作" min-width="180px" fixed="right">
<template slot-scope="scope">
<el-button type="primary" icon="el-icon-edit" size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
<el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDel(scope.$index, scope.row)">删除</el-button>
<!-- <el-button type="primary" size="small" @click="print(scope.$index, scope.row)">打印</el-button>-->
</template>
</el-table-column>
</el-table>
<!--分页-->
<el-col :span="24" class="toolbar">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page.sync="pageSize"
:page-sizes="[10, 30, 50, 100]"
:page-size=limitSize
layout="total,sizes, prev, pager, next"
:total=total>
</el-pagination>
</el-col>
<!--编辑界面-->
<el-dialog title="编辑" :visible.sync="editFormVisible" :close-on-click-modal="false" width="60%" text-align="center" tyle="margin-top: -20px">
<el-form :model="editForm" :rules="editFormRules" ref="editForm" align="center" label-width="145px" style="margin-top: -10px">
<el-row>
<el-col :span="4">
<el-form-item label="ID" hidden>
<span>{{editForm.id}}</span>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8" style="margin-right: 20px">
<el-form-item label="" prop="forShort">
<el-input v-model="editForm.forShort" auto-complete="on" placeholder="全称" style="width:300px" size="small">
<template slot="prepend" >全称</template>
</el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="" prop="fullName">
<el-input v-model="editForm.fullName" onkeyup="this.value=this.value.toUpperCase()" auto-complete="on" placeholder="简称" style="width:300px" size="small">
<template slot="prepend" >简称</template>
</el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8" style="margin-right: 20px">
<el-form-item label="" prop="theShipperType">
<el-select v-model="editForm.theShipperType" placeholder="请选择货主类型">
<el-option
v-for="item in typeOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="" prop="destination">
<el-input v-model="editForm.contacts"
auto-complete="on" placeholder="联系人" style="width:300px" size="small">
<template slot="prepend" >联系人</template>
</el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8" style="margin-right: 20px">
<el-form-item label="" prop="piece">
<el-input v-model="editForm.phone"
auto-complete="on" placeholder="phone" style="width:300px" size="small">
<template slot="prepend" >phone</template>
</el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer" align="center">
<el-button type="success" size="medium" style="width: 120px" @click.native="editSubmit(1)">保存</el-button>
</div>
</el-dialog>
<!--新增界面-->
<el-dialog title="新增" :visible.sync="addFormVisible" :close-on-click-modal="false" tyle="margin-top: -20px"
width="60%" text-align="center">
<el-form :model="addForm" label-width="145px" status-icon style="margin-top: -10px" align="center" :rules="addFormRules" ref="addForm">
<el-row>
<el-col :span="8" style="margin-right: 20px">
<el-form-item label="" prop="forShort">
<el-input v-model="addForm.forShort" auto-complete="on" placeholder="全称"
style="width:300px" size="small">
<template slot="prepend" >全称</template>
</el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="" prop="fullName">
<el-input v-model="addForm.fullName" onkeyup="this.value=this.value.toUpperCase()" auto-complete="on" placeholder="简称" style="width:300px" size="small">
<template slot="prepend" >简称</template>
</el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8" style="margin-right: 20px">
<el-form-item label="" prop="theShipperTypeList" >
<el-select v-model="addForm.theShipperTypeList" multiple placeholder="请选择货主类型">
<el-option
v-for="item in typeOptions"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="" prop="contacts">
<el-input v-model="addForm.contacts"
auto-complete="on" placeholder="联系人" style="width:300px" size="small">
<template slot="prepend" >联系人</template>
</el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8" style="margin-right: 20px">
<el-form-item label="" prop="phone">
<el-input v-model="addForm.phone"
auto-complete="on" placeholder="电话" style="width:300px" size="small">
<template slot="prepend" >电话</template>
</el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer" align="center">
<el-button type="success" size="medium" style="width: 120px" @click.native="addSubmit(1)">保存</el-button>
</div>
</el-dialog>
</section>
</template>
<script>
import { getList, remove, add, edit} from '../../api/shipper/shipper';
export default {
data() {
// Vue.component('barcode', VueBarcode);
return {
typeOptions: [{
value: '1',
label: '发货人'
}, {
value: '2',
label: '操作代理'
}, {
value: '3',
label: '订舱代理'
}],
filters: {
fullName: ''
},
shipperList: [],
total: 0,
pageSize: 1,
limitSize: 10,
listLoading: false,
//编辑界面是否显示
editFormVisible: false,
editLoading: false,
printFormVisible: false,
editFormRules: {
forShort: [
{ required: true, message: '请输入全称', trigger: 'blur' }
],
fullName: [
{ required: true, message: '请输入简称', trigger: 'blur' }
],
theShipperType: [
{ required: true, message: '请选择货主类型', trigger: 'blur' }
],
contacts: [
{ required: true, message: '请输入联系人', trigger: 'blur' }
],
phone: [
{ required: true, message: '请输入电话', trigger: 'blur' }
]
},
//编辑界面数据
editForm: {
id:'',
forShort: '',
fullName: '',
theShipperType: '',
contacts: '',
phone: ''
},
//新增界面是否显示
addFormVisible: false,
addFormRules: {
forShort: [
{ required: true, message: '请输入全称', trigger: 'change' }
],
fullName: [
{ required: true, message: '请输入简称', trigger: 'change' }
],
theShipperTypeList: [
{ required: true, message: '请选择货主类型', trigger: 'change' }
],
contacts: [
{ required: true, message: '请输入联系人', trigger: 'change' }
],
phone: [
{ required: true, message: '请输入电话', trigger: 'change' }
]
},
//新增界面数据
addForm: {
id:'',
forShort: '',
fullName: '',
theShipperType: '',
contacts: '',
phone: '',
theShipperTypeList:''
}
}
},
mounted() {
this.getShipperList();
},
methods: {
/**
* 分页
* @param val
*/
handleSizeChange(val) {
this.limitSize = val;
this.getShipperList();
},
handleCurrentChange(val) {
this.pageSize = val;
this.getShipperList();
},
//获取货主信息列表
getShipperList() {
let para = {
pageSize: this.pageSize,
limitSize: this.limitSize,
fullName: this.filters.fullName
};
this.listLoading = true;
getList(para).then((res) => {
this.total = res.data.data.total;
this.shipperList = res.data.data.list;
this.listLoading = false;
}).catch((error) => {
this.listLoading = false;
if(null!= error.response && error.response!==undefined){
let status= error.response.status;
let msg = error.response.statusText;
alert(status+msg);
}else {
alert(error);
}
});
},
//删除
handleDel: function (index, row) {
this.$confirm('确认删除该记录吗?', '提示', {
type: 'warning'
}).then(() => {
this.listLoading = true;
let para = {ids: row.id };
remove(para).then((res) => {
if (res.data.code == '200'){
this.listLoading = false;
this.$message({
message: res.data.msg,
type: 'success'
});
this.getShipperList();
}else {
this.listLoading = false;
this.$message({
message: res.data.msg,
type: 'error'
});
this.getShipperList();
}
}).catch((error) => {
this.listLoading = false;
alert(error);
});
}).catch();
},
/**
* 显示编辑界面
* @param index
* @param row 为这行的数据对象
*/
handleEdit: function (index, row) {
this.editFormVisible = true;
this.editForm = Object.assign({}, row);
this.getShipperList();
},
//编辑
editSubmit: function (value) {
this.$refs.editForm.validate((valid) => {
if (valid) {
this.$confirm('确认提交吗?', '提示', {}).then(() => {
this.editLoading = true;
let para = Object.assign({}, this.editForm);
this.editLoading = true;
edit(para).then((res) => {
if (res.data.code == '200'){
this.$message({
message: res.data.msg,
type: 'success'
});
this.$refs['editForm'].resetFields();
this.editFormVisible = false;
this.getShipperList();
}else {
this.$message({
message: res.data.msg,
type: 'error'
});
}
}).catch(error => alert(error));
}).catch(() =>{
});
}
});
},
//显示新增界面,每次点开初始化数据
companyAdd: function () {
if (this.$refs['addForm'] != null){
this.$refs['addForm'].resetFields();
}
this.addFormVisible = true;
this.getShipperList();
},
// 新增
addSubmit: function (value) {
this.$refs.addForm.validate((valid) => {
if (valid) {
this.$confirm('确认提交吗?', '提示', {}).then(() => {
let para = Object.assign({}, this.addForm);
add(para).then((res) => {
if (res.data.code == '200'){
this.$message({
message: res.data.msg,
type: 'success'
});
this.$refs['addForm'].resetFields();
this.addFormVisible = false;
this.getShipperList();
}else {
this.$message({
message: res.data.msg,
type: 'error'
});
}
}).catch(error => alert(error));
}).catch(() =>{
});
}
});
},
selsChange: function (sels) {
this.sels = sels;
},
//批量删除
batchRemove: function () {
var ids = this.sels.map(item => item.id).toString();
this.$confirm('确认删除选中记录吗?', '提示', {
type: 'warning'
}).then(() => {
this.listLoading = true;
//NProgress.start();
let para = { ids: ids };
remove(para).then((res) => {
this.listLoading = false;
//NProgress.done();
this.$message({
message: '删除成功',
type: 'success'
});
this.getShipperList();
});
}).catch(() => {
});
},
},
}
</script>
<style>
.el-input-group__prepend {
background-color: #6F8294;
color:#ffffff
}
.el-input__inner{
background-color: #F7F7F7;
}
.el-dialog-div .flight-info .select-lable{
line-height: 17px;
float:left;
width:80px;
font-size:12px;
text-align: center;
}
</style>