22
22
:class =" { active: isToday(d-1) }"
23
23
:style =" { top: pinTop + 'px' }"
24
24
/>
25
+ <!-- 顯示排班 -->
26
+ <div
27
+ v-for =" schedule in weekDaySchedules(d-1)"
28
+ :key =" schedule.id"
29
+ class =" weekBody_schedule"
30
+ :style =" schedule.style"
31
+ />
25
32
<!-- 顯示預約事件 -->
26
33
<div
27
34
v-for =" order in weekDayOrders(d-1)"
@@ -49,6 +56,7 @@ export default {
49
56
current: { type: Date , required: true },
50
57
today: { type: Object , required: true },
51
58
orders: { type: Array , required: true },
59
+ schedules: { type: Array , required: true },
52
60
daysOfWeek: { type: Array , required: true },
53
61
use12Hour: { type: Boolean , default: true }
54
62
},
@@ -100,6 +108,37 @@ export default {
100
108
})
101
109
}
102
110
},
111
+ // 處理當日排班的樣式
112
+ schedulesWithStyle () {
113
+ const { schedules } = this
114
+ const oneDay = 24 * 60 * 60
115
+ const HeightPerHour = 70
116
+
117
+ return schedules
118
+ .map (schedule => {
119
+ const { from , to } = schedule .online
120
+ const height = (to - from) * HeightPerHour / (60 * 60 * 1000 )
121
+ const totalSec = from .getSeconds () + 60 * from .getMinutes () + 60 * 60 * from .getHours ()
122
+ const top = (totalSec % oneDay) * HeightPerHour * 24 / oneDay
123
+ return {
124
+ ... schedule,
125
+ style: {
126
+ height: height + ' px' ,
127
+ top: top + ' px'
128
+ }
129
+ }
130
+ })
131
+ },
132
+ // 取得當日的排班
133
+ weekDaySchedules () {
134
+ const { schedulesWithStyle , daysOfWeek } = this
135
+ return (d ) => {
136
+ const day = daysOfWeek[d]
137
+ return schedulesWithStyle .filter (order => {
138
+ return order .online .from .getDay () === day .weekDay
139
+ })
140
+ }
141
+ },
103
142
isToday () {
104
143
const { today , daysOfWeek } = this
105
144
return d => {
@@ -117,7 +156,7 @@ $border: #d4d5d6;
117
156
$pinColor : #757575 ;
118
157
$orderBg : #e5e5e5 ;
119
158
$orderBg : rgba (229 , 229 , 229 , 0.7 );
120
-
159
+ $scheduleBg : rgba ( 246 , 246 , 246 , 0.5 );
121
160
.weekBody {
122
161
height : 100% ;
123
162
overflow : auto ;
@@ -164,6 +203,19 @@ $orderBg: rgba(229, 229, 229, 0.7);
164
203
& _order_name {
165
204
font-weight : 550 ;
166
205
}
206
+ & _schedule {
207
+ position : absolute ;
208
+ background-color : $scheduleBg ;
209
+ width : 100% ;
210
+ z-index : 1 ;
211
+ text-align : left ;
212
+ padding : 0.5rem ;
213
+ font-size : 0.8rem ;
214
+ cursor : pointer ;
215
+ overflow : hidden ;
216
+ text-overflow : ellipsis ;
217
+ word-wrap : break-word ;
218
+ }
167
219
.pin {
168
220
width : 100% ;
169
221
height : 1px ;
0 commit comments