@@ -7,7 +7,12 @@ import {
7
7
watch ,
8
8
} from 'vue' ;
9
9
import { CalendarDateType } from './types' ;
10
- import { checkPlatform , makeDateProp , makeNumberProp } from './utils' ;
10
+ import {
11
+ checkPlatform ,
12
+ fillNumber ,
13
+ makeDateProp ,
14
+ makeNumberProp ,
15
+ } from './utils' ;
11
16
12
17
export const calendarTimeProps = {
13
18
show : Boolean ,
@@ -191,27 +196,6 @@ export default defineComponent({
191
196
( index === 0 && time === checkedDate . value . hours ) ||
192
197
( index === 1 && time === checkedDate . value . minutes ) ;
193
198
194
- // 校验时间范围
195
- const checkTimeRange = ( range : string ) => {
196
- if ( ! range ) return ;
197
- const timeArr = range . split ( '-' ) ;
198
- if ( timeArr . length === 0 || timeArr . length > 2 ) return false ;
199
-
200
- return timeArr . every ( ( time ) => {
201
- const mhArr = time . split ( ':' ) ;
202
- if ( mhArr . length === 0 || mhArr . length > 2 ) return false ;
203
-
204
- // 校验单个时间是否符合规范 00:00 - 24:00
205
- if ( parseInt ( mhArr [ 0 ] , 10 ) < 0 || parseInt ( mhArr [ 0 ] , 10 ) > 24 )
206
- return false ;
207
- if ( parseInt ( mhArr [ 1 ] , 10 ) < 0 || parseInt ( mhArr [ 1 ] , 10 ) > 59 )
208
- return false ;
209
- if ( parseInt ( mhArr [ 0 ] , 10 ) === 24 && parseInt ( mhArr [ 1 ] , 10 ) > 0 )
210
- return false ;
211
- return true ;
212
- } ) ;
213
- } ;
214
-
215
199
watch (
216
200
( ) => props . defaultTime ,
217
201
( val ) => {
@@ -256,5 +240,40 @@ export default defineComponent({
256
240
} ,
257
241
{ immediate : true }
258
242
) ;
243
+
244
+ const renderTimeItem = ( time : number [ ] , index : number ) =>
245
+ time . map ( ( item , j ) => (
246
+ < div
247
+ class = { `time_item ${
248
+ isBeSelectedTime ( item , index ) ? 'time_item_show' : ''
249
+ } ${ hashClass . value } ${
250
+ formatDisabledDate ( item , index ) ? 'time-disabled' : ''
251
+ } `}
252
+ key = { index + j }
253
+ >
254
+ { fillNumber ( item ) }
255
+ </ div >
256
+ ) ) ;
257
+
258
+ const renderCalendarTime = ( ) => (
259
+ < div class = "time_body" style = { { display : props . show ? 'block' : 'none' } } >
260
+ < div class = "time_group" >
261
+ { timeArray . value . map ( ( item , index ) => (
262
+ < div
263
+ class = "time_content"
264
+ id = { hashID . value [ index ] }
265
+ key = { index }
266
+ onTouchstart = { timeTouchStart }
267
+ onTouchmove = { ( e ) => timeTouchMove ( e , index ) }
268
+ onTouchend = { ( e ) => timeTouchEnd ( e , index ) }
269
+ >
270
+ { renderTimeItem ( item , index ) }
271
+ </ div >
272
+ ) ) }
273
+ </ div >
274
+ </ div >
275
+ ) ;
276
+
277
+ return ( ) => renderCalendarTime ( ) ;
259
278
} ,
260
279
} ) ;
0 commit comments