@ebiz/designer-components 0.1.124 → 0.1.126

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. package/README.md +29 -29
  2. package/dist/designer-components.css +1 -1
  3. package/dist/index.mjs +35548 -33511
  4. package/dist/{pdf-C9oIcL2N.js → pdf-KomaE0u5.js} +891 -891
  5. package/package.json +1 -1
  6. package/src/App.vue +26 -26
  7. package/src/apiService/SIMPLE_DATA_SERVICE.md +284 -284
  8. package/src/apiService/mockDataService.js +115 -115
  9. package/src/apiService/simpleDataService.js +312 -312
  10. package/src/assets/base.css +86 -86
  11. package/src/assets/logo.svg +1 -1
  12. package/src/components/Button.vue +149 -149
  13. package/src/components/DataContainer.vue +40 -40
  14. package/src/components/EbizApproval.vue +366 -366
  15. package/src/components/EbizApprovalDetail.vue +169 -169
  16. package/src/components/EbizApprovalForm.vue +534 -534
  17. package/src/components/EbizApprovalV2.vue +713 -713
  18. package/src/components/EbizAutoForm.vue +596 -596
  19. package/src/components/EbizAvatar.vue +115 -115
  20. package/src/components/EbizCheckbox.vue +93 -93
  21. package/src/components/EbizCheckboxGroup.vue +69 -69
  22. package/src/components/EbizDepartmentSelector.vue +148 -148
  23. package/src/components/EbizDescriptions.vue +340 -340
  24. package/src/components/EbizDescriptionsItem.vue +47 -47
  25. package/src/components/EbizDetailBlock.vue +81 -81
  26. package/src/components/EbizDetailItem.vue +559 -559
  27. package/src/components/EbizDetailView.md +438 -438
  28. package/src/components/EbizDetailView.vue +355 -355
  29. package/src/components/EbizDialog.vue +260 -260
  30. package/src/components/EbizDictionarySelect.vue +229 -229
  31. package/src/components/EbizDiv.vue +40 -40
  32. package/src/components/EbizDivider.vue +96 -96
  33. package/src/components/EbizDormDashboard.vue +314 -314
  34. package/src/components/EbizDropdown.vue +135 -135
  35. package/src/components/EbizDropdownItem.vue +85 -85
  36. package/src/components/EbizEmployeeInfo.vue +144 -144
  37. package/src/components/EbizEmployeeSelector.vue +1160 -1160
  38. package/src/components/EbizFileList.vue +502 -502
  39. package/src/components/EbizMap.vue +541 -541
  40. package/src/components/EbizMeetingRoomSelector.vue +1149 -1149
  41. package/src/components/EbizMobileMeetingRoomSelector.vue +727 -727
  42. package/src/components/EbizOkrTree.vue +99 -99
  43. package/src/components/EbizPageHeader.vue +98 -98
  44. package/src/components/EbizPagination.vue +162 -162
  45. package/src/components/EbizParkingDashboard.vue +152 -152
  46. package/src/components/EbizPdfViewer.vue +540 -540
  47. package/src/components/EbizPopconfirm.vue +47 -47
  48. package/src/components/EbizQrCode.vue +167 -167
  49. package/src/components/EbizRadio.vue +86 -86
  50. package/src/components/EbizRadioGroup.vue +83 -83
  51. package/src/components/EbizRemoteSelect.vue +232 -232
  52. package/src/components/EbizRichTextEditor.vue +338 -338
  53. package/src/components/EbizRouteBreadcrumb.vue +46 -46
  54. package/src/components/EbizSApprovalProcess.vue +1456 -1426
  55. package/src/components/EbizSelect.vue +85 -85
  56. package/src/components/EbizSpace.vue +100 -100
  57. package/src/components/EbizStatistic.vue +149 -149
  58. package/src/components/EbizStatsCard.vue +113 -113
  59. package/src/components/EbizSwiper.vue +113 -113
  60. package/src/components/EbizSwiperItem.vue +13 -13
  61. package/src/components/EbizSwitch.vue +85 -85
  62. package/src/components/EbizTabHeader.vue +132 -132
  63. package/src/components/EbizTabPanel.vue +22 -22
  64. package/src/components/EbizTable.vue +469 -469
  65. package/src/components/EbizTableColumn.vue +116 -116
  66. package/src/components/EbizTableSort.vue +179 -179
  67. package/src/components/EbizTabs.vue +142 -142
  68. package/src/components/EbizTdesignButtonDialog.vue +332 -332
  69. package/src/components/EbizTdesignLoading.vue +107 -107
  70. package/src/components/EbizTimePicker.vue +143 -143
  71. package/src/components/EbizTitle.vue +91 -91
  72. package/src/components/EbizTree.vue +141 -141
  73. package/src/components/EbizTreeMergeTable.vue +1494 -1494
  74. package/src/components/EbizTreeSelector.vue +469 -469
  75. package/src/components/EbizVideo.vue +553 -553
  76. package/src/components/EbizVxeTable.vue +290 -290
  77. package/src/components/Form.vue +28 -28
  78. package/src/components/Home.vue +7 -7
  79. package/src/components/LaunchInterview.vue +526 -526
  80. package/src/components/MyComponent.vue +39 -39
  81. package/src/components/Table.vue +45 -45
  82. package/src/components/TdesignAlert.vue +115 -115
  83. package/src/components/TdesignButton.vue +135 -135
  84. package/src/components/TdesignCalendar/index.vue +145 -145
  85. package/src/components/TdesignCard.vue +195 -195
  86. package/src/components/TdesignCol.vue +101 -101
  87. package/src/components/TdesignCollapse.vue +142 -142
  88. package/src/components/TdesignCollapsePanel.vue +79 -79
  89. package/src/components/TdesignDatePicker.vue +124 -124
  90. package/src/components/TdesignDescriptions.vue +74 -74
  91. package/src/components/TdesignDescriptionsItem.vue +50 -50
  92. package/src/components/TdesignDialog.vue +225 -225
  93. package/src/components/TdesignForm.vue +138 -138
  94. package/src/components/TdesignFormItem.vue +105 -105
  95. package/src/components/TdesignGrid.vue +55 -55
  96. package/src/components/TdesignIcon.vue +67 -67
  97. package/src/components/TdesignImage.vue +162 -162
  98. package/src/components/TdesignImageViewer.vue +200 -200
  99. package/src/components/TdesignInput.vue +242 -242
  100. package/src/components/TdesignSelect.vue +446 -446
  101. package/src/components/TdesignTag.vue +117 -117
  102. package/src/components/TdesignTextarea.vue +142 -142
  103. package/src/components/TdesignTimeline.vue +58 -58
  104. package/src/components/TdesignTimelineItem.vue +71 -71
  105. package/src/components/TdesignUpload.vue +414 -414
  106. package/src/components/TdesignWatermark.vue +107 -107
  107. package/src/components/ebiz-form/components/cascader.vue +61 -61
  108. package/src/components/ebiz-form/components/checkbox.vue +37 -37
  109. package/src/components/ebiz-form/components/city.vue +137 -137
  110. package/src/components/ebiz-form/components/date-panel.vue +52 -52
  111. package/src/components/ebiz-form/components/date-range-panel.vue +52 -52
  112. package/src/components/ebiz-form/components/date-range.vue +56 -56
  113. package/src/components/ebiz-form/components/date.vue +52 -52
  114. package/src/components/ebiz-form/components/editor-multi-language.vue +47 -47
  115. package/src/components/ebiz-form/components/editor.vue +78 -78
  116. package/src/components/ebiz-form/components/file-multi-language.vue +52 -52
  117. package/src/components/ebiz-form/components/file.vue +149 -149
  118. package/src/components/ebiz-form/components/images-multi-language.vue +52 -52
  119. package/src/components/ebiz-form/components/images.vue +129 -129
  120. package/src/components/ebiz-form/components/img-multi-language.vue +51 -51
  121. package/src/components/ebiz-form/components/img.vue +129 -129
  122. package/src/components/ebiz-form/components/number.vue +50 -50
  123. package/src/components/ebiz-form/components/radio.vue +28 -28
  124. package/src/components/ebiz-form/components/select.vue +119 -119
  125. package/src/components/ebiz-form/components/switch.vue +23 -23
  126. package/src/components/ebiz-form/components/text-multi-language.vue +47 -47
  127. package/src/components/ebiz-form/components/text.vue +52 -52
  128. package/src/components/ebiz-form/components/textarea-multi-language.vue +48 -48
  129. package/src/components/ebiz-form/components/textarea.vue +29 -29
  130. package/src/components/ebiz-form/components/video-multi-language.vue +51 -51
  131. package/src/components/ebiz-form/components/video.vue +97 -97
  132. package/src/components/ebiz-form/index.vue +157 -157
  133. package/src/components/examples/PopconfirmExample.vue +149 -149
  134. package/src/components/icons/IconCommunity.vue +7 -7
  135. package/src/components/icons/IconDocumentation.vue +7 -7
  136. package/src/components/icons/IconEcosystem.vue +7 -7
  137. package/src/components/icons/IconSupport.vue +7 -7
  138. package/src/components/icons/IconTooling.vue +19 -19
  139. package/src/components/mItems/UserInfo.vue +349 -349
  140. package/src/components/senior/EbizApprovalList/ApprovalList.vue +127 -127
  141. package/src/components/senior/EbizSData/index.vue +280 -280
  142. package/src/components/senior/EbizSDialog/index.vue +776 -776
  143. package/src/components/senior/EbizSForm/README.md +157 -157
  144. package/src/components/senior/EbizSForm/index.vue +667 -667
  145. package/src/components/senior/EbizSForm/item.vue +1011 -1011
  146. package/src/components/senior/EbizSForm/mItems/DateTimePicker.vue +51 -51
  147. package/src/components/senior/EbizSForm/mItems/Picker.vue +63 -63
  148. package/src/index.js +327 -327
  149. package/src/main.js +55 -55
  150. package/src/router/index.js +436 -436
  151. package/src/utils/formatCode.js +24 -24
  152. package/src/utils/generateImportStatement.js +52 -52
  153. package/src/utils/hasJsx.js +25 -25
  154. package/src/utils/index.js +166 -166
  155. package/src/utils/mergeOptions.js +29 -29
  156. package/src/utils/parseRequiredBlocks.js +18 -18
  157. package/src/utils/vue-sfc-validator.js +155 -155
  158. package/src/views/Button.vue +23 -23
  159. package/src/views/CheckboxDemo.vue +104 -104
  160. package/src/views/DataContainer.vue +19 -19
  161. package/src/views/DialogDemo.vue +125 -125
  162. package/src/views/EbizApprovalDemo.vue +87 -87
  163. package/src/views/EbizApprovalFormDemo.vue +207 -207
  164. package/src/views/EbizAutoFormDemo.vue +129 -129
  165. package/src/views/EbizAvatar.vue +223 -223
  166. package/src/views/EbizDepartmentSelectorDemo.vue +169 -169
  167. package/src/views/EbizDetailBlockDemo.vue +30 -30
  168. package/src/views/EbizDetailViewDemo.vue +412 -412
  169. package/src/views/EbizDormDashboardDemo.vue +87 -87
  170. package/src/views/EbizEmployeeInfo.vue +249 -249
  171. package/src/views/EbizEmployeeSelector.vue +85 -85
  172. package/src/views/EbizFileListDemo.vue +339 -339
  173. package/src/views/EbizMap.vue +201 -201
  174. package/src/views/EbizMeetingRoomSelectorDemo.vue +293 -293
  175. package/src/views/EbizMobileMeetingRoomSelectorDemo.vue +566 -566
  176. package/src/views/EbizParkingDashboardDemo.vue +28 -28
  177. package/src/views/EbizRadioDemo.vue +151 -151
  178. package/src/views/EbizSDataDemo.vue +136 -136
  179. package/src/views/EbizSDialogDemo.vue +303 -303
  180. package/src/views/EbizSForm/index.vue +352 -352
  181. package/src/views/EbizSFormDemo.vue +420 -420
  182. package/src/views/EbizSpace.vue +185 -185
  183. package/src/views/EbizSwiper.vue +157 -157
  184. package/src/views/EbizTdesignButtonDialogExample.vue +437 -437
  185. package/src/views/Form.vue +19 -19
  186. package/src/views/GridDemo.vue +238 -238
  187. package/src/views/Home.vue +156 -156
  188. package/src/views/LaunchInterviewDemo.vue +111 -111
  189. package/src/views/Mindmap.vue +17 -17
  190. package/src/views/MyComponent.vue +19 -19
  191. package/src/views/OkrTree.vue +19 -19
  192. package/src/views/PageHeaderDemo.vue +104 -104
  193. package/src/views/PaginationDemo.vue +96 -96
  194. package/src/views/PdfViewerDemo.vue +433 -433
  195. package/src/views/PermissionBoxDemo.vue +85 -85
  196. package/src/views/PopconfirmDemo.vue +80 -80
  197. package/src/views/RemoteSelect.vue +350 -350
  198. package/src/views/StatisticDemo.vue +190 -190
  199. package/src/views/SwitchDemo.vue +79 -79
  200. package/src/views/Table.vue +19 -19
  201. package/src/views/TableDemo.vue +334 -334
  202. package/src/views/TableSortDemo.vue +143 -143
  203. package/src/views/TableView.vue +68 -68
  204. package/src/views/TabsDemo.vue +282 -282
  205. package/src/views/TagDemo.vue +101 -101
  206. package/src/views/TdesignAlert.vue +98 -98
  207. package/src/views/TdesignButton.vue +190 -190
  208. package/src/views/TdesignCalendar.vue +94 -94
  209. package/src/views/TdesignCard.vue +296 -296
  210. package/src/views/TdesignCollapse.vue +293 -293
  211. package/src/views/TdesignDatePicker.vue +187 -187
  212. package/src/views/TdesignDescriptions.vue +101 -101
  213. package/src/views/TdesignForm.vue +248 -248
  214. package/src/views/TdesignIcon.vue +203 -203
  215. package/src/views/TdesignImage.vue +215 -215
  216. package/src/views/TdesignImageViewer.vue +198 -198
  217. package/src/views/TdesignInput.vue +252 -252
  218. package/src/views/TdesignSelect.vue +473 -473
  219. package/src/views/TdesignSwiper.vue +157 -157
  220. package/src/views/TextareaDemo.vue +93 -93
  221. package/src/views/TimePickerDemo.vue +146 -146
  222. package/src/views/TimelineDemo.vue +160 -160
  223. package/src/views/Title.vue +19 -19
  224. package/src/views/TreeDemo.vue +254 -254
  225. package/src/views/TreeMergeTableDemo.vue +239 -239
  226. package/src/views/TreeSelectorDemo.vue +245 -245
  227. package/src/views/UploadDemo.vue +128 -128
  228. package/src/views/VideoDemo.vue +245 -245
  229. package/src/views/VxeTableDemo.vue +279 -279
  230. package/src/views/WatermarkDemo.vue +85 -85
@@ -1,1150 +1,1150 @@
1
- <template>
2
- <div>
3
- <div class="ebiz-meeting-room-selector">
4
- <!-- 头部区域 -->
5
- <div v-if="loading" class="loading-container">
6
- <t-loading size="large" text="加载中..." />
7
- </div>
8
-
9
- <!-- 主要内容区域 -->
10
- <div v-else class="selector-content">
11
- <!-- 会议室列表 -->
12
- <div class="rooms-list">
13
- <div v-for="room in roomList" :key="room.id" class="room-card"
14
- :class="{ 'selected': selectedRoom?.id === room.id }" @click="handleRoomSelect(room)">
15
- <!-- 会议室信息 -->
16
- <div class="room-info">
17
- <slot name="room-info" :room="room">
18
- <div class="room-header">
19
- <h4 class="room-name">🏢 {{ room.name }}</h4>
20
- <div class="room-controls">
21
- <div class="room-status" :class="getRoomStatusClass(room)">
22
- {{ getRoomStatusText(room) }}
23
- </div>
24
- <div v-if="selectedRoom?.id === room.id" class="time-filter-btn">
25
- <t-button size="small" variant="outline" theme="primary" @click.stop="toggleTimeFilter">
26
- {{ showAllTimeSlots ? '常用时间' : '全部时间' }}
27
- </t-button>
28
- </div>
29
- </div>
30
- </div>
31
- <div class="room-details">
32
- <div class="detail-item">
33
- <span class="icon">👥</span>
34
- <span>{{ room.capacity }}人</span>
35
- </div>
36
- <div class="detail-item">
37
- <span class="icon">📍</span>
38
- <span>{{ room.location }}</span>
39
- </div>
40
- </div>
41
- <div v-if="room.equipment?.length" class="equipment">
42
- <t-tag v-for="item in room.equipment" :key="item" size="small" variant="light" class="equipment-tag">
43
- {{ item }}
44
- </t-tag>
45
- </div>
46
- </slot>
47
- </div>
48
-
49
- <!-- 时间段选择区域 -->
50
- <div v-if="selectedRoom?.id === room.id" class="time-selection">
51
- <div class="time-header">
52
- <h5>⏰ 选择时间段</h5>
53
- <div class="time-info">
54
- <span v-if="selectedTimeSlots.length > 0" class="selected-info">
55
- 已选 {{ selectedTimeSlots.length * 0.5 }}小时
56
- </span>
57
- </div>
58
- </div>
59
-
60
- <!-- 时间段网格 -->
61
- <div class="time-slots-grid">
62
- <div v-for="slot in filteredTimeSlotList" :key="slot.value" class="time-slot" :class="{
63
- 'booked': isSlotBooked(room.id, slot.value),
64
- 'selected': isSlotSelected(room.id, slot.value),
65
- 'disabled': props.disabled || isSlotDisabled(room.id, slot.value)
66
- }" @click="handleTimeSlotClick(room, slot)">
67
- <div class="slot-content">
68
- <div class="slot-time">{{ slot.label }}</div>
69
- <div class="slot-status">
70
- <span v-if="isSlotBooked(room.id, slot.value)" class="status-icon booked">
71
- <span style="display:block;margin-bottom: 4px;">已预约</span>
72
- <span style="display: block;">{{ bookedInfo(room.id, slot.value, 'name') }} </span>
73
- <span style="display: block;">{{ bookedInfo(room.id, slot.value, 'no') }} </span>
74
- </span>
75
- <span v-else-if="isSlotSelected(room.id, slot.value)" class="status-icon selected">✅</span>
76
- <span v-else class="status-icon available">空闲</span>
77
- </div>
78
- </div>
79
- </div>
80
- </div>
81
- </div>
82
- </div>
83
- </div>
84
- </div>
85
-
86
- <!-- 预约确认浮动面板 -->
87
- <div v-if="selectedTimeSlots.length > 0" class="booking-panel">
88
- <slot name="booking-form" :selection="currentSelection">
89
- <div class="booking-form">
90
- <div class="booking-header">
91
- <h4>📋 预约确认</h4>
92
- <t-button variant="text" size="small" @click="handleCancelSelection">
93
- 取消
94
- </t-button>
95
- </div>
96
- <div class="booking-info">
97
- <div class="info-row">
98
- <span class="label">会议室:</span>
99
- <span class="value">{{ selectedRoom?.name }}</span>
100
- </div>
101
- <div class="info-row">
102
- <span class="label">日期:</span>
103
- <span class="value">{{ formatDate(selectedDate) }}</span>
104
- </div>
105
- <div class="info-row">
106
- <span class="label">时间:</span>
107
- <span class="value">{{ formatSelectedTime() }}</span>
108
- </div>
109
- <div class="info-row">
110
- <span class="label">时长:</span>
111
- <span class="value">{{ selectedTimeSlots.length * 0.5 }}小时</span>
112
- </div>
113
- </div>
114
- <div class="booking-actions">
115
- <t-button theme="primary" size="large" block :loading="bookingLoading" @click="handleConfirmBooking">
116
- {{ confirmButtonText }}
117
- </t-button>
118
- </div>
119
- </div>
120
- </slot>
121
- </div>
122
- </div>
123
- <!-- 预约成功提示组件 -->
124
- <div v-if="showSuccessMessage" class="success-overlay" @click="hideSuccessMessage">
125
- <div class="success-container" @click.stop>
126
- <div class="success-icon">✅</div>
127
- <div class="success-title">{{ successTitle }}</div>
128
- <div class="success-content">
129
- <div class="success-item">
130
- <span class="success-label">会议室:</span>
131
- <span class="success-value">{{ successData.roomName }}</span>
132
- </div>
133
- <div class="success-item">
134
- <span class="success-label">日期:</span>
135
- <span class="success-value">{{ successData.date }}</span>
136
- </div>
137
- <div class="success-item">
138
- <span class="success-label">时间:</span>
139
- <span class="success-value">{{ successData.time }}</span>
140
- </div>
141
- <div class="success-item">
142
- <span class="success-label">时长:</span>
143
- <span class="success-value">{{ successData.duration }}小时</span>
144
- </div>
145
- <div v-if="successData.isPreemptive" class="success-preempt-info">
146
- <div class="preempt-info-title">已取消的会议:</div>
147
- <div class="preempt-info-content">{{ successData.cancelledMeetings }}</div>
148
- </div>
149
- </div>
150
- <div class="success-actions">
151
- <t-button theme="primary" @click="hideSuccessMessage">确定</t-button>
152
- </div>
153
- </div>
154
- </div>
155
- </div>
156
- </template>
157
-
158
- <script setup>
159
- import { ref, computed, watch, defineProps, defineEmits } from 'vue'
160
- import { Loading as TLoading, Tag as TTag, Button as TButton, MessagePlugin } from 'tdesign-vue-next'
161
- import { dataService } from '../index.js'
162
-
163
- // 组件属性接口
164
- const props = defineProps({
165
- rooms: {
166
- type: Array,
167
- default: () => []
168
- },
169
- selectedDate: {
170
- type: String,
171
- default: ""
172
- },
173
- timeSlots: {
174
- type: Array,
175
- default: () => []
176
- },
177
- bookedSlots: {
178
- type: Object,
179
- default: () => ({})
180
- },
181
- loading: {
182
- type: Boolean,
183
- default: false
184
- },
185
- disabled: {
186
- type: Boolean,
187
- default: false
188
- },
189
- minDuration: {
190
- type: Number,
191
- default: 1
192
- },
193
- maxDuration: {
194
- type: Number,
195
- default: 8
196
- },
197
- // 新增API配置属性
198
- roomQueryApiConfig: {
199
- type: Object,
200
- default: () => ({})
201
- },
202
- bookingApiConfig: {
203
- type: Object,
204
- default: () => ({})
205
- },
206
- bookingFormData: {
207
- type: Object,
208
- default: () => ({})
209
- },
210
- confirmButtonText: {
211
- type: String,
212
- default: '确认预约'
213
- },
214
- successTitle: {
215
- type: String,
216
- default: '预约成功'
217
- },
218
- preemptSuccessTitle: {
219
- type: String,
220
- default: '抢占预约成功'
221
- }
222
- })
223
-
224
- // 定义事件
225
- const emit = defineEmits([
226
- 'room-select',
227
- 'time-select',
228
- 'booking-confirm',
229
- 'date-change',
230
- 'booking-success',
231
- 'booking-error',
232
- 'room-query-success',
233
- 'room-query-error'
234
- ])
235
-
236
- // 响应式数据
237
- const currentDate = computed(() => {
238
- return formatDate(props.selectedDate)
239
- })
240
- const selectedRoom = ref(null)
241
- const selectedTimeSlots = ref([])
242
- const bookingLoading = ref(false)
243
- const roomQueryLoading = ref(false)
244
- const showSuccessMessage = ref(false)
245
- const successData = ref({})
246
- const apiRoomList = ref([]) // 存储从API获取的会议室数据
247
- const showAllTimeSlots = ref(false)
248
-
249
- // 计算属性
250
- const roomList = computed(() => {
251
- if (apiRoomList.value.length > 0) {
252
- return apiRoomList.value.map(room => ({
253
- id: room.conferenceId,
254
- name: room.conferenceName,
255
- capacity: room.capacity,
256
- location: room.location,
257
- equipment: [],
258
- timeSlots: room.timeSlots
259
- }))
260
- }
261
- return props.rooms
262
- })
263
-
264
- const timeSlotList = computed(() => {
265
- if (props.timeSlots.length > 0) {
266
- return props.timeSlots
267
- }
268
-
269
- if (apiRoomList.value.length > 0 && apiRoomList.value[0]?.timeSlots) {
270
- return apiRoomList.value[0].timeSlots.map(slot => ({
271
- value: slot.time,
272
- label: slot.time,
273
- hour: parseInt(slot.time.split(':')[0]),
274
- minute: parseInt(slot.time.split(':')[1]),
275
- userInfo: slot?.userInfo ?? null
276
- }))
277
- }
278
-
279
- const slots = []
280
- for (let hour = 0; hour < 24; hour++) {
281
- for (let minute = 0; minute < 60; minute += 30) {
282
- const timeValue = `${hour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}`
283
- slots.push({
284
- value: timeValue,
285
- label: timeValue,
286
- hour,
287
- minute
288
- })
289
- }
290
- }
291
- return slots
292
- })
293
-
294
- // 工具方法
295
- const timeToMinutes = (timeStr) => {
296
- const [hour, minute] = timeStr.split(':').map(Number)
297
- return hour * 60 + minute
298
- }
299
-
300
- const compareTimes = (timeA, timeB) => {
301
- const minutesA = timeToMinutes(timeA)
302
- const minutesB = timeToMinutes(timeB)
303
- if (minutesA === minutesB) return 0
304
- return minutesA < minutesB ? -1 : 1
305
- }
306
-
307
- const _isTimeOverlap = (start1, end1, start2, end2) => {
308
- const s1 = timeToMinutes(start1)
309
- const e1 = timeToMinutes(end1)
310
- const s2 = timeToMinutes(start2)
311
- const e2 = timeToMinutes(end2)
312
-
313
- return s1 < e2 && s2 < e1
314
- }
315
-
316
- const getEndTime = (startTime) => {
317
- const [hour, minute] = startTime.split(':').map(Number)
318
- const endMinute = minute + 30
319
- const endHour = endMinute >= 60 ? hour + 1 : hour
320
- const finalMinute = endMinute >= 60 ? endMinute - 60 : endMinute
321
-
322
- return `${endHour.toString().padStart(2, '0')}:${finalMinute.toString().padStart(2, '0')}`
323
- }
324
-
325
- const minutesToTime = (minutes) => {
326
- const hour = Math.floor(minutes / 60)
327
- const minute = minutes % 60
328
- return `${hour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}`
329
- }
330
-
331
- const getCurrentTime = () => {
332
- const now = new Date()
333
- const hour = now.getHours().toString().padStart(2, '0')
334
- const minute = now.getMinutes().toString().padStart(2, '0')
335
- return `${hour}:${minute}`
336
- }
337
-
338
- // 状态检查方法
339
- const isSlotBooked = (roomId, timeSlot) => {
340
- if (apiRoomList.value.length > 0) {
341
- const room = apiRoomList.value.find(r => r.conferenceId == roomId)
342
- if (room && room.timeSlots) {
343
- const slot = room.timeSlots.find(s => s.time === timeSlot)
344
- return slot ? slot.occupied : false
345
- }
346
- }
347
- return props.bookedSlots[roomId]?.includes(timeSlot) || false
348
- }
349
-
350
- const bookedInfo = (roomId, timeSlot, type = 'name') => {
351
- if (apiRoomList.value.length > 0) {
352
- const room = apiRoomList.value.find(r => r.conferenceId == roomId)
353
- if (room && room.timeSlots) {
354
- const slot = room.timeSlots.find(s => s.time === timeSlot)
355
- if (type === 'name') {
356
- return slot?.userInfo?.name ? slot.userInfo.name : ''
357
- } else {
358
- return slot?.userInfo?.no ? slot.userInfo.no : ''
359
- }
360
- }
361
- }
362
- return ''
363
- }
364
-
365
- const isSlotSelected = (roomId, timeSlot) => {
366
- return selectedRoom.value?.id === roomId && selectedTimeSlots.value.includes(timeSlot)
367
- }
368
-
369
- const isSlotDisabled = (_roomId, _timeSlot) => {
370
- const today = formatDate(new Date().getTime());
371
- if (currentDate.value === today && compareTimes(getCurrentTime(), _timeSlot) === 1) {
372
- return true
373
- }
374
- return false
375
- }
376
-
377
- // 智能选择时间段 - 自动填充中间的时间段
378
- const getSmartSelectedSlots = (slots, roomId) => {
379
- if (slots.length <= 1) return slots
380
-
381
- const slotsInMinutes = slots.map(timeToMinutes).sort((a, b) => a - b)
382
- const minTime = slotsInMinutes[0]
383
- const maxTime = slotsInMinutes[slotsInMinutes.length - 1]
384
-
385
- const continuousSlots = []
386
- for (let time = minTime; time <= maxTime; time += 30) {
387
- const timeStr = minutesToTime(time)
388
-
389
- if (!isSlotBooked(roomId, timeStr)) {
390
- continuousSlots.push(timeStr)
391
- } else {
392
- break
393
- }
394
- }
395
-
396
- return continuousSlots
397
- }
398
-
399
- // 限制选择的时间段数量,保留以最新选择为中心的连续时间段
400
- const getLimitedSlots = (slots, latestSlot, maxDuration) => {
401
- const latestMinutes = timeToMinutes(latestSlot)
402
- const slotsInMinutes = slots.map(timeToMinutes).sort((a, b) => a - b)
403
-
404
- const latestIndex = slotsInMinutes.indexOf(latestMinutes)
405
-
406
- const halfDuration = Math.floor(maxDuration / 2)
407
- const startIndex = Math.max(0, latestIndex - halfDuration)
408
- const endIndex = Math.min(slotsInMinutes.length, startIndex + maxDuration)
409
-
410
- const adjustedStartIndex = Math.max(0, endIndex - maxDuration)
411
-
412
- return slotsInMinutes
413
- .slice(adjustedStartIndex, endIndex)
414
- .map(minutesToTime)
415
- }
416
-
417
- // 清理方法
418
- const clearTimeSelection = () => {
419
- selectedTimeSlots.value = []
420
- }
421
-
422
- const clearSelection = () => {
423
- selectedRoom.value = null
424
- clearTimeSelection()
425
- }
426
-
427
- // 显示预约成功信息
428
- const showBookingSuccess = (bookingData) => {
429
- successData.value = {
430
- roomName: bookingData.room.name,
431
- date: bookingData.date,
432
- time: `${bookingData.startTime} - ${bookingData.endTime}`,
433
- duration: bookingData.duration,
434
- isPreemptive: bookingData.isPreemptive,
435
- cancelledMeetings: bookingData.isPreemptive
436
- ? bookingData.conflictMeetings?.map(m => m.title).join('、') || ''
437
- : ''
438
- }
439
- showSuccessMessage.value = true
440
- }
441
-
442
- // 隐藏成功信息
443
- const hideSuccessMessage = () => {
444
- showSuccessMessage.value = false
445
- successData.value = {}
446
- emit('booking-success', successData.value)
447
- }
448
-
449
- // 状态获取方法
450
- const getRoomStatusClass = (room) => {
451
- const commonTimeSlots = timeSlotList.value.filter(slot =>
452
- slot.hour >= 7 && slot.hour < 22
453
- )
454
-
455
- const availableSlots = commonTimeSlots.filter(slot =>
456
- !isSlotBooked(room.id, slot.value)
457
- ).length
458
-
459
- if (availableSlots === 0) return 'fully-booked'
460
- if (availableSlots < commonTimeSlots.length / 2) return 'partially-available'
461
- return 'available'
462
- }
463
-
464
- const getRoomStatusText = (room) => {
465
- const commonTimeSlots = timeSlotList.value.filter(slot =>
466
- slot.hour >= 7 && slot.hour < 22
467
- )
468
-
469
- const availableSlots = commonTimeSlots.filter(slot =>
470
- !isSlotBooked(room.id, slot.value)
471
- ).length
472
-
473
- if (availableSlots === 0) return '已满'
474
- if (availableSlots < commonTimeSlots.length / 2) return '紧张'
475
- return '充足'
476
- }
477
-
478
- const formatSelectedTime = () => {
479
- if (selectedTimeSlots.value.length === 0) return ''
480
-
481
- const sortedSlots = [...selectedTimeSlots.value].sort()
482
- const startTime = sortedSlots[0]
483
- const endTime = getEndTime(sortedSlots[sortedSlots.length - 1])
484
-
485
- return `${startTime} - ${endTime}`
486
- }
487
-
488
- const currentSelection = computed(() => {
489
- if (!selectedRoom.value || selectedTimeSlots.value.length === 0) {
490
- return null
491
- }
492
-
493
- const sortedSlots = [...selectedTimeSlots.value].sort()
494
- return {
495
- room: selectedRoom.value,
496
- date: currentDate.value,
497
- startTime: sortedSlots[0],
498
- endTime: getEndTime(sortedSlots[sortedSlots.length - 1]),
499
- duration: selectedTimeSlots.value.length * 0.5,
500
- timeSlots: sortedSlots
501
- }
502
- })
503
-
504
- const formatDate = (timestamp) => {
505
- const date = new Date(timestamp)
506
- const year = date.getFullYear()
507
- const month = String(date.getMonth() + 1).padStart(2, '0')
508
- const day = String(date.getDate()).padStart(2, '0')
509
- return `${year}-${month}-${day}`
510
- }
511
-
512
- // API调用方法
513
- const queryRooms = async (date) => {
514
- try {
515
- roomQueryLoading.value = true
516
-
517
- if (!date) {
518
- date = props.selectedDate
519
- }
520
- const queryParams = {
521
- date: props.selectedDate,
522
- requestTime: new Date().getTime()
523
- }
524
-
525
- let response
526
- if (props.roomQueryApiConfig && Object.keys(props.roomQueryApiConfig).length > 0) {
527
- response = await dataService.fetch(queryParams, props.roomQueryApiConfig)
528
- } else {
529
- if (typeof props.selectedDate === 'number') {
530
- queryParams.date = formatDate(props.selectedDate)
531
- }
532
-
533
- response = await dataService.fetch(queryParams, {}, "/appdata/execute/plugin?key=get-meetingRoomOccupy-info&date=" + queryParams.date)
534
- }
535
-
536
- const roomData = response.meetingRooms
537
- apiRoomList.value = roomData
538
-
539
- emit('room-query-success', {
540
- success: true,
541
- message: '查询成功',
542
- data: roomData
543
- })
544
- } catch (error) {
545
- emit('room-query-error', error)
546
- MessagePlugin.error({
547
- duration: 3000,
548
- content: error.message || '查询会议室失败'
549
- })
550
- } finally {
551
- roomQueryLoading.value = false
552
- }
553
- }
554
-
555
- const handleBeforeSubmit = (bookingData) => {
556
- try {
557
- emit('before-submit', bookingData)
558
- } catch (error) {
559
- throw new Error(error.message)
560
- }
561
- }
562
- const submitBooking = async (bookingData) => {
563
- if (!props.bookingApiConfig || Object.keys(props.bookingApiConfig).length === 0) {
564
- emit('booking-confirm', bookingData)
565
- return
566
- }
567
-
568
- try {
569
- bookingLoading.value = true
570
-
571
- let date = formatDate(props.selectedDate)
572
- const submitData = {
573
- ...props.bookingFormData,
574
- conference_id: bookingData.room.id,
575
- roomName: bookingData.room.name,
576
- date: date,
577
- start_time: new Date(date + " " + bookingData.startTime + ":00").getTime(),
578
- end_time: new Date(date + " " + bookingData.endTime + ":00") - 1,
579
- duration: bookingData.duration,
580
- timeSlots: bookingData.timeSlots,
581
- requestTime: new Date().getTime(),
582
- }
583
-
584
- const response = await dataService.fetch({ saveData: submitData }, props.bookingApiConfig)
585
-
586
- showBookingSuccess(bookingData)
587
-
588
- } catch (error) {
589
- emit('booking-error', error)
590
- MessagePlugin.error({
591
- duration: 3000,
592
- content: error.message || '预约失败'
593
- })
594
- } finally {
595
- bookingLoading.value = false
596
- }
597
- }
598
-
599
- // 事件处理方法
600
- const handleRoomSelect = (room) => {
601
- if (selectedRoom.value?.id === room.id) {
602
- return
603
- } else {
604
- selectedRoom.value = room
605
- clearTimeSelection()
606
- emit('room-select', room)
607
- }
608
- }
609
-
610
- const handleTimeSlotClick = (room, slot) => {
611
- if (props.disabled || isSlotDisabled(room.id, slot.value) || isSlotBooked(room.id, slot.value)) {
612
- return
613
- }
614
-
615
- if (!selectedRoom.value || selectedRoom.value.id !== room.id) {
616
- selectedRoom.value = room
617
- emit('room-select', room)
618
- }
619
-
620
- const slotIndex = selectedTimeSlots.value.indexOf(slot.value)
621
-
622
- if (slotIndex > -1) {
623
- selectedTimeSlots.value.splice(slotIndex, 1)
624
- } else {
625
- if (selectedTimeSlots.value.length === 0) {
626
- selectedTimeSlots.value.push(slot.value)
627
- } else {
628
- const newSlots = [...selectedTimeSlots.value, slot.value]
629
- selectedTimeSlots.value = getSmartSelectedSlots(newSlots, room.id)
630
- }
631
-
632
- if (selectedTimeSlots.value.length > props.maxDuration) {
633
- selectedTimeSlots.value = getLimitedSlots(selectedTimeSlots.value, slot.value, props.maxDuration)
634
- }
635
- }
636
-
637
- selectedTimeSlots.value = [...selectedTimeSlots.value]
638
-
639
- emit('time-select', currentSelection.value)
640
- }
641
-
642
- const handleConfirmBooking = async () => {
643
- if (!currentSelection.value) return
644
-
645
- const bookingData = {
646
- room: selectedRoom.value,
647
- date: currentDate.value,
648
- startTime: currentSelection.value.startTime,
649
- endTime: currentSelection.value.endTime,
650
- duration: currentSelection.value.duration,
651
- timeSlots: currentSelection.value.timeSlots,
652
- isPreemptive: false,
653
- conflictMeetings: []
654
- }
655
-
656
- handleBeforeSubmit(bookingData)
657
- }
658
-
659
- const handleCancelSelection = () => {
660
- clearSelection()
661
- }
662
-
663
- // 时间筛选功能
664
- const toggleTimeFilter = () => {
665
- showAllTimeSlots.value = !showAllTimeSlots.value
666
- }
667
-
668
- // 监听属性变化
669
- watch(() => props.selectedDate, (newDate) => {
670
- })
671
-
672
- // 新增计算属性
673
- const filteredTimeSlotList = computed(() => {
674
- if (showAllTimeSlots.value) {
675
- return timeSlotList.value
676
- } else {
677
- return timeSlotList.value.filter(slot =>
678
- slot.hour >= 7 && slot.hour < 22
679
- )
680
- }
681
- })
682
-
683
- // 辅助方法:将时间戳转换为时间段数组
684
- const getTimeSlotsFromRange = (startTime, endTime) => {
685
- const slots = []
686
- let current = new Date(startTime)
687
- const end = new Date(endTime)
688
- while (current < end) {
689
- const hour = current.getHours().toString().padStart(2, '0')
690
- const minutes = current.getMinutes().toString().padStart(2, '0')
691
- slots.push(`${hour}:${minutes}`)
692
- current.setMinutes(current.getMinutes() + 30)
693
- }
694
- return slots
695
- }
696
-
697
- // 初始化选中的会议室和时间段
698
- const initializeSelection = async (bookingData) => {
699
- const roomId = bookingData.conference_id
700
- const startTime = bookingData.start_time
701
- const endTime = bookingData.end_time
702
-
703
- if (!startTime || !endTime) return
704
-
705
- const rawSlots = getTimeSlotsFromRange(startTime, endTime)
706
-
707
- if (apiRoomList.value.length === 0) {
708
- await queryRooms()
709
- }
710
-
711
- const room = roomList.value.find(r => r.id === roomId)
712
- if (!room) return
713
-
714
- const validSlots = rawSlots.filter(slot => !isSlotBooked(roomId, slot))
715
-
716
- selectedRoom.value = room
717
-
718
- selectedTimeSlots.value = validSlots
719
- }
720
-
721
- // 监听bookingFormData变化,进行初始化选中
722
- watch(() => props.bookingFormData, async (newVal) => {
723
- if (newVal && newVal.conference_id && newVal.start_time && newVal.end_time) {
724
- await initializeSelection(newVal)
725
- }
726
- }, { deep: true, immediate: true })
727
-
728
- // 暴露组件实例方法
729
- defineExpose({
730
- clearSelection,
731
- clearTimeSelection,
732
- getCurrentSelection: () => currentSelection.value,
733
- queryRooms,
734
- submitBooking,
735
- showBookingSuccess,
736
- hideSuccessMessage,
737
- toggleTimeFilter,
738
- getApiRoomList: () => apiRoomList.value,
739
- refreshRooms: queryRooms,
740
- getShowAllTimeSlots: () => showAllTimeSlots.value,
741
- setShowAllTimeSlots: (value) => { showAllTimeSlots.value = value },
742
- compareTimes,
743
- getCurrentTime
744
- })
745
- </script>
746
-
747
- <style scoped>
748
- .ebiz-meeting-room-selector {
749
- padding-bottom: 280px;
750
- position: relative;
751
- transform: translateX(0px);
752
- }
753
-
754
- .selector-content {
755
- padding: 16px;
756
- }
757
-
758
- .rooms-list {
759
- display: flex;
760
- flex-direction: column;
761
- gap: 16px;
762
- }
763
-
764
- .room-card {
765
- background: #fff;
766
- border-radius: 12px;
767
- overflow: hidden;
768
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
769
- transition: all 0.3s ease;
770
- }
771
-
772
- .room-card.selected {
773
- border: 2px solid #1890ff;
774
- box-shadow: 0 4px 12px rgba(24, 144, 255, 0.2);
775
- }
776
-
777
- .room-info {
778
- padding: 16px;
779
- cursor: pointer;
780
- }
781
-
782
- .room-header {
783
- display: flex;
784
- justify-content: space-between;
785
- align-items: center;
786
- margin-bottom: 12px;
787
- }
788
-
789
- .room-name {
790
- margin: 0;
791
- font-size: 16px;
792
- font-weight: 600;
793
- color: #333;
794
- }
795
-
796
- .room-controls {
797
- display: flex;
798
- align-items: center;
799
- gap: 8px;
800
- }
801
-
802
- .time-filter-btn {
803
- flex-shrink: 0;
804
- }
805
-
806
- .time-filter-btn .t-button {
807
- height: 24px;
808
- padding: 0 8px;
809
- font-size: 11px;
810
- border-radius: 12px;
811
- }
812
-
813
- .room-status {
814
- padding: 4px 8px;
815
- border-radius: 12px;
816
- font-size: 12px;
817
- font-weight: 500;
818
- }
819
-
820
- .room-status.available {
821
- background: #f6ffed;
822
- color: #52c41a;
823
- }
824
-
825
- .room-status.partially-available {
826
- background: #fff7e6;
827
- color: #fa8c16;
828
- }
829
-
830
- .room-status.fully-booked {
831
- background: #fff2f0;
832
- color: #ff4d4f;
833
- }
834
-
835
- .room-details {
836
- display: flex;
837
- gap: 16px;
838
- margin-bottom: 12px;
839
- }
840
-
841
- .detail-item {
842
- display: flex;
843
- align-items: center;
844
- gap: 4px;
845
- font-size: 14px;
846
- color: #666;
847
- }
848
-
849
- .icon {
850
- font-size: 16px;
851
- }
852
-
853
- .equipment {
854
- display: flex;
855
- flex-wrap: wrap;
856
- gap: 6px;
857
- }
858
-
859
- .equipment-tag {
860
- font-size: 12px;
861
- }
862
-
863
- .time-selection {
864
- border-top: 1px solid #f0f0f0;
865
- padding: 16px;
866
- background: #fafafa;
867
- }
868
-
869
- .time-header {
870
- display: flex;
871
- justify-content: space-between;
872
- align-items: center;
873
- margin-bottom: 12px;
874
- }
875
-
876
- .time-header h5 {
877
- margin: 0;
878
- font-size: 14px;
879
- font-weight: 600;
880
- color: #333;
881
- }
882
-
883
- .selected-info {
884
- font-size: 12px;
885
- color: #1890ff;
886
- font-weight: 500;
887
- }
888
-
889
- .time-slots-grid {
890
- display: grid;
891
- grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
892
- gap: 12px;
893
- }
894
-
895
- .time-slot {
896
- background: #f6ffed;
897
- border: 1px solid #52c41a;
898
- border-radius: 8px;
899
- text-align: center;
900
- cursor: pointer;
901
- transition: all 0.2s ease;
902
- min-height: 60px;
903
- display: flex;
904
- flex-direction: column;
905
- justify-content: center;
906
- }
907
-
908
- .time-slot:active {
909
- transform: scale(0.95);
910
- }
911
-
912
- .time-slot.booked {
913
- background: #f5f5f5;
914
- border-color: #d9d9d9;
915
- cursor: not-allowed;
916
- }
917
-
918
- .time-slot.selected {
919
- background: #e6f7ff;
920
- border-color: #1890ff;
921
- color: #1890ff;
922
- }
923
-
924
- .time-slot.disabled {
925
- background: #f5f5f5;
926
- border-color: #d9d9d9;
927
- cursor: not-allowed;
928
- }
929
-
930
- .slot-content {
931
- display: flex;
932
- flex-direction: column;
933
- align-items: center;
934
- gap: 4px;
935
- }
936
-
937
- .slot-time {
938
- font-size: 14px;
939
- font-weight: 500;
940
- }
941
-
942
- .status-icon {
943
- font-size: 14px;
944
- color: #666;
945
- word-break: break-all;
946
- }
947
-
948
- .booking-panel {
949
- position: fixed;
950
- bottom: 0;
951
- left: 8px;
952
- right: 8px;
953
- background: #fff;
954
- border-top: 1px solid #eee;
955
- box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
956
- z-index: 1000;
957
- animation: slideUp 0.3s ease;
958
- }
959
-
960
- @keyframes slideUp {
961
- from {
962
- transform: translateY(100%);
963
- }
964
-
965
- to {
966
- transform: translateY(0);
967
- }
968
- }
969
-
970
- .booking-form {
971
- padding: 24px;
972
- }
973
-
974
- .booking-header {
975
- display: flex;
976
- justify-content: space-between;
977
- align-items: center;
978
- margin-bottom: 16px;
979
- }
980
-
981
- .booking-header h4 {
982
- margin: 0;
983
- font-size: 18px;
984
- font-weight: 600;
985
- color: #333;
986
- }
987
-
988
- .booking-info {
989
- margin-bottom: 24px;
990
- }
991
-
992
- .info-row {
993
- display: flex;
994
- justify-content: space-between;
995
- align-items: center;
996
- padding: 8px 0;
997
- font-size: 16px;
998
- }
999
-
1000
- .label {
1001
- color: #666;
1002
- font-weight: 500;
1003
- }
1004
-
1005
- .value {
1006
- color: #333;
1007
- font-weight: 600;
1008
- }
1009
-
1010
- .booking-actions {
1011
- margin-top: 16px;
1012
- }
1013
-
1014
- /* 预约成功提示样式 */
1015
- .success-overlay {
1016
- position: fixed;
1017
- top: 0;
1018
- left: 0;
1019
- right: 0;
1020
- bottom: 0;
1021
- background: rgba(0, 0, 0, 0.5);
1022
- display: flex;
1023
- align-items: center;
1024
- justify-content: center;
1025
- z-index: 1000;
1026
- animation: fadeIn 0.3s ease;
1027
- }
1028
-
1029
- .success-container {
1030
- background: #fff;
1031
- border-radius: 16px;
1032
- padding: 32px;
1033
- margin: 20px;
1034
- max-width: 500px;
1035
- width: 100%;
1036
- text-align: center;
1037
- animation: slideUpSuccess 0.3s ease;
1038
- }
1039
-
1040
- .success-icon {
1041
- font-size: 40px;
1042
- margin-bottom: 24px;
1043
- }
1044
-
1045
- .success-title {
1046
- font-size: 24px;
1047
- font-weight: 600;
1048
- color: #333;
1049
- margin-bottom: 24px;
1050
- }
1051
-
1052
- .success-content {
1053
- text-align: left;
1054
- margin-bottom: 32px;
1055
- }
1056
-
1057
- .success-item {
1058
- display: flex;
1059
- justify-content: space-between;
1060
- align-items: center;
1061
- padding: 12px 0;
1062
- border-bottom: 1px solid #f0f0f0;
1063
- }
1064
-
1065
- .success-item:last-child {
1066
- border-bottom: none;
1067
- }
1068
-
1069
- .success-label {
1070
- font-size: 16px;
1071
- color: #666;
1072
- }
1073
-
1074
- .success-value {
1075
- font-size: 16px;
1076
- font-weight: 500;
1077
- color: #333;
1078
- }
1079
-
1080
- .success-preempt-info {
1081
- margin-top: 16px;
1082
- padding: 16px;
1083
- background: #fff7e6;
1084
- border-radius: 8px;
1085
- border-left: 4px solid #fa8c16;
1086
- }
1087
-
1088
- .preempt-info-title {
1089
- font-size: 14px;
1090
- color: #d46b08;
1091
- font-weight: 600;
1092
- margin-bottom: 8px;
1093
- }
1094
-
1095
- .preempt-info-content {
1096
- font-size: 14px;
1097
- color: #d46b08;
1098
- line-height: 1.4;
1099
- }
1100
-
1101
- .success-actions {
1102
- text-align: center;
1103
- }
1104
-
1105
- @keyframes fadeIn {
1106
- from {
1107
- opacity: 0;
1108
- }
1109
-
1110
- to {
1111
- opacity: 1;
1112
- }
1113
- }
1114
-
1115
- @keyframes slideUpSuccess {
1116
- from {
1117
- transform: translateY(30px);
1118
- opacity: 0;
1119
- }
1120
-
1121
- to {
1122
- transform: translateY(0);
1123
- opacity: 1;
1124
- }
1125
- }
1126
-
1127
- /* 响应式设计 */
1128
- @media (max-width: 768px) {
1129
- .time-slots-grid {
1130
- grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
1131
- gap: 8px;
1132
- }
1133
-
1134
- .time-slot {
1135
- min-height: 60px;
1136
- }
1137
-
1138
- .slot-time {
1139
- font-size: 12px;
1140
- }
1141
-
1142
- .status-icon {
1143
- font-size: 12px;
1144
- }
1145
-
1146
- .success-container {
1147
- margin: 10px;
1148
- }
1149
- }
1
+ <template>
2
+ <div>
3
+ <div class="ebiz-meeting-room-selector">
4
+ <!-- 头部区域 -->
5
+ <div v-if="loading" class="loading-container">
6
+ <t-loading size="large" text="加载中..." />
7
+ </div>
8
+
9
+ <!-- 主要内容区域 -->
10
+ <div v-else class="selector-content">
11
+ <!-- 会议室列表 -->
12
+ <div class="rooms-list">
13
+ <div v-for="room in roomList" :key="room.id" class="room-card"
14
+ :class="{ 'selected': selectedRoom?.id === room.id }" @click="handleRoomSelect(room)">
15
+ <!-- 会议室信息 -->
16
+ <div class="room-info">
17
+ <slot name="room-info" :room="room">
18
+ <div class="room-header">
19
+ <h4 class="room-name">🏢 {{ room.name }}</h4>
20
+ <div class="room-controls">
21
+ <div class="room-status" :class="getRoomStatusClass(room)">
22
+ {{ getRoomStatusText(room) }}
23
+ </div>
24
+ <div v-if="selectedRoom?.id === room.id" class="time-filter-btn">
25
+ <t-button size="small" variant="outline" theme="primary" @click.stop="toggleTimeFilter">
26
+ {{ showAllTimeSlots ? '常用时间' : '全部时间' }}
27
+ </t-button>
28
+ </div>
29
+ </div>
30
+ </div>
31
+ <div class="room-details">
32
+ <div class="detail-item">
33
+ <span class="icon">👥</span>
34
+ <span>{{ room.capacity }}人</span>
35
+ </div>
36
+ <div class="detail-item">
37
+ <span class="icon">📍</span>
38
+ <span>{{ room.location }}</span>
39
+ </div>
40
+ </div>
41
+ <div v-if="room.equipment?.length" class="equipment">
42
+ <t-tag v-for="item in room.equipment" :key="item" size="small" variant="light" class="equipment-tag">
43
+ {{ item }}
44
+ </t-tag>
45
+ </div>
46
+ </slot>
47
+ </div>
48
+
49
+ <!-- 时间段选择区域 -->
50
+ <div v-if="selectedRoom?.id === room.id" class="time-selection">
51
+ <div class="time-header">
52
+ <h5>⏰ 选择时间段</h5>
53
+ <div class="time-info">
54
+ <span v-if="selectedTimeSlots.length > 0" class="selected-info">
55
+ 已选 {{ selectedTimeSlots.length * 0.5 }}小时
56
+ </span>
57
+ </div>
58
+ </div>
59
+
60
+ <!-- 时间段网格 -->
61
+ <div class="time-slots-grid">
62
+ <div v-for="slot in filteredTimeSlotList" :key="slot.value" class="time-slot" :class="{
63
+ 'booked': isSlotBooked(room.id, slot.value),
64
+ 'selected': isSlotSelected(room.id, slot.value),
65
+ 'disabled': props.disabled || isSlotDisabled(room.id, slot.value)
66
+ }" @click="handleTimeSlotClick(room, slot)">
67
+ <div class="slot-content">
68
+ <div class="slot-time">{{ slot.label }}</div>
69
+ <div class="slot-status">
70
+ <span v-if="isSlotBooked(room.id, slot.value)" class="status-icon booked">
71
+ <span style="display:block;margin-bottom: 4px;">已预约</span>
72
+ <span style="display: block;">{{ bookedInfo(room.id, slot.value, 'name') }} </span>
73
+ <span style="display: block;">{{ bookedInfo(room.id, slot.value, 'no') }} </span>
74
+ </span>
75
+ <span v-else-if="isSlotSelected(room.id, slot.value)" class="status-icon selected">✅</span>
76
+ <span v-else class="status-icon available">空闲</span>
77
+ </div>
78
+ </div>
79
+ </div>
80
+ </div>
81
+ </div>
82
+ </div>
83
+ </div>
84
+ </div>
85
+
86
+ <!-- 预约确认浮动面板 -->
87
+ <div v-if="selectedTimeSlots.length > 0" class="booking-panel">
88
+ <slot name="booking-form" :selection="currentSelection">
89
+ <div class="booking-form">
90
+ <div class="booking-header">
91
+ <h4>📋 预约确认</h4>
92
+ <t-button variant="text" size="small" @click="handleCancelSelection">
93
+ 取消
94
+ </t-button>
95
+ </div>
96
+ <div class="booking-info">
97
+ <div class="info-row">
98
+ <span class="label">会议室:</span>
99
+ <span class="value">{{ selectedRoom?.name }}</span>
100
+ </div>
101
+ <div class="info-row">
102
+ <span class="label">日期:</span>
103
+ <span class="value">{{ formatDate(selectedDate) }}</span>
104
+ </div>
105
+ <div class="info-row">
106
+ <span class="label">时间:</span>
107
+ <span class="value">{{ formatSelectedTime() }}</span>
108
+ </div>
109
+ <div class="info-row">
110
+ <span class="label">时长:</span>
111
+ <span class="value">{{ selectedTimeSlots.length * 0.5 }}小时</span>
112
+ </div>
113
+ </div>
114
+ <div class="booking-actions">
115
+ <t-button theme="primary" size="large" block :loading="bookingLoading" @click="handleConfirmBooking">
116
+ {{ confirmButtonText }}
117
+ </t-button>
118
+ </div>
119
+ </div>
120
+ </slot>
121
+ </div>
122
+ </div>
123
+ <!-- 预约成功提示组件 -->
124
+ <div v-if="showSuccessMessage" class="success-overlay" @click="hideSuccessMessage">
125
+ <div class="success-container" @click.stop>
126
+ <div class="success-icon">✅</div>
127
+ <div class="success-title">{{ successTitle }}</div>
128
+ <div class="success-content">
129
+ <div class="success-item">
130
+ <span class="success-label">会议室:</span>
131
+ <span class="success-value">{{ successData.roomName }}</span>
132
+ </div>
133
+ <div class="success-item">
134
+ <span class="success-label">日期:</span>
135
+ <span class="success-value">{{ successData.date }}</span>
136
+ </div>
137
+ <div class="success-item">
138
+ <span class="success-label">时间:</span>
139
+ <span class="success-value">{{ successData.time }}</span>
140
+ </div>
141
+ <div class="success-item">
142
+ <span class="success-label">时长:</span>
143
+ <span class="success-value">{{ successData.duration }}小时</span>
144
+ </div>
145
+ <div v-if="successData.isPreemptive" class="success-preempt-info">
146
+ <div class="preempt-info-title">已取消的会议:</div>
147
+ <div class="preempt-info-content">{{ successData.cancelledMeetings }}</div>
148
+ </div>
149
+ </div>
150
+ <div class="success-actions">
151
+ <t-button theme="primary" @click="hideSuccessMessage">确定</t-button>
152
+ </div>
153
+ </div>
154
+ </div>
155
+ </div>
156
+ </template>
157
+
158
+ <script setup>
159
+ import { ref, computed, watch, defineProps, defineEmits } from 'vue'
160
+ import { Loading as TLoading, Tag as TTag, Button as TButton, MessagePlugin } from 'tdesign-vue-next'
161
+ import { dataService } from '../index.js'
162
+
163
+ // 组件属性接口
164
+ const props = defineProps({
165
+ rooms: {
166
+ type: Array,
167
+ default: () => []
168
+ },
169
+ selectedDate: {
170
+ type: String,
171
+ default: ""
172
+ },
173
+ timeSlots: {
174
+ type: Array,
175
+ default: () => []
176
+ },
177
+ bookedSlots: {
178
+ type: Object,
179
+ default: () => ({})
180
+ },
181
+ loading: {
182
+ type: Boolean,
183
+ default: false
184
+ },
185
+ disabled: {
186
+ type: Boolean,
187
+ default: false
188
+ },
189
+ minDuration: {
190
+ type: Number,
191
+ default: 1
192
+ },
193
+ maxDuration: {
194
+ type: Number,
195
+ default: 8
196
+ },
197
+ // 新增API配置属性
198
+ roomQueryApiConfig: {
199
+ type: Object,
200
+ default: () => ({})
201
+ },
202
+ bookingApiConfig: {
203
+ type: Object,
204
+ default: () => ({})
205
+ },
206
+ bookingFormData: {
207
+ type: Object,
208
+ default: () => ({})
209
+ },
210
+ confirmButtonText: {
211
+ type: String,
212
+ default: '确认预约'
213
+ },
214
+ successTitle: {
215
+ type: String,
216
+ default: '预约成功'
217
+ },
218
+ preemptSuccessTitle: {
219
+ type: String,
220
+ default: '抢占预约成功'
221
+ }
222
+ })
223
+
224
+ // 定义事件
225
+ const emit = defineEmits([
226
+ 'room-select',
227
+ 'time-select',
228
+ 'booking-confirm',
229
+ 'date-change',
230
+ 'booking-success',
231
+ 'booking-error',
232
+ 'room-query-success',
233
+ 'room-query-error'
234
+ ])
235
+
236
+ // 响应式数据
237
+ const currentDate = computed(() => {
238
+ return formatDate(props.selectedDate)
239
+ })
240
+ const selectedRoom = ref(null)
241
+ const selectedTimeSlots = ref([])
242
+ const bookingLoading = ref(false)
243
+ const roomQueryLoading = ref(false)
244
+ const showSuccessMessage = ref(false)
245
+ const successData = ref({})
246
+ const apiRoomList = ref([]) // 存储从API获取的会议室数据
247
+ const showAllTimeSlots = ref(false)
248
+
249
+ // 计算属性
250
+ const roomList = computed(() => {
251
+ if (apiRoomList.value.length > 0) {
252
+ return apiRoomList.value.map(room => ({
253
+ id: room.conferenceId,
254
+ name: room.conferenceName,
255
+ capacity: room.capacity,
256
+ location: room.location,
257
+ equipment: [],
258
+ timeSlots: room.timeSlots
259
+ }))
260
+ }
261
+ return props.rooms
262
+ })
263
+
264
+ const timeSlotList = computed(() => {
265
+ if (props.timeSlots.length > 0) {
266
+ return props.timeSlots
267
+ }
268
+
269
+ if (apiRoomList.value.length > 0 && apiRoomList.value[0]?.timeSlots) {
270
+ return apiRoomList.value[0].timeSlots.map(slot => ({
271
+ value: slot.time,
272
+ label: slot.time,
273
+ hour: parseInt(slot.time.split(':')[0]),
274
+ minute: parseInt(slot.time.split(':')[1]),
275
+ userInfo: slot?.userInfo ?? null
276
+ }))
277
+ }
278
+
279
+ const slots = []
280
+ for (let hour = 0; hour < 24; hour++) {
281
+ for (let minute = 0; minute < 60; minute += 30) {
282
+ const timeValue = `${hour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}`
283
+ slots.push({
284
+ value: timeValue,
285
+ label: timeValue,
286
+ hour,
287
+ minute
288
+ })
289
+ }
290
+ }
291
+ return slots
292
+ })
293
+
294
+ // 工具方法
295
+ const timeToMinutes = (timeStr) => {
296
+ const [hour, minute] = timeStr.split(':').map(Number)
297
+ return hour * 60 + minute
298
+ }
299
+
300
+ const compareTimes = (timeA, timeB) => {
301
+ const minutesA = timeToMinutes(timeA)
302
+ const minutesB = timeToMinutes(timeB)
303
+ if (minutesA === minutesB) return 0
304
+ return minutesA < minutesB ? -1 : 1
305
+ }
306
+
307
+ const _isTimeOverlap = (start1, end1, start2, end2) => {
308
+ const s1 = timeToMinutes(start1)
309
+ const e1 = timeToMinutes(end1)
310
+ const s2 = timeToMinutes(start2)
311
+ const e2 = timeToMinutes(end2)
312
+
313
+ return s1 < e2 && s2 < e1
314
+ }
315
+
316
+ const getEndTime = (startTime) => {
317
+ const [hour, minute] = startTime.split(':').map(Number)
318
+ const endMinute = minute + 30
319
+ const endHour = endMinute >= 60 ? hour + 1 : hour
320
+ const finalMinute = endMinute >= 60 ? endMinute - 60 : endMinute
321
+
322
+ return `${endHour.toString().padStart(2, '0')}:${finalMinute.toString().padStart(2, '0')}`
323
+ }
324
+
325
+ const minutesToTime = (minutes) => {
326
+ const hour = Math.floor(minutes / 60)
327
+ const minute = minutes % 60
328
+ return `${hour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}`
329
+ }
330
+
331
+ const getCurrentTime = () => {
332
+ const now = new Date()
333
+ const hour = now.getHours().toString().padStart(2, '0')
334
+ const minute = now.getMinutes().toString().padStart(2, '0')
335
+ return `${hour}:${minute}`
336
+ }
337
+
338
+ // 状态检查方法
339
+ const isSlotBooked = (roomId, timeSlot) => {
340
+ if (apiRoomList.value.length > 0) {
341
+ const room = apiRoomList.value.find(r => r.conferenceId == roomId)
342
+ if (room && room.timeSlots) {
343
+ const slot = room.timeSlots.find(s => s.time === timeSlot)
344
+ return slot ? slot.occupied : false
345
+ }
346
+ }
347
+ return props.bookedSlots[roomId]?.includes(timeSlot) || false
348
+ }
349
+
350
+ const bookedInfo = (roomId, timeSlot, type = 'name') => {
351
+ if (apiRoomList.value.length > 0) {
352
+ const room = apiRoomList.value.find(r => r.conferenceId == roomId)
353
+ if (room && room.timeSlots) {
354
+ const slot = room.timeSlots.find(s => s.time === timeSlot)
355
+ if (type === 'name') {
356
+ return slot?.userInfo?.name ? slot.userInfo.name : ''
357
+ } else {
358
+ return slot?.userInfo?.no ? slot.userInfo.no : ''
359
+ }
360
+ }
361
+ }
362
+ return ''
363
+ }
364
+
365
+ const isSlotSelected = (roomId, timeSlot) => {
366
+ return selectedRoom.value?.id === roomId && selectedTimeSlots.value.includes(timeSlot)
367
+ }
368
+
369
+ const isSlotDisabled = (_roomId, _timeSlot) => {
370
+ const today = formatDate(new Date().getTime());
371
+ if (currentDate.value === today && compareTimes(getCurrentTime(), _timeSlot) === 1) {
372
+ return true
373
+ }
374
+ return false
375
+ }
376
+
377
+ // 智能选择时间段 - 自动填充中间的时间段
378
+ const getSmartSelectedSlots = (slots, roomId) => {
379
+ if (slots.length <= 1) return slots
380
+
381
+ const slotsInMinutes = slots.map(timeToMinutes).sort((a, b) => a - b)
382
+ const minTime = slotsInMinutes[0]
383
+ const maxTime = slotsInMinutes[slotsInMinutes.length - 1]
384
+
385
+ const continuousSlots = []
386
+ for (let time = minTime; time <= maxTime; time += 30) {
387
+ const timeStr = minutesToTime(time)
388
+
389
+ if (!isSlotBooked(roomId, timeStr)) {
390
+ continuousSlots.push(timeStr)
391
+ } else {
392
+ break
393
+ }
394
+ }
395
+
396
+ return continuousSlots
397
+ }
398
+
399
+ // 限制选择的时间段数量,保留以最新选择为中心的连续时间段
400
+ const getLimitedSlots = (slots, latestSlot, maxDuration) => {
401
+ const latestMinutes = timeToMinutes(latestSlot)
402
+ const slotsInMinutes = slots.map(timeToMinutes).sort((a, b) => a - b)
403
+
404
+ const latestIndex = slotsInMinutes.indexOf(latestMinutes)
405
+
406
+ const halfDuration = Math.floor(maxDuration / 2)
407
+ const startIndex = Math.max(0, latestIndex - halfDuration)
408
+ const endIndex = Math.min(slotsInMinutes.length, startIndex + maxDuration)
409
+
410
+ const adjustedStartIndex = Math.max(0, endIndex - maxDuration)
411
+
412
+ return slotsInMinutes
413
+ .slice(adjustedStartIndex, endIndex)
414
+ .map(minutesToTime)
415
+ }
416
+
417
+ // 清理方法
418
+ const clearTimeSelection = () => {
419
+ selectedTimeSlots.value = []
420
+ }
421
+
422
+ const clearSelection = () => {
423
+ selectedRoom.value = null
424
+ clearTimeSelection()
425
+ }
426
+
427
+ // 显示预约成功信息
428
+ const showBookingSuccess = (bookingData) => {
429
+ successData.value = {
430
+ roomName: bookingData.room.name,
431
+ date: bookingData.date,
432
+ time: `${bookingData.startTime} - ${bookingData.endTime}`,
433
+ duration: bookingData.duration,
434
+ isPreemptive: bookingData.isPreemptive,
435
+ cancelledMeetings: bookingData.isPreemptive
436
+ ? bookingData.conflictMeetings?.map(m => m.title).join('、') || ''
437
+ : ''
438
+ }
439
+ showSuccessMessage.value = true
440
+ }
441
+
442
+ // 隐藏成功信息
443
+ const hideSuccessMessage = () => {
444
+ showSuccessMessage.value = false
445
+ successData.value = {}
446
+ emit('booking-success', successData.value)
447
+ }
448
+
449
+ // 状态获取方法
450
+ const getRoomStatusClass = (room) => {
451
+ const commonTimeSlots = timeSlotList.value.filter(slot =>
452
+ slot.hour >= 7 && slot.hour < 22
453
+ )
454
+
455
+ const availableSlots = commonTimeSlots.filter(slot =>
456
+ !isSlotBooked(room.id, slot.value)
457
+ ).length
458
+
459
+ if (availableSlots === 0) return 'fully-booked'
460
+ if (availableSlots < commonTimeSlots.length / 2) return 'partially-available'
461
+ return 'available'
462
+ }
463
+
464
+ const getRoomStatusText = (room) => {
465
+ const commonTimeSlots = timeSlotList.value.filter(slot =>
466
+ slot.hour >= 7 && slot.hour < 22
467
+ )
468
+
469
+ const availableSlots = commonTimeSlots.filter(slot =>
470
+ !isSlotBooked(room.id, slot.value)
471
+ ).length
472
+
473
+ if (availableSlots === 0) return '已满'
474
+ if (availableSlots < commonTimeSlots.length / 2) return '紧张'
475
+ return '充足'
476
+ }
477
+
478
+ const formatSelectedTime = () => {
479
+ if (selectedTimeSlots.value.length === 0) return ''
480
+
481
+ const sortedSlots = [...selectedTimeSlots.value].sort()
482
+ const startTime = sortedSlots[0]
483
+ const endTime = getEndTime(sortedSlots[sortedSlots.length - 1])
484
+
485
+ return `${startTime} - ${endTime}`
486
+ }
487
+
488
+ const currentSelection = computed(() => {
489
+ if (!selectedRoom.value || selectedTimeSlots.value.length === 0) {
490
+ return null
491
+ }
492
+
493
+ const sortedSlots = [...selectedTimeSlots.value].sort()
494
+ return {
495
+ room: selectedRoom.value,
496
+ date: currentDate.value,
497
+ startTime: sortedSlots[0],
498
+ endTime: getEndTime(sortedSlots[sortedSlots.length - 1]),
499
+ duration: selectedTimeSlots.value.length * 0.5,
500
+ timeSlots: sortedSlots
501
+ }
502
+ })
503
+
504
+ const formatDate = (timestamp) => {
505
+ const date = new Date(timestamp)
506
+ const year = date.getFullYear()
507
+ const month = String(date.getMonth() + 1).padStart(2, '0')
508
+ const day = String(date.getDate()).padStart(2, '0')
509
+ return `${year}-${month}-${day}`
510
+ }
511
+
512
+ // API调用方法
513
+ const queryRooms = async (date) => {
514
+ try {
515
+ roomQueryLoading.value = true
516
+
517
+ if (!date) {
518
+ date = props.selectedDate
519
+ }
520
+ const queryParams = {
521
+ date: props.selectedDate,
522
+ requestTime: new Date().getTime()
523
+ }
524
+
525
+ let response
526
+ if (props.roomQueryApiConfig && Object.keys(props.roomQueryApiConfig).length > 0) {
527
+ response = await dataService.fetch(queryParams, props.roomQueryApiConfig)
528
+ } else {
529
+ if (typeof props.selectedDate === 'number') {
530
+ queryParams.date = formatDate(props.selectedDate)
531
+ }
532
+
533
+ response = await dataService.fetch(queryParams, {}, "/appdata/execute/plugin?key=get-meetingRoomOccupy-info&date=" + queryParams.date)
534
+ }
535
+
536
+ const roomData = response.meetingRooms
537
+ apiRoomList.value = roomData
538
+
539
+ emit('room-query-success', {
540
+ success: true,
541
+ message: '查询成功',
542
+ data: roomData
543
+ })
544
+ } catch (error) {
545
+ emit('room-query-error', error)
546
+ MessagePlugin.error({
547
+ duration: 3000,
548
+ content: error.message || '查询会议室失败'
549
+ })
550
+ } finally {
551
+ roomQueryLoading.value = false
552
+ }
553
+ }
554
+
555
+ const handleBeforeSubmit = (bookingData) => {
556
+ try {
557
+ emit('before-submit', bookingData)
558
+ } catch (error) {
559
+ throw new Error(error.message)
560
+ }
561
+ }
562
+ const submitBooking = async (bookingData) => {
563
+ if (!props.bookingApiConfig || Object.keys(props.bookingApiConfig).length === 0) {
564
+ emit('booking-confirm', bookingData)
565
+ return
566
+ }
567
+
568
+ try {
569
+ bookingLoading.value = true
570
+
571
+ let date = formatDate(props.selectedDate)
572
+ const submitData = {
573
+ ...props.bookingFormData,
574
+ conference_id: bookingData.room.id,
575
+ roomName: bookingData.room.name,
576
+ date: date,
577
+ start_time: new Date(date + " " + bookingData.startTime + ":00").getTime(),
578
+ end_time: new Date(date + " " + bookingData.endTime + ":00") - 1,
579
+ duration: bookingData.duration,
580
+ timeSlots: bookingData.timeSlots,
581
+ requestTime: new Date().getTime(),
582
+ }
583
+
584
+ const response = await dataService.fetch({ saveData: submitData }, props.bookingApiConfig)
585
+
586
+ showBookingSuccess(bookingData)
587
+
588
+ } catch (error) {
589
+ emit('booking-error', error)
590
+ MessagePlugin.error({
591
+ duration: 3000,
592
+ content: error.message || '预约失败'
593
+ })
594
+ } finally {
595
+ bookingLoading.value = false
596
+ }
597
+ }
598
+
599
+ // 事件处理方法
600
+ const handleRoomSelect = (room) => {
601
+ if (selectedRoom.value?.id === room.id) {
602
+ return
603
+ } else {
604
+ selectedRoom.value = room
605
+ clearTimeSelection()
606
+ emit('room-select', room)
607
+ }
608
+ }
609
+
610
+ const handleTimeSlotClick = (room, slot) => {
611
+ if (props.disabled || isSlotDisabled(room.id, slot.value) || isSlotBooked(room.id, slot.value)) {
612
+ return
613
+ }
614
+
615
+ if (!selectedRoom.value || selectedRoom.value.id !== room.id) {
616
+ selectedRoom.value = room
617
+ emit('room-select', room)
618
+ }
619
+
620
+ const slotIndex = selectedTimeSlots.value.indexOf(slot.value)
621
+
622
+ if (slotIndex > -1) {
623
+ selectedTimeSlots.value.splice(slotIndex, 1)
624
+ } else {
625
+ if (selectedTimeSlots.value.length === 0) {
626
+ selectedTimeSlots.value.push(slot.value)
627
+ } else {
628
+ const newSlots = [...selectedTimeSlots.value, slot.value]
629
+ selectedTimeSlots.value = getSmartSelectedSlots(newSlots, room.id)
630
+ }
631
+
632
+ if (selectedTimeSlots.value.length > props.maxDuration) {
633
+ selectedTimeSlots.value = getLimitedSlots(selectedTimeSlots.value, slot.value, props.maxDuration)
634
+ }
635
+ }
636
+
637
+ selectedTimeSlots.value = [...selectedTimeSlots.value]
638
+
639
+ emit('time-select', currentSelection.value)
640
+ }
641
+
642
+ const handleConfirmBooking = async () => {
643
+ if (!currentSelection.value) return
644
+
645
+ const bookingData = {
646
+ room: selectedRoom.value,
647
+ date: currentDate.value,
648
+ startTime: currentSelection.value.startTime,
649
+ endTime: currentSelection.value.endTime,
650
+ duration: currentSelection.value.duration,
651
+ timeSlots: currentSelection.value.timeSlots,
652
+ isPreemptive: false,
653
+ conflictMeetings: []
654
+ }
655
+
656
+ handleBeforeSubmit(bookingData)
657
+ }
658
+
659
+ const handleCancelSelection = () => {
660
+ clearSelection()
661
+ }
662
+
663
+ // 时间筛选功能
664
+ const toggleTimeFilter = () => {
665
+ showAllTimeSlots.value = !showAllTimeSlots.value
666
+ }
667
+
668
+ // 监听属性变化
669
+ watch(() => props.selectedDate, (newDate) => {
670
+ })
671
+
672
+ // 新增计算属性
673
+ const filteredTimeSlotList = computed(() => {
674
+ if (showAllTimeSlots.value) {
675
+ return timeSlotList.value
676
+ } else {
677
+ return timeSlotList.value.filter(slot =>
678
+ slot.hour >= 7 && slot.hour < 22
679
+ )
680
+ }
681
+ })
682
+
683
+ // 辅助方法:将时间戳转换为时间段数组
684
+ const getTimeSlotsFromRange = (startTime, endTime) => {
685
+ const slots = []
686
+ let current = new Date(startTime)
687
+ const end = new Date(endTime)
688
+ while (current < end) {
689
+ const hour = current.getHours().toString().padStart(2, '0')
690
+ const minutes = current.getMinutes().toString().padStart(2, '0')
691
+ slots.push(`${hour}:${minutes}`)
692
+ current.setMinutes(current.getMinutes() + 30)
693
+ }
694
+ return slots
695
+ }
696
+
697
+ // 初始化选中的会议室和时间段
698
+ const initializeSelection = async (bookingData) => {
699
+ const roomId = bookingData.conference_id
700
+ const startTime = bookingData.start_time
701
+ const endTime = bookingData.end_time
702
+
703
+ if (!startTime || !endTime) return
704
+
705
+ const rawSlots = getTimeSlotsFromRange(startTime, endTime)
706
+
707
+ if (apiRoomList.value.length === 0) {
708
+ await queryRooms()
709
+ }
710
+
711
+ const room = roomList.value.find(r => r.id === roomId)
712
+ if (!room) return
713
+
714
+ const validSlots = rawSlots.filter(slot => !isSlotBooked(roomId, slot))
715
+
716
+ selectedRoom.value = room
717
+
718
+ selectedTimeSlots.value = validSlots
719
+ }
720
+
721
+ // 监听bookingFormData变化,进行初始化选中
722
+ watch(() => props.bookingFormData, async (newVal) => {
723
+ if (newVal && newVal.conference_id && newVal.start_time && newVal.end_time) {
724
+ await initializeSelection(newVal)
725
+ }
726
+ }, { deep: true, immediate: true })
727
+
728
+ // 暴露组件实例方法
729
+ defineExpose({
730
+ clearSelection,
731
+ clearTimeSelection,
732
+ getCurrentSelection: () => currentSelection.value,
733
+ queryRooms,
734
+ submitBooking,
735
+ showBookingSuccess,
736
+ hideSuccessMessage,
737
+ toggleTimeFilter,
738
+ getApiRoomList: () => apiRoomList.value,
739
+ refreshRooms: queryRooms,
740
+ getShowAllTimeSlots: () => showAllTimeSlots.value,
741
+ setShowAllTimeSlots: (value) => { showAllTimeSlots.value = value },
742
+ compareTimes,
743
+ getCurrentTime
744
+ })
745
+ </script>
746
+
747
+ <style scoped>
748
+ .ebiz-meeting-room-selector {
749
+ padding-bottom: 280px;
750
+ position: relative;
751
+ transform: translateX(0px);
752
+ }
753
+
754
+ .selector-content {
755
+ padding: 16px;
756
+ }
757
+
758
+ .rooms-list {
759
+ display: flex;
760
+ flex-direction: column;
761
+ gap: 16px;
762
+ }
763
+
764
+ .room-card {
765
+ background: #fff;
766
+ border-radius: 12px;
767
+ overflow: hidden;
768
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
769
+ transition: all 0.3s ease;
770
+ }
771
+
772
+ .room-card.selected {
773
+ border: 2px solid #1890ff;
774
+ box-shadow: 0 4px 12px rgba(24, 144, 255, 0.2);
775
+ }
776
+
777
+ .room-info {
778
+ padding: 16px;
779
+ cursor: pointer;
780
+ }
781
+
782
+ .room-header {
783
+ display: flex;
784
+ justify-content: space-between;
785
+ align-items: center;
786
+ margin-bottom: 12px;
787
+ }
788
+
789
+ .room-name {
790
+ margin: 0;
791
+ font-size: 16px;
792
+ font-weight: 600;
793
+ color: #333;
794
+ }
795
+
796
+ .room-controls {
797
+ display: flex;
798
+ align-items: center;
799
+ gap: 8px;
800
+ }
801
+
802
+ .time-filter-btn {
803
+ flex-shrink: 0;
804
+ }
805
+
806
+ .time-filter-btn .t-button {
807
+ height: 24px;
808
+ padding: 0 8px;
809
+ font-size: 11px;
810
+ border-radius: 12px;
811
+ }
812
+
813
+ .room-status {
814
+ padding: 4px 8px;
815
+ border-radius: 12px;
816
+ font-size: 12px;
817
+ font-weight: 500;
818
+ }
819
+
820
+ .room-status.available {
821
+ background: #f6ffed;
822
+ color: #52c41a;
823
+ }
824
+
825
+ .room-status.partially-available {
826
+ background: #fff7e6;
827
+ color: #fa8c16;
828
+ }
829
+
830
+ .room-status.fully-booked {
831
+ background: #fff2f0;
832
+ color: #ff4d4f;
833
+ }
834
+
835
+ .room-details {
836
+ display: flex;
837
+ gap: 16px;
838
+ margin-bottom: 12px;
839
+ }
840
+
841
+ .detail-item {
842
+ display: flex;
843
+ align-items: center;
844
+ gap: 4px;
845
+ font-size: 14px;
846
+ color: #666;
847
+ }
848
+
849
+ .icon {
850
+ font-size: 16px;
851
+ }
852
+
853
+ .equipment {
854
+ display: flex;
855
+ flex-wrap: wrap;
856
+ gap: 6px;
857
+ }
858
+
859
+ .equipment-tag {
860
+ font-size: 12px;
861
+ }
862
+
863
+ .time-selection {
864
+ border-top: 1px solid #f0f0f0;
865
+ padding: 16px;
866
+ background: #fafafa;
867
+ }
868
+
869
+ .time-header {
870
+ display: flex;
871
+ justify-content: space-between;
872
+ align-items: center;
873
+ margin-bottom: 12px;
874
+ }
875
+
876
+ .time-header h5 {
877
+ margin: 0;
878
+ font-size: 14px;
879
+ font-weight: 600;
880
+ color: #333;
881
+ }
882
+
883
+ .selected-info {
884
+ font-size: 12px;
885
+ color: #1890ff;
886
+ font-weight: 500;
887
+ }
888
+
889
+ .time-slots-grid {
890
+ display: grid;
891
+ grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
892
+ gap: 12px;
893
+ }
894
+
895
+ .time-slot {
896
+ background: #f6ffed;
897
+ border: 1px solid #52c41a;
898
+ border-radius: 8px;
899
+ text-align: center;
900
+ cursor: pointer;
901
+ transition: all 0.2s ease;
902
+ min-height: 60px;
903
+ display: flex;
904
+ flex-direction: column;
905
+ justify-content: center;
906
+ }
907
+
908
+ .time-slot:active {
909
+ transform: scale(0.95);
910
+ }
911
+
912
+ .time-slot.booked {
913
+ background: #f5f5f5;
914
+ border-color: #d9d9d9;
915
+ cursor: not-allowed;
916
+ }
917
+
918
+ .time-slot.selected {
919
+ background: #e6f7ff;
920
+ border-color: #1890ff;
921
+ color: #1890ff;
922
+ }
923
+
924
+ .time-slot.disabled {
925
+ background: #f5f5f5;
926
+ border-color: #d9d9d9;
927
+ cursor: not-allowed;
928
+ }
929
+
930
+ .slot-content {
931
+ display: flex;
932
+ flex-direction: column;
933
+ align-items: center;
934
+ gap: 4px;
935
+ }
936
+
937
+ .slot-time {
938
+ font-size: 14px;
939
+ font-weight: 500;
940
+ }
941
+
942
+ .status-icon {
943
+ font-size: 14px;
944
+ color: #666;
945
+ word-break: break-all;
946
+ }
947
+
948
+ .booking-panel {
949
+ position: fixed;
950
+ bottom: 0;
951
+ left: 8px;
952
+ right: 8px;
953
+ background: #fff;
954
+ border-top: 1px solid #eee;
955
+ box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
956
+ z-index: 1000;
957
+ animation: slideUp 0.3s ease;
958
+ }
959
+
960
+ @keyframes slideUp {
961
+ from {
962
+ transform: translateY(100%);
963
+ }
964
+
965
+ to {
966
+ transform: translateY(0);
967
+ }
968
+ }
969
+
970
+ .booking-form {
971
+ padding: 24px;
972
+ }
973
+
974
+ .booking-header {
975
+ display: flex;
976
+ justify-content: space-between;
977
+ align-items: center;
978
+ margin-bottom: 16px;
979
+ }
980
+
981
+ .booking-header h4 {
982
+ margin: 0;
983
+ font-size: 18px;
984
+ font-weight: 600;
985
+ color: #333;
986
+ }
987
+
988
+ .booking-info {
989
+ margin-bottom: 24px;
990
+ }
991
+
992
+ .info-row {
993
+ display: flex;
994
+ justify-content: space-between;
995
+ align-items: center;
996
+ padding: 8px 0;
997
+ font-size: 16px;
998
+ }
999
+
1000
+ .label {
1001
+ color: #666;
1002
+ font-weight: 500;
1003
+ }
1004
+
1005
+ .value {
1006
+ color: #333;
1007
+ font-weight: 600;
1008
+ }
1009
+
1010
+ .booking-actions {
1011
+ margin-top: 16px;
1012
+ }
1013
+
1014
+ /* 预约成功提示样式 */
1015
+ .success-overlay {
1016
+ position: fixed;
1017
+ top: 0;
1018
+ left: 0;
1019
+ right: 0;
1020
+ bottom: 0;
1021
+ background: rgba(0, 0, 0, 0.5);
1022
+ display: flex;
1023
+ align-items: center;
1024
+ justify-content: center;
1025
+ z-index: 1000;
1026
+ animation: fadeIn 0.3s ease;
1027
+ }
1028
+
1029
+ .success-container {
1030
+ background: #fff;
1031
+ border-radius: 16px;
1032
+ padding: 32px;
1033
+ margin: 20px;
1034
+ max-width: 500px;
1035
+ width: 100%;
1036
+ text-align: center;
1037
+ animation: slideUpSuccess 0.3s ease;
1038
+ }
1039
+
1040
+ .success-icon {
1041
+ font-size: 40px;
1042
+ margin-bottom: 24px;
1043
+ }
1044
+
1045
+ .success-title {
1046
+ font-size: 24px;
1047
+ font-weight: 600;
1048
+ color: #333;
1049
+ margin-bottom: 24px;
1050
+ }
1051
+
1052
+ .success-content {
1053
+ text-align: left;
1054
+ margin-bottom: 32px;
1055
+ }
1056
+
1057
+ .success-item {
1058
+ display: flex;
1059
+ justify-content: space-between;
1060
+ align-items: center;
1061
+ padding: 12px 0;
1062
+ border-bottom: 1px solid #f0f0f0;
1063
+ }
1064
+
1065
+ .success-item:last-child {
1066
+ border-bottom: none;
1067
+ }
1068
+
1069
+ .success-label {
1070
+ font-size: 16px;
1071
+ color: #666;
1072
+ }
1073
+
1074
+ .success-value {
1075
+ font-size: 16px;
1076
+ font-weight: 500;
1077
+ color: #333;
1078
+ }
1079
+
1080
+ .success-preempt-info {
1081
+ margin-top: 16px;
1082
+ padding: 16px;
1083
+ background: #fff7e6;
1084
+ border-radius: 8px;
1085
+ border-left: 4px solid #fa8c16;
1086
+ }
1087
+
1088
+ .preempt-info-title {
1089
+ font-size: 14px;
1090
+ color: #d46b08;
1091
+ font-weight: 600;
1092
+ margin-bottom: 8px;
1093
+ }
1094
+
1095
+ .preempt-info-content {
1096
+ font-size: 14px;
1097
+ color: #d46b08;
1098
+ line-height: 1.4;
1099
+ }
1100
+
1101
+ .success-actions {
1102
+ text-align: center;
1103
+ }
1104
+
1105
+ @keyframes fadeIn {
1106
+ from {
1107
+ opacity: 0;
1108
+ }
1109
+
1110
+ to {
1111
+ opacity: 1;
1112
+ }
1113
+ }
1114
+
1115
+ @keyframes slideUpSuccess {
1116
+ from {
1117
+ transform: translateY(30px);
1118
+ opacity: 0;
1119
+ }
1120
+
1121
+ to {
1122
+ transform: translateY(0);
1123
+ opacity: 1;
1124
+ }
1125
+ }
1126
+
1127
+ /* 响应式设计 */
1128
+ @media (max-width: 768px) {
1129
+ .time-slots-grid {
1130
+ grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
1131
+ gap: 8px;
1132
+ }
1133
+
1134
+ .time-slot {
1135
+ min-height: 60px;
1136
+ }
1137
+
1138
+ .slot-time {
1139
+ font-size: 12px;
1140
+ }
1141
+
1142
+ .status-icon {
1143
+ font-size: 12px;
1144
+ }
1145
+
1146
+ .success-container {
1147
+ margin: 10px;
1148
+ }
1149
+ }
1150
1150
  </style>