chooseParkingSpace.vue
4.38 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
<template>
<el-dialog :title="$t('auditParkingSpaceApply.selectParkingSpace')" :visible.sync="visible" width="80%"
@close="handleClose">
<el-card>
<el-row :gutter="20">
<el-col :span="18"></el-col>
<el-col :span="6">
<el-input-group>
<el-input v-model="searchParams.areaNum" :placeholder="$t('auditParkingSpaceApply.inputParkingLot')" />
<el-button type="primary" @click="queryParkingSpaces">
{{ $t('common.search') }}
</el-button>
</el-input-group>
</el-col>
</el-row>
<el-table :data="parkingSpaces" style="width: 100%" border>
<el-table-column prop="areaNum" :label="$t('auditParkingSpaceApply.parkingLot')" align="center">
<template slot-scope="scope">
{{ scope.row.areaNum }}{{ $t('auditParkingSpaceApply.parkingLotUnit') }}
</template>
</el-table-column>
<el-table-column prop="num" :label="$t('auditParkingSpaceApply.parkingSpace')" align="center">
<template slot-scope="scope">
{{ scope.row.num }}{{ $t('auditParkingSpaceApply.parkingSpaceUnit') }}
</template>
</el-table-column>
<el-table-column prop="state" :label="$t('auditParkingSpaceApply.parkingStatus')" align="center">
<template slot-scope="scope">
{{ viewParkingSpaceState(scope.row.state) }}
</template>
</el-table-column>
<el-table-column prop="parkingTypeName" :label="$t('auditParkingSpaceApply.parkingType')" align="center" />
<el-table-column prop="area" :label="$t('auditParkingSpaceApply.area')" align="center" />
<el-table-column prop="psId" :label="$t('auditParkingSpaceApply.parkingSpace') + 'ID'" align="center" />
<el-table-column :label="$t('auditParkingSpaceApply.operation')" align="center">
<template slot-scope="scope">
<el-button size="mini" type="primary" @click="chooseParkingSpace(scope.row)">
{{ $t('auditParkingSpaceApply.choose') }}
</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination :current-page="pagination.currentPage" :page-sizes="[10, 20, 30, 50]"
:page-size="pagination.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="pagination.total"
@size-change="handleSizeChange" @current-change="handleCurrentChange" />
</el-card>
</el-dialog>
</template>
<script>
import { queryParkingSpaces } from '@/api/car/auditParkingSpaceApplyApi'
import { getCommunityId } from '@/api/community/communityApi'
export default {
name: 'ChooseParkingSpace',
props: {
visible: {
type: Boolean,
default: false
},
paId: {
type: String,
default: ''
}
},
data() {
return {
searchParams: {
areaNum: '',
state: 'F' // 默认查询空闲车位
},
parkingSpaces: [],
pagination: {
currentPage: 1,
pageSize: 10,
total: 0
},
communityId: getCommunityId()
}
},
methods: {
open() {
this.visible = true
this.queryParkingSpaces()
},
handleClose() {
this.$emit('update:visible', false)
},
async queryParkingSpaces() {
try {
const params = {
page: this.pagination.currentPage,
row: this.pagination.pageSize,
communityId: this.communityId,
...this.searchParams,
paId: this.paId
}
const res = await queryParkingSpaces(params)
this.parkingSpaces = res.data.parkingSpaces
this.pagination.total = res.data.total
} catch (error) {
this.$message.error(this.$t('common.queryFailed'))
}
},
chooseParkingSpace(parkingSpace) {
this.$emit('choose', parkingSpace)
this.handleClose()
},
viewParkingSpaceState(state) {
const states = {
'F': this.$t('auditParkingSpaceApply.free'),
'S': this.$t('auditParkingSpaceApply.sold'),
'H': this.$t('auditParkingSpaceApply.rented'),
}
return states[state] || this.$t('auditParkingSpaceApply.unknown')
},
handleSizeChange(val) {
this.pagination.pageSize = val
this.queryParkingSpaces()
},
handleCurrentChange(val) {
this.pagination.currentPage = val
this.queryParkingSpaces()
}
}
}
</script>
<style scoped>
.el-input-group {
display: flex;
}
</style>