34fbc487
wuxw
完成预约功能
|
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
|
<template v-if="communitySpaces.length > 0">
<el-table-column v-for="space in communitySpaces" :key="space.spaceId" :label="space.name" align="center">
<template slot-scope="{ $index }">
<div v-if="getSpaceStatus($index, space) === 'available'">
<el-button type="text" @click="openAddModal(space.spaceId, $index)">
{{ $t('reportCommunitySpace.available') }}
</el-button>
</div>
<div v-else>
{{ getSpaceStatus($index, space) }}
</div>
</template>
</el-table-column>
</template>
<el-table-column v-else :label="$t('reportCommunitySpace.noSpace')" align="center" />
</el-table>
</el-card>
</el-col>
</el-row>
<add-community-space-person ref="addPersonDialog" @success="fetchData" />
</div>
</template>
<script>
import { listCommunityVenue, listCommunitySpace, listCommunitySpacePerson } from '@/api/community/reportCommunitySpaceApi'
import AddCommunitySpacePerson from '@/components/community/addCommunitySpacePerson'
import { getCommunityId } from '@/api/community/communityApi'
import { getDateYYYYMMDD } from '@/utils/dateUtil'
export default {
name: 'ReportCommunitySpaceList',
components: { AddCommunitySpacePerson },
data() {
return {
queryParams: {
venueId: '',
appointmentTime: getDateYYYYMMDD(),
communityId: getCommunityId()
},
venues: [],
communitySpaces: [],
spacePersons: [],
tableData: Array.from({ length: 24 }, (_, i) => ({ time: `${i}` }))
}
},
created() {
this.fetchVenues()
},
methods: {
selectVenue(venue) {
this.queryParams.venueId = venue.venueId
this.fetchData()
},
async fetchVenues() {
try {
const params = {
page: 1,
row: 100,
communityId: this.queryParams.communityId
}
this.venues = await listCommunityVenue(params)
if (this.venues.length > 0) {
this.queryParams.venueId = this.venues[0].venueId
this.fetchData()
}
} catch (error) {
this.$message.error(this.$t('common.fetchFailed'))
}
},
async fetchData() {
if (!this.queryParams.venueId) return
try {
// 获取场地列表
const spaceParams = {
page: 1,
row: 100,
venueId: this.queryParams.venueId,
communityId: this.queryParams.communityId
}
this.communitySpaces = await listCommunitySpace(spaceParams)
// 获取预约记录
const personParams = {
page: 1,
row: 100,
venueId: this.queryParams.venueId,
appointmentTime: this.queryParams.appointmentTime,
communityId: this.queryParams.communityId,
state: 'S'
}
this.spacePersons = await listCommunitySpacePerson(personParams)
} catch (error) {
this.$message.error(this.$t('common.fetchFailed'))
}
},
getSpaceStatus(hour, space) {
// 检查场地是否在该小时不可用
const openTime = space.openTimes.find(t => t.hours == hour)
if (openTime && openTime.isOpen === 'N') {
return this.$t('reportCommunitySpace.notAvailable')
}
// 检查是否有预约
const person = this.spacePersons.find(p => p.spaceId === space.spaceId)
if (person) {
const timeSlot = person.times.find(t => t.hours == hour)
if (timeSlot) {
return `${person.personName} > ${person.personTel}`
}
}
return 'available'
},
openAddModal(spaceId, hour) {
const data = {
spaceId: spaceId,
hours: hour,
appointmentTime: this.queryParams.appointmentTime,
openTime: hour
}
this.$refs.addPersonDialog.open(data)
}
}
}
</script>
<style lang="scss" scoped>
.app-container {
padding: 20px;
}
.box-card {
margin-bottom: 20px;
}
.filter-container {
margin-bottom: 20px;
}
.venue-list {
max-height: calc(100vh - 200px);
overflow-y: auto;
}
.venue-items {
list-style: none;
padding: 0;
margin: 0;
}
.venue-items li {
padding: 12px 15px;
border-bottom: 1px solid #eee;
cursor: pointer;
transition: all 0.3s;
}
.venue-items li:hover {
background-color: #f5f7fa;
}
.venue-items li.active {
|