chooseParkingArea.vue
3.25 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
<template>
<el-dialog :title="$t('chooseParkingArea.title')" :visible.sync="visible" width="70%">
<div slot="header">
<el-row :gutter="20">
<el-col :span="18"></el-col>
<el-col :span="6">
<el-input v-model="searchForm.num"
:placeholder="$t('chooseParkingArea.parkingLotNumPlaceholder')"></el-input>
<el-button slot="append" type="primary" @click="queryParkingAreas">
{{ $t('chooseParkingArea.query') }}
</el-button>
<el-button type="primary" @click="resetParkingAreas">
{{ $t('chooseParkingArea.reset') }}
</el-button>
</el-col>
</el-row>
</div>
<el-table :data="parkingAreas" border>
<el-table-column prop="paId" :label="$t('chooseParkingArea.parkingLotId')" align="center"></el-table-column>
<el-table-column prop="num" :label="$t('chooseParkingArea.parkingLotNum')" align="center"></el-table-column>
<el-table-column prop="typeCd" :label="$t('chooseParkingArea.parkingLotType')" align="center"></el-table-column>
<el-table-column :label="$t('chooseParkingArea.operation')" align="center" width="120">
<template slot-scope="scope">
<el-button type="primary" size="mini" @click="selectParkingArea(scope.row)">
{{ $t('chooseParkingArea.select') }}
</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination @size-change="handleSizeChange" @current-change="handlePageChange"
:current-page="pagination.current" :page-sizes="[10, 20, 30, 50]" :page-size="pagination.size"
layout="total, sizes, prev, pager, next, jumper" :total="pagination.total"
style="margin-top:20px;text-align:right"></el-pagination>
</el-dialog>
</template>
<script>
import { listParkingAreas } from '@/api/car/listParkingSpaceApi'
import { getCommunityId } from '@/api/community/communityApi'
export default {
name: 'ChooseParkingArea',
data() {
return {
visible: false,
searchForm: {
num: ''
},
parkingAreas: [],
pagination: {
current: 1,
size: 10,
total: 0
}
}
},
methods: {
open() {
this.visible = true
this.loadParkingAreas()
},
async loadParkingAreas() {
try {
const params = {
page: this.pagination.current,
row: this.pagination.size,
communityId: getCommunityId(),
num: this.searchForm.num
}
const res = await listParkingAreas(params)
this.parkingAreas = res.parkingAreas
this.pagination.total = res.total
} catch (error) {
this.$message.error(this.$t('common.loadError'))
}
},
selectParkingArea(row) {
this.$emit('choose', row)
this.visible = false
},
queryParkingAreas() {
this.pagination.current = 1
this.loadParkingAreas()
},
resetParkingAreas() {
this.searchForm.num = ''
this.queryParkingAreas()
},
handlePageChange(page) {
this.pagination.current = page
this.loadParkingAreas()
},
handleSizeChange(size) {
this.pagination.size = size
this.loadParkingAreas()
}
}
}
</script>