@ebiz/designer-components 0.1.0 → 0.1.1
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.
- package/README.md +29 -29
- package/dist/designer-components.css +1 -1
- package/dist/index.mjs +264 -264
- package/package.json +1 -1
- package/src/App.vue +26 -26
- package/src/apiService/SIMPLE_DATA_SERVICE.md +284 -284
- package/src/apiService/mockDataService.js +115 -115
- package/src/apiService/simpleDataService.js +297 -297
- package/src/assets/base.css +86 -86
- package/src/assets/logo.svg +1 -1
- package/src/components/Button.vue +149 -149
- package/src/components/DataContainer.vue +40 -40
- package/src/components/EbizApproval.vue +332 -332
- package/src/components/EbizAutoForm.vue +596 -596
- package/src/components/EbizAvatar.vue +115 -115
- package/src/components/EbizCheckbox.vue +93 -93
- package/src/components/EbizCheckboxGroup.vue +69 -69
- package/src/components/EbizDepartmentSelector.vue +144 -144
- package/src/components/EbizDescriptions.vue +340 -340
- package/src/components/EbizDescriptionsItem.vue +47 -47
- package/src/components/EbizDetailBlock.vue +81 -81
- package/src/components/EbizDialog.vue +260 -260
- package/src/components/EbizDiv.vue +32 -32
- package/src/components/EbizDivider.vue +96 -96
- package/src/components/EbizDropdown.vue +117 -0
- package/src/components/EbizDropdownItem.vue +81 -0
- package/src/components/EbizEmployeeInfo.vue +138 -138
- package/src/components/EbizEmployeeSelector.vue +1095 -1095
- package/src/components/EbizFileUpload.vue +238 -238
- package/src/components/EbizMap.vue +541 -541
- package/src/components/EbizMeetingRoomSelector.vue +664 -664
- package/src/components/EbizMobileMeetingRoomSelector.vue +727 -727
- package/src/components/EbizOkrTree.vue +99 -99
- package/src/components/EbizPageHeader.vue +95 -95
- package/src/components/EbizPagination.vue +162 -162
- package/src/components/EbizPopconfirm.vue +47 -47
- package/src/components/EbizRadio.vue +86 -86
- package/src/components/EbizRadioGroup.vue +83 -83
- package/src/components/EbizRemoteSelect.vue +232 -232
- package/src/components/EbizRouteBreadcrumb.vue +46 -46
- package/src/components/EbizSelect.vue +85 -85
- package/src/components/EbizSpace.vue +100 -100
- package/src/components/EbizStatistic.vue +149 -149
- package/src/components/EbizStatsCard.vue +113 -113
- package/src/components/EbizSwiper.vue +113 -113
- package/src/components/EbizSwiperItem.vue +13 -13
- package/src/components/EbizSwitch.vue +85 -85
- package/src/components/EbizTabHeader.vue +132 -132
- package/src/components/EbizTabPanel.vue +22 -22
- package/src/components/EbizTable.vue +469 -469
- package/src/components/EbizTableColumn.vue +116 -116
- package/src/components/EbizTableSort.vue +179 -179
- package/src/components/EbizTabs.vue +142 -142
- package/src/components/EbizTdesignButtonDialog.vue +332 -332
- package/src/components/EbizTdesignLoading.vue +107 -107
- package/src/components/EbizTimePicker.vue +143 -143
- package/src/components/EbizTitle.vue +91 -91
- package/src/components/EbizTree.vue +152 -152
- package/src/components/EbizTreeMergeTable.vue +1414 -1414
- package/src/components/EbizTreeSelector.vue +418 -418
- package/src/components/EbizVxeTable.vue +290 -290
- package/src/components/Form.vue +28 -28
- package/src/components/Home.vue +7 -7
- package/src/components/MyComponent.vue +39 -39
- package/src/components/Table.vue +45 -45
- package/src/components/TdesignAlert.vue +115 -115
- package/src/components/TdesignButton.vue +135 -135
- package/src/components/TdesignCalendar/index.vue +145 -145
- package/src/components/TdesignCard.vue +195 -195
- package/src/components/TdesignCol.vue +101 -101
- package/src/components/TdesignCollapse.vue +142 -142
- package/src/components/TdesignCollapsePanel.vue +79 -79
- package/src/components/TdesignDatePicker.vue +124 -124
- package/src/components/TdesignDescriptions.vue +74 -74
- package/src/components/TdesignDescriptionsItem.vue +50 -50
- package/src/components/TdesignDialog.vue +225 -225
- package/src/components/TdesignForm.vue +138 -138
- package/src/components/TdesignFormItem.vue +105 -105
- package/src/components/TdesignGrid.vue +55 -55
- package/src/components/TdesignIcon.vue +67 -67
- package/src/components/TdesignImage.vue +162 -162
- package/src/components/TdesignImageViewer.vue +200 -200
- package/src/components/TdesignInput.vue +242 -242
- package/src/components/TdesignSelect.vue +444 -444
- package/src/components/TdesignTag.vue +117 -117
- package/src/components/TdesignTextarea.vue +142 -142
- package/src/components/TdesignTimeline.vue +58 -58
- package/src/components/TdesignTimelineItem.vue +71 -71
- package/src/components/TdesignUpload.vue +392 -392
- package/src/components/TdesignWatermark.vue +107 -107
- package/src/components/ebiz-form/components/cascader.vue +61 -61
- package/src/components/ebiz-form/components/checkbox.vue +37 -37
- package/src/components/ebiz-form/components/city.vue +137 -137
- package/src/components/ebiz-form/components/date-panel.vue +52 -52
- package/src/components/ebiz-form/components/date-range-panel.vue +52 -52
- package/src/components/ebiz-form/components/date-range.vue +56 -56
- package/src/components/ebiz-form/components/date.vue +52 -52
- package/src/components/ebiz-form/components/editor-multi-language.vue +47 -47
- package/src/components/ebiz-form/components/editor.vue +78 -78
- package/src/components/ebiz-form/components/file-multi-language.vue +52 -52
- package/src/components/ebiz-form/components/file.vue +149 -149
- package/src/components/ebiz-form/components/images-multi-language.vue +52 -52
- package/src/components/ebiz-form/components/images.vue +129 -129
- package/src/components/ebiz-form/components/img-multi-language.vue +51 -51
- package/src/components/ebiz-form/components/img.vue +129 -129
- package/src/components/ebiz-form/components/number.vue +50 -50
- package/src/components/ebiz-form/components/radio.vue +28 -28
- package/src/components/ebiz-form/components/select.vue +119 -119
- package/src/components/ebiz-form/components/switch.vue +23 -23
- package/src/components/ebiz-form/components/text-multi-language.vue +47 -47
- package/src/components/ebiz-form/components/text.vue +52 -52
- package/src/components/ebiz-form/components/textarea-multi-language.vue +48 -48
- package/src/components/ebiz-form/components/textarea.vue +29 -29
- package/src/components/ebiz-form/components/video-multi-language.vue +51 -51
- package/src/components/ebiz-form/components/video.vue +97 -97
- package/src/components/ebiz-form/index.vue +157 -157
- package/src/components/examples/PopconfirmExample.vue +149 -149
- package/src/components/icons/IconCommunity.vue +7 -7
- package/src/components/icons/IconDocumentation.vue +7 -7
- package/src/components/icons/IconEcosystem.vue +7 -7
- package/src/components/icons/IconSupport.vue +7 -7
- package/src/components/icons/IconTooling.vue +19 -19
- package/src/components/senior/EbizSData/index.vue +262 -262
- package/src/components/senior/EbizSDialog/index.vue +715 -715
- package/src/components/senior/EbizSForm/README.md +157 -157
- package/src/components/senior/EbizSForm/index.vue +668 -668
- package/src/components/senior/EbizSForm/item.vue +512 -512
- package/src/components/senior/EbizSForm/mItems/DateTimePicker.vue +51 -51
- package/src/components/senior/EbizSForm/mItems/Picker.vue +63 -63
- package/src/index.js +224 -224
- package/src/main.js +55 -55
- package/src/router/index.js +386 -386
- package/src/utils/formatCode.js +24 -24
- package/src/utils/generateImportStatement.js +52 -52
- package/src/utils/hasJsx.js +25 -25
- package/src/utils/index.js +166 -166
- package/src/utils/mergeOptions.js +29 -29
- package/src/utils/parseRequiredBlocks.js +18 -18
- package/src/utils/upload.ts +126 -126
- package/src/utils/vue-sfc-validator.js +155 -155
- package/src/views/Button.vue +23 -23
- package/src/views/CheckboxDemo.vue +104 -104
- package/src/views/DataContainer.vue +19 -19
- package/src/views/DialogDemo.vue +125 -125
- package/src/views/EbizApprovalDemo.vue +76 -76
- package/src/views/EbizAutoFormDemo.vue +129 -129
- package/src/views/EbizAvatar.vue +223 -223
- package/src/views/EbizDepartmentSelectorDemo.vue +169 -169
- package/src/views/EbizDetailBlockDemo.vue +30 -30
- package/src/views/EbizEmployeeInfo.vue +249 -249
- package/src/views/EbizEmployeeSelector.vue +83 -83
- package/src/views/EbizMap.vue +201 -201
- package/src/views/EbizMeetingRoomSelectorDemo.vue +293 -293
- package/src/views/EbizMobileMeetingRoomSelectorDemo.vue +566 -566
- package/src/views/EbizRadioDemo.vue +151 -151
- package/src/views/EbizSDataDemo.vue +136 -136
- package/src/views/EbizSDialogDemo.vue +301 -301
- package/src/views/EbizSForm/index.vue +359 -359
- package/src/views/EbizSFormDemo.vue +420 -420
- package/src/views/EbizSpace.vue +185 -185
- package/src/views/EbizSwiper.vue +157 -157
- package/src/views/EbizTdesignButtonDialogExample.vue +437 -437
- package/src/views/Form.vue +19 -19
- package/src/views/GridDemo.vue +238 -238
- package/src/views/Home.vue +148 -148
- package/src/views/Mindmap.vue +17 -17
- package/src/views/MyComponent.vue +19 -19
- package/src/views/OkrTree.vue +19 -19
- package/src/views/PageHeaderDemo.vue +104 -104
- package/src/views/PaginationDemo.vue +96 -96
- package/src/views/PermissionBoxDemo.vue +85 -85
- package/src/views/PopconfirmDemo.vue +80 -80
- package/src/views/RemoteSelect.vue +350 -350
- package/src/views/StatisticDemo.vue +190 -190
- package/src/views/SwitchDemo.vue +79 -79
- package/src/views/Table.vue +19 -19
- package/src/views/TableDemo.vue +334 -334
- package/src/views/TableSortDemo.vue +143 -143
- package/src/views/TableView.vue +68 -68
- package/src/views/TabsDemo.vue +282 -282
- package/src/views/TagDemo.vue +101 -101
- package/src/views/TdesignAlert.vue +98 -98
- package/src/views/TdesignButton.vue +190 -190
- package/src/views/TdesignCalendar.vue +94 -94
- package/src/views/TdesignCard.vue +296 -296
- package/src/views/TdesignCollapse.vue +293 -293
- package/src/views/TdesignDatePicker.vue +187 -187
- package/src/views/TdesignDescriptions.vue +101 -101
- package/src/views/TdesignForm.vue +248 -248
- package/src/views/TdesignIcon.vue +203 -203
- package/src/views/TdesignImage.vue +215 -215
- package/src/views/TdesignImageViewer.vue +198 -198
- package/src/views/TdesignInput.vue +252 -252
- package/src/views/TdesignSelect.vue +473 -473
- package/src/views/TdesignSwiper.vue +157 -157
- package/src/views/TextareaDemo.vue +93 -93
- package/src/views/TimePickerDemo.vue +146 -146
- package/src/views/TimelineDemo.vue +160 -160
- package/src/views/Title.vue +19 -19
- package/src/views/TreeDemo.vue +254 -254
- package/src/views/TreeMergeTableDemo.vue +239 -239
- package/src/views/TreeSelectorDemo.vue +245 -245
- package/src/views/UploadDemo.vue +121 -121
- package/src/views/VxeTableDemo.vue +279 -279
- package/src/views/WatermarkDemo.vue +85 -85
@@ -1,665 +1,665 @@
|
|
1
|
-
<template>
|
2
|
-
<div class="ebiz-meeting-room-selector">
|
3
|
-
<!-- 头部区域 -->
|
4
|
-
<div class="selector-header">
|
5
|
-
<slot name="header">
|
6
|
-
<div class="header-content">
|
7
|
-
<h3 class="title">会议室预约</h3>
|
8
|
-
<div class="date-selector">
|
9
|
-
<label>选择日期:</label>
|
10
|
-
<t-date-picker
|
11
|
-
v-model="currentDate"
|
12
|
-
:disabled="disabled"
|
13
|
-
:min-date="new Date()"
|
14
|
-
format="YYYY-MM-DD"
|
15
|
-
@change="handleDateChange"
|
16
|
-
/>
|
17
|
-
</div>
|
18
|
-
</div>
|
19
|
-
</slot>
|
20
|
-
</div>
|
21
|
-
|
22
|
-
<!-- 加载状态 -->
|
23
|
-
<div v-if="loading" class="loading-container">
|
24
|
-
<t-loading size="large" text="加载中..." />
|
25
|
-
</div>
|
26
|
-
|
27
|
-
<!-- 主要内容区域 -->
|
28
|
-
<div v-else class="selector-content">
|
29
|
-
<!-- 时间轴表头 -->
|
30
|
-
<div class="time-header">
|
31
|
-
<div class="room-column-header">会议室</div>
|
32
|
-
<div class="time-slots-header">
|
33
|
-
<div
|
34
|
-
v-for="slot in timeSlotList"
|
35
|
-
:key="slot.value"
|
36
|
-
class="time-slot-header"
|
37
|
-
>
|
38
|
-
{{ slot.label }}
|
39
|
-
</div>
|
40
|
-
</div>
|
41
|
-
</div>
|
42
|
-
|
43
|
-
<!-- 会议室列表 -->
|
44
|
-
<div class="rooms-container">
|
45
|
-
<div
|
46
|
-
v-for="room in roomList"
|
47
|
-
:key="room.id"
|
48
|
-
class="room-row"
|
49
|
-
:class="{ 'selected': selectedRoom?.id === room.id }"
|
50
|
-
>
|
51
|
-
<!-- 会议室信息 -->
|
52
|
-
<div class="room-info" @click="handleRoomSelect(room)">
|
53
|
-
<slot name="room-info" :room="room">
|
54
|
-
<div class="room-basic-info">
|
55
|
-
<h4 class="room-name">{{ room.name }}</h4>
|
56
|
-
<p class="room-details">
|
57
|
-
<span class="capacity">容量: {{ room.capacity }}人</span>
|
58
|
-
<span class="location">位置: {{ room.location }}</span>
|
59
|
-
</p>
|
60
|
-
<div v-if="room.equipment?.length" class="equipment">
|
61
|
-
<t-tag
|
62
|
-
v-for="item in room.equipment"
|
63
|
-
:key="item"
|
64
|
-
size="small"
|
65
|
-
variant="light"
|
66
|
-
>
|
67
|
-
{{ item }}
|
68
|
-
</t-tag>
|
69
|
-
</div>
|
70
|
-
</div>
|
71
|
-
</slot>
|
72
|
-
</div>
|
73
|
-
|
74
|
-
<!-- 时间段网格 -->
|
75
|
-
<div class="time-slots-grid">
|
76
|
-
<div
|
77
|
-
v-for="slot in timeSlotList"
|
78
|
-
:key="slot.value"
|
79
|
-
class="time-slot"
|
80
|
-
:class="{
|
81
|
-
'booked': isSlotBooked(room.id, slot.value),
|
82
|
-
'selected': isSlotSelected(room.id, slot.value),
|
83
|
-
'selecting': isSlotSelecting(room.id, slot.value),
|
84
|
-
'disabled': disabled || isSlotDisabled(room.id, slot.value)
|
85
|
-
}"
|
86
|
-
@click="handleTimeSlotClick(room, slot)"
|
87
|
-
@mouseenter="handleTimeSlotHover(room, slot)"
|
88
|
-
@mouseleave="handleTimeSlotLeave()"
|
89
|
-
>
|
90
|
-
<slot name="time-slot" :room="room" :slot="slot" :is-booked="isSlotBooked(room.id, slot.value)">
|
91
|
-
<div class="slot-content">
|
92
|
-
<span v-if="isSlotBooked(room.id, slot.value)" class="booked-indicator">已约</span>
|
93
|
-
<span v-else-if="isSlotSelected(room.id, slot.value)" class="selected-indicator">已选</span>
|
94
|
-
</div>
|
95
|
-
</slot>
|
96
|
-
</div>
|
97
|
-
</div>
|
98
|
-
</div>
|
99
|
-
</div>
|
100
|
-
</div>
|
101
|
-
|
102
|
-
<!-- 预约确认区域 -->
|
103
|
-
<div v-if="selectedTimeSlots.length > 0" class="booking-panel">
|
104
|
-
<slot name="booking-form" :selection="currentSelection">
|
105
|
-
<div class="booking-form">
|
106
|
-
<h4>预约确认</h4>
|
107
|
-
<div class="booking-info">
|
108
|
-
<p><strong>会议室:</strong>{{ selectedRoom?.name }}</p>
|
109
|
-
<p><strong>日期:</strong>{{ currentDate }}</p>
|
110
|
-
<p><strong>时间:</strong>{{ formatSelectedTime() }}</p>
|
111
|
-
<p><strong>时长:</strong>{{ selectedTimeSlots.length * 0.5 }}小时</p>
|
112
|
-
</div>
|
113
|
-
<div class="booking-actions">
|
114
|
-
<t-button variant="outline" @click="handleCancelSelection">取消</t-button>
|
115
|
-
<t-button theme="primary" @click="handleConfirmBooking">确认预约</t-button>
|
116
|
-
</div>
|
117
|
-
</div>
|
118
|
-
</slot>
|
119
|
-
</div>
|
120
|
-
|
121
|
-
<!-- 底部操作区域 -->
|
122
|
-
<div class="selector-footer">
|
123
|
-
<slot name="footer">
|
124
|
-
<div class="legend">
|
125
|
-
<div class="legend-item">
|
126
|
-
<span class="legend-color available"></span>
|
127
|
-
<span>可预约</span>
|
128
|
-
</div>
|
129
|
-
<div class="legend-item">
|
130
|
-
<span class="legend-color booked"></span>
|
131
|
-
<span>已预约</span>
|
132
|
-
</div>
|
133
|
-
<div class="legend-item">
|
134
|
-
<span class="legend-color selected"></span>
|
135
|
-
<span>已选择</span>
|
136
|
-
</div>
|
137
|
-
</div>
|
138
|
-
</slot>
|
139
|
-
</div>
|
140
|
-
</div>
|
141
|
-
</template>
|
142
|
-
|
143
|
-
<script setup lang="ts">
|
144
|
-
import { ref, computed, watch, defineProps, defineEmits } from 'vue'
|
145
|
-
import { DatePicker as TDatePicker, Loading as TLoading, Tag as TTag, Button as TButton } from 'tdesign-vue-next'
|
146
|
-
|
147
|
-
// 组件属性接口
|
148
|
-
interface Room {
|
149
|
-
id: string
|
150
|
-
name: string
|
151
|
-
capacity: number
|
152
|
-
location: string
|
153
|
-
equipment?: string[]
|
154
|
-
}
|
155
|
-
|
156
|
-
interface TimeSlot {
|
157
|
-
value: string
|
158
|
-
label: string
|
159
|
-
hour: number
|
160
|
-
minute: number
|
161
|
-
}
|
162
|
-
|
163
|
-
interface Props {
|
164
|
-
rooms?: Room[]
|
165
|
-
selectedDate?: string
|
166
|
-
timeSlots?: TimeSlot[]
|
167
|
-
bookedSlots?: Record<string, string[]>
|
168
|
-
loading?: boolean
|
169
|
-
disabled?: boolean
|
170
|
-
minDuration?: number
|
171
|
-
maxDuration?: number
|
172
|
-
}
|
173
|
-
|
174
|
-
// 定义属性
|
175
|
-
const props = withDefaults(defineProps<Props>(), {
|
176
|
-
rooms: () => [],
|
177
|
-
selectedDate: "",
|
178
|
-
timeSlots: () => [],
|
179
|
-
bookedSlots: () => ({}),
|
180
|
-
loading: false,
|
181
|
-
disabled: false,
|
182
|
-
minDuration: 1,
|
183
|
-
maxDuration: 8
|
184
|
-
})
|
185
|
-
|
186
|
-
// 定义事件
|
187
|
-
const emit = defineEmits(['room-select', 'time-select', 'booking-confirm', 'date-change'])
|
188
|
-
|
189
|
-
// 响应式数据
|
190
|
-
const currentDate = ref(props.selectedDate || new Date().toISOString().split('T')[0])
|
191
|
-
const selectedRoom = ref<Room | null>(null)
|
192
|
-
const selectedTimeSlots = ref<string[]>([])
|
193
|
-
const selectingStart = ref<string | null>(null)
|
194
|
-
const hoveringSlot = ref<string | null>(null)
|
195
|
-
|
196
|
-
// 计算属性
|
197
|
-
const roomList = computed(() => props.rooms)
|
198
|
-
|
199
|
-
const timeSlotList = computed(() => {
|
200
|
-
if (props.timeSlots.length > 0) {
|
201
|
-
return props.timeSlots
|
202
|
-
}
|
203
|
-
|
204
|
-
// 默认生成9:00-18:00的时间段,每30分钟一个
|
205
|
-
const slots: TimeSlot[] = []
|
206
|
-
for (let hour = 9; hour < 18; hour++) {
|
207
|
-
for (let minute = 0; minute < 60; minute += 30) {
|
208
|
-
const timeValue = `${hour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}`
|
209
|
-
slots.push({
|
210
|
-
value: timeValue,
|
211
|
-
label: timeValue,
|
212
|
-
hour,
|
213
|
-
minute
|
214
|
-
})
|
215
|
-
}
|
216
|
-
}
|
217
|
-
return slots
|
218
|
-
})
|
219
|
-
|
220
|
-
// 辅助方法
|
221
|
-
const getEndTime = (startTime: string): string => {
|
222
|
-
const [hour, minute] = startTime.split(':').map(Number)
|
223
|
-
const endMinute = minute + 30
|
224
|
-
const endHour = endMinute >= 60 ? hour + 1 : hour
|
225
|
-
const finalMinute = endMinute >= 60 ? endMinute - 60 : endMinute
|
226
|
-
|
227
|
-
return `${endHour.toString().padStart(2, '0')}:${finalMinute.toString().padStart(2, '0')}`
|
228
|
-
}
|
229
|
-
|
230
|
-
const clearTimeSelection = () => {
|
231
|
-
selectedTimeSlots.value = []
|
232
|
-
selectingStart.value = null
|
233
|
-
hoveringSlot.value = null
|
234
|
-
}
|
235
|
-
|
236
|
-
const clearSelection = () => {
|
237
|
-
selectedRoom.value = null
|
238
|
-
clearTimeSelection()
|
239
|
-
}
|
240
|
-
|
241
|
-
const isSlotBooked = (roomId: string, timeSlot: string): boolean => {
|
242
|
-
return props.bookedSlots[roomId]?.includes(timeSlot) || false
|
243
|
-
}
|
244
|
-
|
245
|
-
const isSlotSelected = (roomId: string, timeSlot: string): boolean => {
|
246
|
-
return selectedRoom.value?.id === roomId && selectedTimeSlots.value.includes(timeSlot)
|
247
|
-
}
|
248
|
-
|
249
|
-
const isSlotSelecting = (roomId: string, timeSlot: string): boolean => {
|
250
|
-
if (!selectingStart.value || selectedRoom.value?.id !== roomId || !hoveringSlot.value) {
|
251
|
-
return false
|
252
|
-
}
|
253
|
-
|
254
|
-
const startIndex = timeSlotList.value.findIndex(s => s.value === selectingStart.value)
|
255
|
-
const hoverIndex = timeSlotList.value.findIndex(s => s.value === hoveringSlot.value)
|
256
|
-
const currentIndex = timeSlotList.value.findIndex(s => s.value === timeSlot)
|
257
|
-
|
258
|
-
if (startIndex === -1 || hoverIndex === -1 || currentIndex === -1) {
|
259
|
-
return false
|
260
|
-
}
|
261
|
-
|
262
|
-
const minIndex = Math.min(startIndex, hoverIndex)
|
263
|
-
const maxIndex = Math.max(startIndex, hoverIndex)
|
264
|
-
|
265
|
-
return currentIndex >= minIndex && currentIndex <= maxIndex
|
266
|
-
}
|
267
|
-
|
268
|
-
const isSlotDisabled = (_roomId: string, _timeSlot: string): boolean => {
|
269
|
-
// 可以根据业务需求添加更多禁用逻辑
|
270
|
-
return false
|
271
|
-
}
|
272
|
-
|
273
|
-
const formatSelectedTime = (): string => {
|
274
|
-
if (selectedTimeSlots.value.length === 0) return ''
|
275
|
-
|
276
|
-
const sortedSlots = [...selectedTimeSlots.value].sort()
|
277
|
-
const startTime = sortedSlots[0]
|
278
|
-
const endTime = getEndTime(sortedSlots[sortedSlots.length - 1])
|
279
|
-
|
280
|
-
return `${startTime} - ${endTime}`
|
281
|
-
}
|
282
|
-
|
283
|
-
const currentSelection = computed(() => {
|
284
|
-
if (!selectedRoom.value || selectedTimeSlots.value.length === 0) {
|
285
|
-
return null
|
286
|
-
}
|
287
|
-
|
288
|
-
const sortedSlots = [...selectedTimeSlots.value].sort()
|
289
|
-
return {
|
290
|
-
room: selectedRoom.value,
|
291
|
-
date: currentDate.value,
|
292
|
-
startTime: sortedSlots[0],
|
293
|
-
endTime: getEndTime(sortedSlots[sortedSlots.length - 1]),
|
294
|
-
duration: selectedTimeSlots.value.length,
|
295
|
-
timeSlots: sortedSlots
|
296
|
-
}
|
297
|
-
})
|
298
|
-
|
299
|
-
// 事件处理方法
|
300
|
-
const handleDateChange = (date: string) => {
|
301
|
-
currentDate.value = date
|
302
|
-
clearSelection()
|
303
|
-
emit('date-change', date)
|
304
|
-
}
|
305
|
-
|
306
|
-
const handleRoomSelect = (room: Room) => {
|
307
|
-
selectedRoom.value = room
|
308
|
-
clearTimeSelection()
|
309
|
-
emit('room-select', room)
|
310
|
-
}
|
311
|
-
|
312
|
-
const handleTimeSlotClick = (room: Room, slot: TimeSlot) => {
|
313
|
-
if (disabled || isSlotDisabled(room.id, slot.value) || isSlotBooked(room.id, slot.value)) {
|
314
|
-
return
|
315
|
-
}
|
316
|
-
|
317
|
-
// 如果点击的不是当前选中的会议室,先选中会议室
|
318
|
-
if (selectedRoom.value?.id !== room.id) {
|
319
|
-
handleRoomSelect(room)
|
320
|
-
}
|
321
|
-
|
322
|
-
// 处理时间段选择
|
323
|
-
if (!selectingStart.value) {
|
324
|
-
// 开始选择
|
325
|
-
selectingStart.value = slot.value
|
326
|
-
selectedTimeSlots.value = [slot.value]
|
327
|
-
} else {
|
328
|
-
// 完成选择
|
329
|
-
const startIndex = timeSlotList.value.findIndex(s => s.value === selectingStart.value)
|
330
|
-
const endIndex = timeSlotList.value.findIndex(s => s.value === slot.value)
|
331
|
-
|
332
|
-
if (startIndex !== -1 && endIndex !== -1) {
|
333
|
-
const minIndex = Math.min(startIndex, endIndex)
|
334
|
-
const maxIndex = Math.max(startIndex, endIndex)
|
335
|
-
const duration = maxIndex - minIndex + 1
|
336
|
-
|
337
|
-
// 检查时长限制
|
338
|
-
if (duration < props.minDuration || duration > props.maxDuration) {
|
339
|
-
clearTimeSelection()
|
340
|
-
return
|
341
|
-
}
|
342
|
-
|
343
|
-
// 检查选择范围内是否有已预约的时间段
|
344
|
-
const selectedRange = timeSlotList.value.slice(minIndex, maxIndex + 1)
|
345
|
-
const hasBookedSlot = selectedRange.some(s => isSlotBooked(room.id, s.value))
|
346
|
-
|
347
|
-
if (hasBookedSlot) {
|
348
|
-
clearTimeSelection()
|
349
|
-
return
|
350
|
-
}
|
351
|
-
|
352
|
-
selectedTimeSlots.value = selectedRange.map(s => s.value)
|
353
|
-
selectingStart.value = null
|
354
|
-
|
355
|
-
emit('time-select', currentSelection.value)
|
356
|
-
}
|
357
|
-
}
|
358
|
-
}
|
359
|
-
|
360
|
-
const handleTimeSlotHover = (room: Room, slot: TimeSlot) => {
|
361
|
-
if (!selectingStart.value || selectedRoom.value?.id !== room.id) {
|
362
|
-
return
|
363
|
-
}
|
364
|
-
|
365
|
-
hoveringSlot.value = slot.value
|
366
|
-
}
|
367
|
-
|
368
|
-
const handleTimeSlotLeave = () => {
|
369
|
-
hoveringSlot.value = null
|
370
|
-
}
|
371
|
-
|
372
|
-
const handleConfirmBooking = () => {
|
373
|
-
if (currentSelection.value) {
|
374
|
-
emit('booking-confirm', currentSelection.value)
|
375
|
-
clearSelection()
|
376
|
-
}
|
377
|
-
}
|
378
|
-
|
379
|
-
const handleCancelSelection = () => {
|
380
|
-
clearSelection()
|
381
|
-
}
|
382
|
-
|
383
|
-
// 监听属性变化
|
384
|
-
watch(() => props.selectedDate, (newDate) => {
|
385
|
-
if (newDate && newDate !== currentDate.value) {
|
386
|
-
currentDate.value = newDate
|
387
|
-
clearSelection()
|
388
|
-
}
|
389
|
-
})
|
390
|
-
|
391
|
-
// 暴露组件实例方法
|
392
|
-
defineExpose({
|
393
|
-
clearSelection,
|
394
|
-
clearTimeSelection,
|
395
|
-
getCurrentSelection: () => currentSelection.value
|
396
|
-
})
|
397
|
-
</script>
|
398
|
-
|
399
|
-
<style scoped>
|
400
|
-
.ebiz-meeting-room-selector {
|
401
|
-
background: #fff;
|
402
|
-
border-radius: 8px;
|
403
|
-
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
404
|
-
overflow: hidden;
|
405
|
-
}
|
406
|
-
|
407
|
-
.selector-header {
|
408
|
-
padding: 20px;
|
409
|
-
border-bottom: 1px solid #e7e7e7;
|
410
|
-
background: #fafafa;
|
411
|
-
}
|
412
|
-
|
413
|
-
.header-content {
|
414
|
-
display: flex;
|
415
|
-
justify-content: space-between;
|
416
|
-
align-items: center;
|
417
|
-
}
|
418
|
-
|
419
|
-
.title {
|
420
|
-
margin: 0;
|
421
|
-
font-size: 18px;
|
422
|
-
font-weight: 600;
|
423
|
-
color: #333;
|
424
|
-
}
|
425
|
-
|
426
|
-
.date-selector {
|
427
|
-
display: flex;
|
428
|
-
align-items: center;
|
429
|
-
gap: 8px;
|
430
|
-
}
|
431
|
-
|
432
|
-
.date-selector label {
|
433
|
-
font-weight: 500;
|
434
|
-
color: #666;
|
435
|
-
}
|
436
|
-
|
437
|
-
.loading-container {
|
438
|
-
padding: 60px;
|
439
|
-
text-align: center;
|
440
|
-
}
|
441
|
-
|
442
|
-
.selector-content {
|
443
|
-
overflow-x: auto;
|
444
|
-
}
|
445
|
-
|
446
|
-
.time-header {
|
447
|
-
display: flex;
|
448
|
-
background: #f5f5f5;
|
449
|
-
border-bottom: 2px solid #e7e7e7;
|
450
|
-
position: sticky;
|
451
|
-
top: 0;
|
452
|
-
z-index: 10;
|
453
|
-
}
|
454
|
-
|
455
|
-
.room-column-header {
|
456
|
-
width: 280px;
|
457
|
-
min-width: 280px;
|
458
|
-
padding: 12px 16px;
|
459
|
-
font-weight: 600;
|
460
|
-
color: #333;
|
461
|
-
border-right: 1px solid #e7e7e7;
|
462
|
-
background: #f5f5f5;
|
463
|
-
}
|
464
|
-
|
465
|
-
.time-slots-header {
|
466
|
-
display: flex;
|
467
|
-
flex: 1;
|
468
|
-
}
|
469
|
-
|
470
|
-
.time-slot-header {
|
471
|
-
width: 80px;
|
472
|
-
min-width: 80px;
|
473
|
-
padding: 12px 8px;
|
474
|
-
text-align: center;
|
475
|
-
font-size: 12px;
|
476
|
-
font-weight: 500;
|
477
|
-
color: #666;
|
478
|
-
border-right: 1px solid #e7e7e7;
|
479
|
-
}
|
480
|
-
|
481
|
-
.rooms-container {
|
482
|
-
max-height: 600px;
|
483
|
-
overflow-y: auto;
|
484
|
-
}
|
485
|
-
|
486
|
-
.room-row {
|
487
|
-
display: flex;
|
488
|
-
border-bottom: 1px solid #e7e7e7;
|
489
|
-
transition: background-color 0.2s;
|
490
|
-
}
|
491
|
-
|
492
|
-
.room-row:hover {
|
493
|
-
background: #f9f9f9;
|
494
|
-
}
|
495
|
-
|
496
|
-
.room-row.selected {
|
497
|
-
background: #e6f7ff;
|
498
|
-
}
|
499
|
-
|
500
|
-
.room-info {
|
501
|
-
width: 280px;
|
502
|
-
min-width: 280px;
|
503
|
-
padding: 16px;
|
504
|
-
border-right: 1px solid #e7e7e7;
|
505
|
-
cursor: pointer;
|
506
|
-
transition: background-color 0.2s;
|
507
|
-
}
|
508
|
-
|
509
|
-
.room-info:hover {
|
510
|
-
background: rgba(24, 144, 255, 0.05);
|
511
|
-
}
|
512
|
-
|
513
|
-
.room-basic-info {
|
514
|
-
height: 100%;
|
515
|
-
}
|
516
|
-
|
517
|
-
.room-name {
|
518
|
-
margin: 0 0 8px 0;
|
519
|
-
font-size: 16px;
|
520
|
-
font-weight: 600;
|
521
|
-
color: #333;
|
522
|
-
}
|
523
|
-
|
524
|
-
.room-details {
|
525
|
-
margin: 0 0 8px 0;
|
526
|
-
font-size: 14px;
|
527
|
-
color: #666;
|
528
|
-
line-height: 1.4;
|
529
|
-
}
|
530
|
-
|
531
|
-
.room-details span {
|
532
|
-
display: block;
|
533
|
-
}
|
534
|
-
|
535
|
-
.equipment {
|
536
|
-
display: flex;
|
537
|
-
flex-wrap: wrap;
|
538
|
-
gap: 4px;
|
539
|
-
}
|
540
|
-
|
541
|
-
.time-slots-grid {
|
542
|
-
display: flex;
|
543
|
-
flex: 1;
|
544
|
-
}
|
545
|
-
|
546
|
-
.time-slot {
|
547
|
-
width: 80px;
|
548
|
-
min-width: 80px;
|
549
|
-
height: 80px;
|
550
|
-
border-right: 1px solid #e7e7e7;
|
551
|
-
cursor: pointer;
|
552
|
-
transition: all 0.2s;
|
553
|
-
position: relative;
|
554
|
-
display: flex;
|
555
|
-
align-items: center;
|
556
|
-
justify-content: center;
|
557
|
-
}
|
558
|
-
|
559
|
-
.time-slot:hover:not(.booked):not(.disabled) {
|
560
|
-
background: rgba(24, 144, 255, 0.1);
|
561
|
-
}
|
562
|
-
|
563
|
-
.time-slot.booked {
|
564
|
-
background: #f5f5f5;
|
565
|
-
cursor: not-allowed;
|
566
|
-
}
|
567
|
-
|
568
|
-
.time-slot.selected {
|
569
|
-
background: #1890ff;
|
570
|
-
color: white;
|
571
|
-
}
|
572
|
-
|
573
|
-
.time-slot.selecting {
|
574
|
-
background: rgba(24, 144, 255, 0.3);
|
575
|
-
}
|
576
|
-
|
577
|
-
.time-slot.disabled {
|
578
|
-
background: #f0f0f0;
|
579
|
-
cursor: not-allowed;
|
580
|
-
opacity: 0.5;
|
581
|
-
}
|
582
|
-
|
583
|
-
.slot-content {
|
584
|
-
font-size: 12px;
|
585
|
-
text-align: center;
|
586
|
-
}
|
587
|
-
|
588
|
-
.booked-indicator {
|
589
|
-
color: #999;
|
590
|
-
font-weight: 500;
|
591
|
-
}
|
592
|
-
|
593
|
-
.selected-indicator {
|
594
|
-
color: white;
|
595
|
-
font-weight: 500;
|
596
|
-
}
|
597
|
-
|
598
|
-
.booking-panel {
|
599
|
-
padding: 20px;
|
600
|
-
background: #f9f9f9;
|
601
|
-
border-top: 1px solid #e7e7e7;
|
602
|
-
}
|
603
|
-
|
604
|
-
.booking-form h4 {
|
605
|
-
margin: 0 0 16px 0;
|
606
|
-
font-size: 16px;
|
607
|
-
font-weight: 600;
|
608
|
-
color: #333;
|
609
|
-
}
|
610
|
-
|
611
|
-
.booking-info {
|
612
|
-
margin-bottom: 16px;
|
613
|
-
}
|
614
|
-
|
615
|
-
.booking-info p {
|
616
|
-
margin: 0 0 8px 0;
|
617
|
-
font-size: 14px;
|
618
|
-
color: #666;
|
619
|
-
}
|
620
|
-
|
621
|
-
.booking-actions {
|
622
|
-
display: flex;
|
623
|
-
gap: 12px;
|
624
|
-
justify-content: flex-end;
|
625
|
-
}
|
626
|
-
|
627
|
-
.selector-footer {
|
628
|
-
padding: 16px 20px;
|
629
|
-
background: #fafafa;
|
630
|
-
border-top: 1px solid #e7e7e7;
|
631
|
-
}
|
632
|
-
|
633
|
-
.legend {
|
634
|
-
display: flex;
|
635
|
-
gap: 24px;
|
636
|
-
justify-content: center;
|
637
|
-
}
|
638
|
-
|
639
|
-
.legend-item {
|
640
|
-
display: flex;
|
641
|
-
align-items: center;
|
642
|
-
gap: 8px;
|
643
|
-
font-size: 14px;
|
644
|
-
color: #666;
|
645
|
-
}
|
646
|
-
|
647
|
-
.legend-color {
|
648
|
-
width: 16px;
|
649
|
-
height: 16px;
|
650
|
-
border-radius: 2px;
|
651
|
-
border: 1px solid #e7e7e7;
|
652
|
-
}
|
653
|
-
|
654
|
-
.legend-color.available {
|
655
|
-
background: white;
|
656
|
-
}
|
657
|
-
|
658
|
-
.legend-color.booked {
|
659
|
-
background: #f5f5f5;
|
660
|
-
}
|
661
|
-
|
662
|
-
.legend-color.selected {
|
663
|
-
background: #1890ff;
|
664
|
-
}
|
1
|
+
<template>
|
2
|
+
<div class="ebiz-meeting-room-selector">
|
3
|
+
<!-- 头部区域 -->
|
4
|
+
<div class="selector-header">
|
5
|
+
<slot name="header">
|
6
|
+
<div class="header-content">
|
7
|
+
<h3 class="title">会议室预约</h3>
|
8
|
+
<div class="date-selector">
|
9
|
+
<label>选择日期:</label>
|
10
|
+
<t-date-picker
|
11
|
+
v-model="currentDate"
|
12
|
+
:disabled="disabled"
|
13
|
+
:min-date="new Date()"
|
14
|
+
format="YYYY-MM-DD"
|
15
|
+
@change="handleDateChange"
|
16
|
+
/>
|
17
|
+
</div>
|
18
|
+
</div>
|
19
|
+
</slot>
|
20
|
+
</div>
|
21
|
+
|
22
|
+
<!-- 加载状态 -->
|
23
|
+
<div v-if="loading" class="loading-container">
|
24
|
+
<t-loading size="large" text="加载中..." />
|
25
|
+
</div>
|
26
|
+
|
27
|
+
<!-- 主要内容区域 -->
|
28
|
+
<div v-else class="selector-content">
|
29
|
+
<!-- 时间轴表头 -->
|
30
|
+
<div class="time-header">
|
31
|
+
<div class="room-column-header">会议室</div>
|
32
|
+
<div class="time-slots-header">
|
33
|
+
<div
|
34
|
+
v-for="slot in timeSlotList"
|
35
|
+
:key="slot.value"
|
36
|
+
class="time-slot-header"
|
37
|
+
>
|
38
|
+
{{ slot.label }}
|
39
|
+
</div>
|
40
|
+
</div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<!-- 会议室列表 -->
|
44
|
+
<div class="rooms-container">
|
45
|
+
<div
|
46
|
+
v-for="room in roomList"
|
47
|
+
:key="room.id"
|
48
|
+
class="room-row"
|
49
|
+
:class="{ 'selected': selectedRoom?.id === room.id }"
|
50
|
+
>
|
51
|
+
<!-- 会议室信息 -->
|
52
|
+
<div class="room-info" @click="handleRoomSelect(room)">
|
53
|
+
<slot name="room-info" :room="room">
|
54
|
+
<div class="room-basic-info">
|
55
|
+
<h4 class="room-name">{{ room.name }}</h4>
|
56
|
+
<p class="room-details">
|
57
|
+
<span class="capacity">容量: {{ room.capacity }}人</span>
|
58
|
+
<span class="location">位置: {{ room.location }}</span>
|
59
|
+
</p>
|
60
|
+
<div v-if="room.equipment?.length" class="equipment">
|
61
|
+
<t-tag
|
62
|
+
v-for="item in room.equipment"
|
63
|
+
:key="item"
|
64
|
+
size="small"
|
65
|
+
variant="light"
|
66
|
+
>
|
67
|
+
{{ item }}
|
68
|
+
</t-tag>
|
69
|
+
</div>
|
70
|
+
</div>
|
71
|
+
</slot>
|
72
|
+
</div>
|
73
|
+
|
74
|
+
<!-- 时间段网格 -->
|
75
|
+
<div class="time-slots-grid">
|
76
|
+
<div
|
77
|
+
v-for="slot in timeSlotList"
|
78
|
+
:key="slot.value"
|
79
|
+
class="time-slot"
|
80
|
+
:class="{
|
81
|
+
'booked': isSlotBooked(room.id, slot.value),
|
82
|
+
'selected': isSlotSelected(room.id, slot.value),
|
83
|
+
'selecting': isSlotSelecting(room.id, slot.value),
|
84
|
+
'disabled': disabled || isSlotDisabled(room.id, slot.value)
|
85
|
+
}"
|
86
|
+
@click="handleTimeSlotClick(room, slot)"
|
87
|
+
@mouseenter="handleTimeSlotHover(room, slot)"
|
88
|
+
@mouseleave="handleTimeSlotLeave()"
|
89
|
+
>
|
90
|
+
<slot name="time-slot" :room="room" :slot="slot" :is-booked="isSlotBooked(room.id, slot.value)">
|
91
|
+
<div class="slot-content">
|
92
|
+
<span v-if="isSlotBooked(room.id, slot.value)" class="booked-indicator">已约</span>
|
93
|
+
<span v-else-if="isSlotSelected(room.id, slot.value)" class="selected-indicator">已选</span>
|
94
|
+
</div>
|
95
|
+
</slot>
|
96
|
+
</div>
|
97
|
+
</div>
|
98
|
+
</div>
|
99
|
+
</div>
|
100
|
+
</div>
|
101
|
+
|
102
|
+
<!-- 预约确认区域 -->
|
103
|
+
<div v-if="selectedTimeSlots.length > 0" class="booking-panel">
|
104
|
+
<slot name="booking-form" :selection="currentSelection">
|
105
|
+
<div class="booking-form">
|
106
|
+
<h4>预约确认</h4>
|
107
|
+
<div class="booking-info">
|
108
|
+
<p><strong>会议室:</strong>{{ selectedRoom?.name }}</p>
|
109
|
+
<p><strong>日期:</strong>{{ currentDate }}</p>
|
110
|
+
<p><strong>时间:</strong>{{ formatSelectedTime() }}</p>
|
111
|
+
<p><strong>时长:</strong>{{ selectedTimeSlots.length * 0.5 }}小时</p>
|
112
|
+
</div>
|
113
|
+
<div class="booking-actions">
|
114
|
+
<t-button variant="outline" @click="handleCancelSelection">取消</t-button>
|
115
|
+
<t-button theme="primary" @click="handleConfirmBooking">确认预约</t-button>
|
116
|
+
</div>
|
117
|
+
</div>
|
118
|
+
</slot>
|
119
|
+
</div>
|
120
|
+
|
121
|
+
<!-- 底部操作区域 -->
|
122
|
+
<div class="selector-footer">
|
123
|
+
<slot name="footer">
|
124
|
+
<div class="legend">
|
125
|
+
<div class="legend-item">
|
126
|
+
<span class="legend-color available"></span>
|
127
|
+
<span>可预约</span>
|
128
|
+
</div>
|
129
|
+
<div class="legend-item">
|
130
|
+
<span class="legend-color booked"></span>
|
131
|
+
<span>已预约</span>
|
132
|
+
</div>
|
133
|
+
<div class="legend-item">
|
134
|
+
<span class="legend-color selected"></span>
|
135
|
+
<span>已选择</span>
|
136
|
+
</div>
|
137
|
+
</div>
|
138
|
+
</slot>
|
139
|
+
</div>
|
140
|
+
</div>
|
141
|
+
</template>
|
142
|
+
|
143
|
+
<script setup lang="ts">
|
144
|
+
import { ref, computed, watch, defineProps, defineEmits } from 'vue'
|
145
|
+
import { DatePicker as TDatePicker, Loading as TLoading, Tag as TTag, Button as TButton } from 'tdesign-vue-next'
|
146
|
+
|
147
|
+
// 组件属性接口
|
148
|
+
interface Room {
|
149
|
+
id: string
|
150
|
+
name: string
|
151
|
+
capacity: number
|
152
|
+
location: string
|
153
|
+
equipment?: string[]
|
154
|
+
}
|
155
|
+
|
156
|
+
interface TimeSlot {
|
157
|
+
value: string
|
158
|
+
label: string
|
159
|
+
hour: number
|
160
|
+
minute: number
|
161
|
+
}
|
162
|
+
|
163
|
+
interface Props {
|
164
|
+
rooms?: Room[]
|
165
|
+
selectedDate?: string
|
166
|
+
timeSlots?: TimeSlot[]
|
167
|
+
bookedSlots?: Record<string, string[]>
|
168
|
+
loading?: boolean
|
169
|
+
disabled?: boolean
|
170
|
+
minDuration?: number
|
171
|
+
maxDuration?: number
|
172
|
+
}
|
173
|
+
|
174
|
+
// 定义属性
|
175
|
+
const props = withDefaults(defineProps<Props>(), {
|
176
|
+
rooms: () => [],
|
177
|
+
selectedDate: "",
|
178
|
+
timeSlots: () => [],
|
179
|
+
bookedSlots: () => ({}),
|
180
|
+
loading: false,
|
181
|
+
disabled: false,
|
182
|
+
minDuration: 1,
|
183
|
+
maxDuration: 8
|
184
|
+
})
|
185
|
+
|
186
|
+
// 定义事件
|
187
|
+
const emit = defineEmits(['room-select', 'time-select', 'booking-confirm', 'date-change'])
|
188
|
+
|
189
|
+
// 响应式数据
|
190
|
+
const currentDate = ref(props.selectedDate || new Date().toISOString().split('T')[0])
|
191
|
+
const selectedRoom = ref<Room | null>(null)
|
192
|
+
const selectedTimeSlots = ref<string[]>([])
|
193
|
+
const selectingStart = ref<string | null>(null)
|
194
|
+
const hoveringSlot = ref<string | null>(null)
|
195
|
+
|
196
|
+
// 计算属性
|
197
|
+
const roomList = computed(() => props.rooms)
|
198
|
+
|
199
|
+
const timeSlotList = computed(() => {
|
200
|
+
if (props.timeSlots.length > 0) {
|
201
|
+
return props.timeSlots
|
202
|
+
}
|
203
|
+
|
204
|
+
// 默认生成9:00-18:00的时间段,每30分钟一个
|
205
|
+
const slots: TimeSlot[] = []
|
206
|
+
for (let hour = 9; hour < 18; hour++) {
|
207
|
+
for (let minute = 0; minute < 60; minute += 30) {
|
208
|
+
const timeValue = `${hour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}`
|
209
|
+
slots.push({
|
210
|
+
value: timeValue,
|
211
|
+
label: timeValue,
|
212
|
+
hour,
|
213
|
+
minute
|
214
|
+
})
|
215
|
+
}
|
216
|
+
}
|
217
|
+
return slots
|
218
|
+
})
|
219
|
+
|
220
|
+
// 辅助方法
|
221
|
+
const getEndTime = (startTime: string): string => {
|
222
|
+
const [hour, minute] = startTime.split(':').map(Number)
|
223
|
+
const endMinute = minute + 30
|
224
|
+
const endHour = endMinute >= 60 ? hour + 1 : hour
|
225
|
+
const finalMinute = endMinute >= 60 ? endMinute - 60 : endMinute
|
226
|
+
|
227
|
+
return `${endHour.toString().padStart(2, '0')}:${finalMinute.toString().padStart(2, '0')}`
|
228
|
+
}
|
229
|
+
|
230
|
+
const clearTimeSelection = () => {
|
231
|
+
selectedTimeSlots.value = []
|
232
|
+
selectingStart.value = null
|
233
|
+
hoveringSlot.value = null
|
234
|
+
}
|
235
|
+
|
236
|
+
const clearSelection = () => {
|
237
|
+
selectedRoom.value = null
|
238
|
+
clearTimeSelection()
|
239
|
+
}
|
240
|
+
|
241
|
+
const isSlotBooked = (roomId: string, timeSlot: string): boolean => {
|
242
|
+
return props.bookedSlots[roomId]?.includes(timeSlot) || false
|
243
|
+
}
|
244
|
+
|
245
|
+
const isSlotSelected = (roomId: string, timeSlot: string): boolean => {
|
246
|
+
return selectedRoom.value?.id === roomId && selectedTimeSlots.value.includes(timeSlot)
|
247
|
+
}
|
248
|
+
|
249
|
+
const isSlotSelecting = (roomId: string, timeSlot: string): boolean => {
|
250
|
+
if (!selectingStart.value || selectedRoom.value?.id !== roomId || !hoveringSlot.value) {
|
251
|
+
return false
|
252
|
+
}
|
253
|
+
|
254
|
+
const startIndex = timeSlotList.value.findIndex(s => s.value === selectingStart.value)
|
255
|
+
const hoverIndex = timeSlotList.value.findIndex(s => s.value === hoveringSlot.value)
|
256
|
+
const currentIndex = timeSlotList.value.findIndex(s => s.value === timeSlot)
|
257
|
+
|
258
|
+
if (startIndex === -1 || hoverIndex === -1 || currentIndex === -1) {
|
259
|
+
return false
|
260
|
+
}
|
261
|
+
|
262
|
+
const minIndex = Math.min(startIndex, hoverIndex)
|
263
|
+
const maxIndex = Math.max(startIndex, hoverIndex)
|
264
|
+
|
265
|
+
return currentIndex >= minIndex && currentIndex <= maxIndex
|
266
|
+
}
|
267
|
+
|
268
|
+
const isSlotDisabled = (_roomId: string, _timeSlot: string): boolean => {
|
269
|
+
// 可以根据业务需求添加更多禁用逻辑
|
270
|
+
return false
|
271
|
+
}
|
272
|
+
|
273
|
+
const formatSelectedTime = (): string => {
|
274
|
+
if (selectedTimeSlots.value.length === 0) return ''
|
275
|
+
|
276
|
+
const sortedSlots = [...selectedTimeSlots.value].sort()
|
277
|
+
const startTime = sortedSlots[0]
|
278
|
+
const endTime = getEndTime(sortedSlots[sortedSlots.length - 1])
|
279
|
+
|
280
|
+
return `${startTime} - ${endTime}`
|
281
|
+
}
|
282
|
+
|
283
|
+
const currentSelection = computed(() => {
|
284
|
+
if (!selectedRoom.value || selectedTimeSlots.value.length === 0) {
|
285
|
+
return null
|
286
|
+
}
|
287
|
+
|
288
|
+
const sortedSlots = [...selectedTimeSlots.value].sort()
|
289
|
+
return {
|
290
|
+
room: selectedRoom.value,
|
291
|
+
date: currentDate.value,
|
292
|
+
startTime: sortedSlots[0],
|
293
|
+
endTime: getEndTime(sortedSlots[sortedSlots.length - 1]),
|
294
|
+
duration: selectedTimeSlots.value.length,
|
295
|
+
timeSlots: sortedSlots
|
296
|
+
}
|
297
|
+
})
|
298
|
+
|
299
|
+
// 事件处理方法
|
300
|
+
const handleDateChange = (date: string) => {
|
301
|
+
currentDate.value = date
|
302
|
+
clearSelection()
|
303
|
+
emit('date-change', date)
|
304
|
+
}
|
305
|
+
|
306
|
+
const handleRoomSelect = (room: Room) => {
|
307
|
+
selectedRoom.value = room
|
308
|
+
clearTimeSelection()
|
309
|
+
emit('room-select', room)
|
310
|
+
}
|
311
|
+
|
312
|
+
const handleTimeSlotClick = (room: Room, slot: TimeSlot) => {
|
313
|
+
if (disabled || isSlotDisabled(room.id, slot.value) || isSlotBooked(room.id, slot.value)) {
|
314
|
+
return
|
315
|
+
}
|
316
|
+
|
317
|
+
// 如果点击的不是当前选中的会议室,先选中会议室
|
318
|
+
if (selectedRoom.value?.id !== room.id) {
|
319
|
+
handleRoomSelect(room)
|
320
|
+
}
|
321
|
+
|
322
|
+
// 处理时间段选择
|
323
|
+
if (!selectingStart.value) {
|
324
|
+
// 开始选择
|
325
|
+
selectingStart.value = slot.value
|
326
|
+
selectedTimeSlots.value = [slot.value]
|
327
|
+
} else {
|
328
|
+
// 完成选择
|
329
|
+
const startIndex = timeSlotList.value.findIndex(s => s.value === selectingStart.value)
|
330
|
+
const endIndex = timeSlotList.value.findIndex(s => s.value === slot.value)
|
331
|
+
|
332
|
+
if (startIndex !== -1 && endIndex !== -1) {
|
333
|
+
const minIndex = Math.min(startIndex, endIndex)
|
334
|
+
const maxIndex = Math.max(startIndex, endIndex)
|
335
|
+
const duration = maxIndex - minIndex + 1
|
336
|
+
|
337
|
+
// 检查时长限制
|
338
|
+
if (duration < props.minDuration || duration > props.maxDuration) {
|
339
|
+
clearTimeSelection()
|
340
|
+
return
|
341
|
+
}
|
342
|
+
|
343
|
+
// 检查选择范围内是否有已预约的时间段
|
344
|
+
const selectedRange = timeSlotList.value.slice(minIndex, maxIndex + 1)
|
345
|
+
const hasBookedSlot = selectedRange.some(s => isSlotBooked(room.id, s.value))
|
346
|
+
|
347
|
+
if (hasBookedSlot) {
|
348
|
+
clearTimeSelection()
|
349
|
+
return
|
350
|
+
}
|
351
|
+
|
352
|
+
selectedTimeSlots.value = selectedRange.map(s => s.value)
|
353
|
+
selectingStart.value = null
|
354
|
+
|
355
|
+
emit('time-select', currentSelection.value)
|
356
|
+
}
|
357
|
+
}
|
358
|
+
}
|
359
|
+
|
360
|
+
const handleTimeSlotHover = (room: Room, slot: TimeSlot) => {
|
361
|
+
if (!selectingStart.value || selectedRoom.value?.id !== room.id) {
|
362
|
+
return
|
363
|
+
}
|
364
|
+
|
365
|
+
hoveringSlot.value = slot.value
|
366
|
+
}
|
367
|
+
|
368
|
+
const handleTimeSlotLeave = () => {
|
369
|
+
hoveringSlot.value = null
|
370
|
+
}
|
371
|
+
|
372
|
+
const handleConfirmBooking = () => {
|
373
|
+
if (currentSelection.value) {
|
374
|
+
emit('booking-confirm', currentSelection.value)
|
375
|
+
clearSelection()
|
376
|
+
}
|
377
|
+
}
|
378
|
+
|
379
|
+
const handleCancelSelection = () => {
|
380
|
+
clearSelection()
|
381
|
+
}
|
382
|
+
|
383
|
+
// 监听属性变化
|
384
|
+
watch(() => props.selectedDate, (newDate) => {
|
385
|
+
if (newDate && newDate !== currentDate.value) {
|
386
|
+
currentDate.value = newDate
|
387
|
+
clearSelection()
|
388
|
+
}
|
389
|
+
})
|
390
|
+
|
391
|
+
// 暴露组件实例方法
|
392
|
+
defineExpose({
|
393
|
+
clearSelection,
|
394
|
+
clearTimeSelection,
|
395
|
+
getCurrentSelection: () => currentSelection.value
|
396
|
+
})
|
397
|
+
</script>
|
398
|
+
|
399
|
+
<style scoped>
|
400
|
+
.ebiz-meeting-room-selector {
|
401
|
+
background: #fff;
|
402
|
+
border-radius: 8px;
|
403
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
404
|
+
overflow: hidden;
|
405
|
+
}
|
406
|
+
|
407
|
+
.selector-header {
|
408
|
+
padding: 20px;
|
409
|
+
border-bottom: 1px solid #e7e7e7;
|
410
|
+
background: #fafafa;
|
411
|
+
}
|
412
|
+
|
413
|
+
.header-content {
|
414
|
+
display: flex;
|
415
|
+
justify-content: space-between;
|
416
|
+
align-items: center;
|
417
|
+
}
|
418
|
+
|
419
|
+
.title {
|
420
|
+
margin: 0;
|
421
|
+
font-size: 18px;
|
422
|
+
font-weight: 600;
|
423
|
+
color: #333;
|
424
|
+
}
|
425
|
+
|
426
|
+
.date-selector {
|
427
|
+
display: flex;
|
428
|
+
align-items: center;
|
429
|
+
gap: 8px;
|
430
|
+
}
|
431
|
+
|
432
|
+
.date-selector label {
|
433
|
+
font-weight: 500;
|
434
|
+
color: #666;
|
435
|
+
}
|
436
|
+
|
437
|
+
.loading-container {
|
438
|
+
padding: 60px;
|
439
|
+
text-align: center;
|
440
|
+
}
|
441
|
+
|
442
|
+
.selector-content {
|
443
|
+
overflow-x: auto;
|
444
|
+
}
|
445
|
+
|
446
|
+
.time-header {
|
447
|
+
display: flex;
|
448
|
+
background: #f5f5f5;
|
449
|
+
border-bottom: 2px solid #e7e7e7;
|
450
|
+
position: sticky;
|
451
|
+
top: 0;
|
452
|
+
z-index: 10;
|
453
|
+
}
|
454
|
+
|
455
|
+
.room-column-header {
|
456
|
+
width: 280px;
|
457
|
+
min-width: 280px;
|
458
|
+
padding: 12px 16px;
|
459
|
+
font-weight: 600;
|
460
|
+
color: #333;
|
461
|
+
border-right: 1px solid #e7e7e7;
|
462
|
+
background: #f5f5f5;
|
463
|
+
}
|
464
|
+
|
465
|
+
.time-slots-header {
|
466
|
+
display: flex;
|
467
|
+
flex: 1;
|
468
|
+
}
|
469
|
+
|
470
|
+
.time-slot-header {
|
471
|
+
width: 80px;
|
472
|
+
min-width: 80px;
|
473
|
+
padding: 12px 8px;
|
474
|
+
text-align: center;
|
475
|
+
font-size: 12px;
|
476
|
+
font-weight: 500;
|
477
|
+
color: #666;
|
478
|
+
border-right: 1px solid #e7e7e7;
|
479
|
+
}
|
480
|
+
|
481
|
+
.rooms-container {
|
482
|
+
max-height: 600px;
|
483
|
+
overflow-y: auto;
|
484
|
+
}
|
485
|
+
|
486
|
+
.room-row {
|
487
|
+
display: flex;
|
488
|
+
border-bottom: 1px solid #e7e7e7;
|
489
|
+
transition: background-color 0.2s;
|
490
|
+
}
|
491
|
+
|
492
|
+
.room-row:hover {
|
493
|
+
background: #f9f9f9;
|
494
|
+
}
|
495
|
+
|
496
|
+
.room-row.selected {
|
497
|
+
background: #e6f7ff;
|
498
|
+
}
|
499
|
+
|
500
|
+
.room-info {
|
501
|
+
width: 280px;
|
502
|
+
min-width: 280px;
|
503
|
+
padding: 16px;
|
504
|
+
border-right: 1px solid #e7e7e7;
|
505
|
+
cursor: pointer;
|
506
|
+
transition: background-color 0.2s;
|
507
|
+
}
|
508
|
+
|
509
|
+
.room-info:hover {
|
510
|
+
background: rgba(24, 144, 255, 0.05);
|
511
|
+
}
|
512
|
+
|
513
|
+
.room-basic-info {
|
514
|
+
height: 100%;
|
515
|
+
}
|
516
|
+
|
517
|
+
.room-name {
|
518
|
+
margin: 0 0 8px 0;
|
519
|
+
font-size: 16px;
|
520
|
+
font-weight: 600;
|
521
|
+
color: #333;
|
522
|
+
}
|
523
|
+
|
524
|
+
.room-details {
|
525
|
+
margin: 0 0 8px 0;
|
526
|
+
font-size: 14px;
|
527
|
+
color: #666;
|
528
|
+
line-height: 1.4;
|
529
|
+
}
|
530
|
+
|
531
|
+
.room-details span {
|
532
|
+
display: block;
|
533
|
+
}
|
534
|
+
|
535
|
+
.equipment {
|
536
|
+
display: flex;
|
537
|
+
flex-wrap: wrap;
|
538
|
+
gap: 4px;
|
539
|
+
}
|
540
|
+
|
541
|
+
.time-slots-grid {
|
542
|
+
display: flex;
|
543
|
+
flex: 1;
|
544
|
+
}
|
545
|
+
|
546
|
+
.time-slot {
|
547
|
+
width: 80px;
|
548
|
+
min-width: 80px;
|
549
|
+
height: 80px;
|
550
|
+
border-right: 1px solid #e7e7e7;
|
551
|
+
cursor: pointer;
|
552
|
+
transition: all 0.2s;
|
553
|
+
position: relative;
|
554
|
+
display: flex;
|
555
|
+
align-items: center;
|
556
|
+
justify-content: center;
|
557
|
+
}
|
558
|
+
|
559
|
+
.time-slot:hover:not(.booked):not(.disabled) {
|
560
|
+
background: rgba(24, 144, 255, 0.1);
|
561
|
+
}
|
562
|
+
|
563
|
+
.time-slot.booked {
|
564
|
+
background: #f5f5f5;
|
565
|
+
cursor: not-allowed;
|
566
|
+
}
|
567
|
+
|
568
|
+
.time-slot.selected {
|
569
|
+
background: #1890ff;
|
570
|
+
color: white;
|
571
|
+
}
|
572
|
+
|
573
|
+
.time-slot.selecting {
|
574
|
+
background: rgba(24, 144, 255, 0.3);
|
575
|
+
}
|
576
|
+
|
577
|
+
.time-slot.disabled {
|
578
|
+
background: #f0f0f0;
|
579
|
+
cursor: not-allowed;
|
580
|
+
opacity: 0.5;
|
581
|
+
}
|
582
|
+
|
583
|
+
.slot-content {
|
584
|
+
font-size: 12px;
|
585
|
+
text-align: center;
|
586
|
+
}
|
587
|
+
|
588
|
+
.booked-indicator {
|
589
|
+
color: #999;
|
590
|
+
font-weight: 500;
|
591
|
+
}
|
592
|
+
|
593
|
+
.selected-indicator {
|
594
|
+
color: white;
|
595
|
+
font-weight: 500;
|
596
|
+
}
|
597
|
+
|
598
|
+
.booking-panel {
|
599
|
+
padding: 20px;
|
600
|
+
background: #f9f9f9;
|
601
|
+
border-top: 1px solid #e7e7e7;
|
602
|
+
}
|
603
|
+
|
604
|
+
.booking-form h4 {
|
605
|
+
margin: 0 0 16px 0;
|
606
|
+
font-size: 16px;
|
607
|
+
font-weight: 600;
|
608
|
+
color: #333;
|
609
|
+
}
|
610
|
+
|
611
|
+
.booking-info {
|
612
|
+
margin-bottom: 16px;
|
613
|
+
}
|
614
|
+
|
615
|
+
.booking-info p {
|
616
|
+
margin: 0 0 8px 0;
|
617
|
+
font-size: 14px;
|
618
|
+
color: #666;
|
619
|
+
}
|
620
|
+
|
621
|
+
.booking-actions {
|
622
|
+
display: flex;
|
623
|
+
gap: 12px;
|
624
|
+
justify-content: flex-end;
|
625
|
+
}
|
626
|
+
|
627
|
+
.selector-footer {
|
628
|
+
padding: 16px 20px;
|
629
|
+
background: #fafafa;
|
630
|
+
border-top: 1px solid #e7e7e7;
|
631
|
+
}
|
632
|
+
|
633
|
+
.legend {
|
634
|
+
display: flex;
|
635
|
+
gap: 24px;
|
636
|
+
justify-content: center;
|
637
|
+
}
|
638
|
+
|
639
|
+
.legend-item {
|
640
|
+
display: flex;
|
641
|
+
align-items: center;
|
642
|
+
gap: 8px;
|
643
|
+
font-size: 14px;
|
644
|
+
color: #666;
|
645
|
+
}
|
646
|
+
|
647
|
+
.legend-color {
|
648
|
+
width: 16px;
|
649
|
+
height: 16px;
|
650
|
+
border-radius: 2px;
|
651
|
+
border: 1px solid #e7e7e7;
|
652
|
+
}
|
653
|
+
|
654
|
+
.legend-color.available {
|
655
|
+
background: white;
|
656
|
+
}
|
657
|
+
|
658
|
+
.legend-color.booked {
|
659
|
+
background: #f5f5f5;
|
660
|
+
}
|
661
|
+
|
662
|
+
.legend-color.selected {
|
663
|
+
background: #1890ff;
|
664
|
+
}
|
665
665
|
</style>
|