Yard.vue
18.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
<template>
<div>
<el-card style="background-color: #F5F7FA">
<!-- 搜素区域 -->
<div>
<el-row :gutter="10">
<el-col :span="4">
<el-input v-model="yard_queryInfo.name" prefix-icon="el-icon-search" size="small"
placeholder="场站名称" clearable></el-input>
</el-col>
<el-col :span="4">
<el-input v-model="yard_queryInfo.customsCode" 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="yard_getList">
查询
</el-button>
<el-button type="primary" style="width:120px" size="small" @click="yard_toAddDialog">
场站添加
</el-button>
</el-col>
</el-row>
</div>
<!-- 列表区域 -->
<div style="margin-top: 20px;">
<el-table :data="yard_page.yardList" border size="mini"
v-loading="yard_loading.listLoading" element-loading-text="获取场站列表,拼命加载中">
<el-table-column type="index" align="center"></el-table-column>
<el-table-column label="场站名称" prop="name" align="center" width="120"></el-table-column>
<el-table-column label="区域代码" prop="areaCode" align="center" width="120"></el-table-column>
<el-table-column label="场站ID" prop="stationId" align="center" width="120"></el-table-column>
<el-table-column label="关区代码" prop="customsCode" align="center" width="120"></el-table-column>
<el-table-column label="备注信息" prop="remarks" align="center" width="200"></el-table-column>
<el-table-column label="操作" width="140px" align="center">
<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="yard_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="yard_loading.delLoading"
@click="yard_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="10" style="margin-top: 5px">
<el-pagination
@size-change="yard_handleSizeChange"
@current-change="yard_handleCurrentChange"
:current-page="yard_queryInfo.pageNum"
:page-sizes="[10,30,50,100]"
:page-size="yard_queryInfo.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="yard_page.total">
</el-pagination>
</el-col>
</el-row>
</div>
</el-card>
<!-- 场站添加 -->
<div>
<el-dialog title="场站添加:"
:visible.sync="yard_dialog.addDialog"
style="margin-top: -80px" text-align="center" width="60%"
@close="yard_addDialogClosed">
<el-form :inline="true" label-width="150px" status-icon style="margin-top: -10px;" align="center"
:model="yard_addForm" :rules="yard_addFormRules" ref="yard_addFormRef">
<el-form-item label="场站名称:" prop="name">
<el-input v-model="yard_addForm.name" style="width:300px" size="mini" clearable
placeholder="请输入场站名称">
</el-input>
</el-form-item>
<el-form-item label="区域代码:" prop="areaCode">
<el-input v-model="yard_addForm.areaCode" style="width:300px" size="mini" clearable
placeholder="请输入区域代码">
</el-input>
</el-form-item>
<el-form-item label="场站ID:" prop="stationId">
<el-input v-model="yard_addForm.stationId" style="width:300px" size="mini" clearable
placeholder="请输入场站ID">
</el-input>
</el-form-item>
<el-form-item label="关区代码:" prop="customsCode">
<el-select v-model="yard_addForm.customsCode" style="width: 300px" clearable size="small"
placeholder="请选择关区代码">
<el-option
v-for="item in customsCodeList"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="备注信息:" prop="remarks">
<el-input v-model="yard_addForm.remarks" style="width:300px" clearable size="mini"
type="textarea" :rows="5">
</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="yard_dialog.addDialog = false" size="medium"
style="width: 100px">取消
</el-button>
<el-button type="primary" @click="yard_add" :loading="yard_loading.addLoading"
size="medium" style="width: 100px">保存
</el-button>
</div>
</el-dialog>
</div>
<!-- 场站修改 -->
<div>
<el-dialog title="场站修改:"
:visible.sync="yard_dialog.editDialog"
style="margin-top: -80px" text-align="center" width="60%"
@close="yard_editDialogClosed">
<el-form :inline="true" label-width="150px" status-icon style="margin-top: -10px;" align="center"
:model="yard_editForm" :rules="yard_editFormRules" ref="yard_editFormRef">
<el-form-item label="场站名称:" prop="name">
<el-input v-model="yard_editForm.name" style="width:300px" size="mini" clearable
placeholder="请输入场站名称">
</el-input>
</el-form-item>
<el-form-item label="区域代码:" prop="areaCode">
<el-input v-model="yard_editForm.areaCode" style="width:300px" size="mini" clearable
placeholder="请输入区域代码">
</el-input>
</el-form-item>
<el-form-item label="场站ID:" prop="stationId">
<el-input v-model="yard_editForm.stationId" style="width:300px" size="mini" clearable
placeholder="请输入场站ID">
</el-input>
</el-form-item>
<el-form-item label="关区代码:" prop="customsCode">
<el-select v-model="yard_editForm.customsCode" style="width: 300px" clearable size="small"
placeholder="请选择关区代码">
<el-option
v-for="item in customsCodeList"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="备注信息:" prop="remarks">
<el-input v-model="yard_editForm.remarks" style="width:300px" clearable size="mini"
type="textarea" :rows="5">
</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="yard_dialog.editDialog = false" size="medium"
style="width: 100px">取消
</el-button>
<el-button type="primary" @click="yard_edit" :loading="yard_loading.editLoading"
size="medium" style="width: 100px">保存
</el-button>
</div>
</el-dialog>
</div>
</div>
</template>
<script>
import {selectYardList, insertYard, updateYard, deleteYard} from "../../api/station_dispatch";
export default {
name: "Yard",
data() {
return {
/**
* 搜索参数
*/
yard_queryInfo: {
// 场站名称
name: '',
customsCode: undefined,
// 当前页数
pageNum: 1,
// 每页大小
pageSize: 10,
},
/**
* yard,分页
*/
yard_page: {
yardList: [],
total: 0,
selectList: [],
},
/**
* 加载
*/
yard_loading: {
listLoading: false,
addLoading: false,
editLoading: false,
delLoading: false,
batchDelLoading: false,
},
/**
* 对话框
*/
yard_dialog: {
addDialog: false,
editDialog: false,
},
/**
* 备案添加,表单
*/
yard_addForm: {
// 场站名称
name: '',
// 区域代码
areaCode: '',
// 场站ID
stationId: '',
// 关区代码
customsCode: undefined,
// 备注信息
remarks: '',
},
customsCodeList: [
{
value: 4604,
label: '4604'
},
{
value: 4620,
label: '4620'
},
],
/**
* 备案添加,表单验证规则
*/
yard_addFormRules: {
name: [
{required: true, message: '请输入场站名称', trigger: ['blur', 'change']},
],
},
/**
* 备案修改,表单
*/
yard_editForm: {},
/**
* 备案修改,表单验证规则
*/
yard_editFormRules: {
name: [
{required: true, message: '请输入场站名称', trigger: ['blur', 'change']},
],
},
}
},
methods: {
/**
* 分页查询,监听 pageSize 改变的事件
* 刷新列表
*/
yard_handleSizeChange(newSize) {
this.yard_queryInfo.pageSize = newSize;
this.yard_getList();
},
/**
* 分页查询,监听 pageNum 改变的事件
* 刷新列表
*/
yard_handleCurrentChange(newPage) {
this.yard_queryInfo.pageNum = newPage;
this.yard_getList();
},
/**
* 列表查询
*/
yard_getList() {
this.yard_loading.listLoading = true;
selectYardList(this.yard_queryInfo).then((response) => {
let res = response.data;
if (res.code !== '200') {
this.yard_loading.listLoading = false;
return this.$message.error(res.msg);
}
this.yard_page.yardList = res.data.list;
this.yard_page.total = res.data.total;
this.yard_loading.listLoading = false;
}).catch(error => {
this.yard_loading.listLoading = false;
this.$message.error(error.toString());
});
},
/**
* 对话框,备案添加,打开事件
*/
yard_toAddDialog() {
this.yard_dialog.addDialog = true;
},
/**
* 对话框,备案添加,关闭事件
*/
yard_addDialogClosed() {
this.$refs.yard_addFormRef.resetFields();
},
/**
* 备案添加
*/
yard_add() {
this.$refs.yard_addFormRef.validate(valid => {
// 未通过,表单预校验
if (!valid) return;
// 通过,表单预检验
this.yard_loading.addLoading = true;
insertYard(this.yard_addForm).then((response) => {
let res = response.data;
if (res.code !== '200') {
this.yard_loading.addLoading = false;
return this.$message.error(res.msg);
}
this.$message.success(res.msg);
this.yard_loading.addLoading = false;
this.yard_dialog.addDialog = false;
this.yard_getList();
}).catch(error => {
this.yard_loading.addLoading = false;
this.$message.error(error.toString());
});
})
},
/**
* 备案修改,对话框,打开事件
*/
yard_toEditDialog(index, row) {
this.yard_editForm = Object.assign({}, row);
this.yard_dialog.editDialog = true;
},
/**
* 备案修改,对话框,关闭事件
*/
yard_editDialogClosed() {
this.$refs.yard_editFormRef.resetFields();
},
/**
* 备案修改
*/
yard_edit() {
this.$refs.yard_editFormRef.validate(valid => {
// 未通过,表单预校验
if (!valid) return;
this.yard_loading.editLoading = true;
updateYard(this.yard_editForm).then((response) => {
let res = response.data;
if (res.code !== '200') {
this.yard_loading.editLoading = false;
return this.$message.error(res.msg);
}
this.$message.success(res.msg);
this.yard_loading.editLoading = false;
this.yard_dialog.editDialog = false;
this.yard_getList();
}).catch(error => {
this.yard_loading.editLoading = false;
this.$message.error(error.toString());
});
})
},
/**
* 删除功能
*/
yard_delete(index, row) {
this.$confirm('此操作永久删除该场站信息, 是否继续?', '警告', {
confirmButtonText: '确定删除',
cancelButtonText: '取消',
type: 'warning'
}
).then(() => {
this.yard_loading.delLoading = true;
deleteYard(row).then((response) => {
let res = response.data;
if (res.code !== '200') {
this.yard_loading.delLoading = false;
return this.$message.error(res.msg);
}
this.yard_loading.delLoading = false;
this.$message.success(res.msg);
this.yard_getList();
}).catch(error => {
this.yard_loading.delLoading = false;
this.$message.error(error.toString());
});
}).catch(() => {
});
},
},
}
</script>
<style scoped>
</style>