@@ -50,27 +50,27 @@ const AtCalendar = Vue.extend({
50
50
type : String ,
51
51
default : 'YYYY年MM月' ,
52
52
} ,
53
- onMonthChange : {
53
+ atMonthChange : {
54
54
type : Function ,
55
55
default : ( ) => ( ) => { } ,
56
56
} ,
57
- onClickPreMonth : {
57
+ atClickPreMonth : {
58
58
type : Function ,
59
59
default : ( ) => ( ) => { } ,
60
60
} ,
61
- onClickNextMonth : {
61
+ atClickNextMonth : {
62
62
type : Function ,
63
63
default : ( ) => ( ) => { } ,
64
64
} ,
65
- onDayClick : {
65
+ atDayClick : {
66
66
type : Function ,
67
67
default : ( ) => ( ) => { } ,
68
68
} ,
69
- onSelectDate : {
69
+ atSelectDate : {
70
70
type : Function ,
71
71
default : ( ) => ( ) => { } ,
72
72
} ,
73
- onDayLongClick : {
73
+ atDayLongClick : {
74
74
type : Function ,
75
75
default : ( ) => ( ) => { } ,
76
76
} ,
@@ -88,11 +88,17 @@ const AtCalendar = Vue.extend({
88
88
state : { } ,
89
89
}
90
90
} ,
91
- watch : {
92
- currentDate ( val ) {
93
- if ( ! val ) return
91
+ computed : {
92
+ nextProps ( ) {
94
93
const { currentDate, isMultiSelect } = this
95
- if ( isMultiSelect ) {
94
+ return { currentDate, isMultiSelect }
95
+ } ,
96
+ } ,
97
+ watch : {
98
+ nextProps ( val , oldVal ) {
99
+ const { currentDate, isMultiSelect } = val
100
+ if ( ! currentDate || currentDate === oldVal . currentDate ) return
101
+ if ( isMultiSelect && oldVal . isMultiSelect ) {
96
102
const { start, end } = currentDate
97
103
const { start : preStart , end : preEnd } = this . currentDate
98
104
@@ -201,9 +207,9 @@ const AtCalendar = Vue.extend({
201
207
triggerChangeDate ( value ) {
202
208
const { format } = this
203
209
204
- if ( typeof this . onMonthChange !== 'function' ) return
210
+ if ( typeof this . atMonthChange !== 'function' ) return
205
211
206
- this . onMonthChange ( value . format ( format ) )
212
+ this . atMonthChange ( value . format ( format ) )
207
213
} ,
208
214
setMonth ( vectorCount ) {
209
215
const { format } = this
@@ -213,20 +219,21 @@ const AtCalendar = Vue.extend({
213
219
this . setState ( {
214
220
generateDate : _generateDate . valueOf ( ) ,
215
221
} )
216
-
217
- if ( vectorCount && typeof this . onMonthChange === 'function' ) {
218
- this . onMonthChange ( _generateDate . format ( format ) )
222
+ console . log ( this . state )
223
+ if ( vectorCount && typeof this . atMonthChange === 'function' ) {
224
+ this . atMonthChange ( _generateDate . format ( format ) )
219
225
}
220
226
} ,
221
227
handleClickPreMonth ( isMinMonth ) {
228
+ console . log ( 'isMinMonth >> ' , isMinMonth )
222
229
if ( isMinMonth === true ) {
223
230
return
224
231
}
225
232
226
233
this . setMonth ( - 1 )
227
234
228
- if ( typeof this . onClickPreMonth === 'function' ) {
229
- this . onClickPreMonth ( )
235
+ if ( typeof this . atClickPreMonth === 'function' ) {
236
+ this . atClickPreMonth ( )
230
237
}
231
238
} ,
232
239
handleClickNextMonth ( isMaxMonth ) {
@@ -236,8 +243,8 @@ const AtCalendar = Vue.extend({
236
243
237
244
this . setMonth ( 1 )
238
245
239
- if ( typeof this . onClickNextMonth === 'function' ) {
240
- this . onClickNextMonth ( )
246
+ if ( typeof this . atClickNextMonth === 'function' ) {
247
+ this . atClickNextMonth ( )
241
248
}
242
249
} ,
243
250
handleSelectDate ( e ) {
@@ -268,18 +275,18 @@ const AtCalendar = Vue.extend({
268
275
} else {
269
276
stateValue = this . getSingleSelectdState ( dayjsDate )
270
277
}
271
-
278
+ console . log ( 'stateValue' , stateValue )
272
279
this . setState ( stateValue , ( ) => {
273
280
this . handleSelectedDate ( )
274
281
} )
275
282
276
- if ( typeof this . onDayClick === 'function' ) {
277
- this . onDayClick ( { value : item . value } )
283
+ if ( typeof this . atDayClick === 'function' ) {
284
+ this . atDayClick ( { value : item . value } )
278
285
}
279
286
} ,
280
287
handleSelectedDate ( ) {
281
288
const selectDate = this . state . selectedDate
282
- if ( typeof this . onSelectDate === 'function' ) {
289
+ if ( typeof this . atSelectDate === 'function' ) {
283
290
const info = {
284
291
start : dayjs ( selectDate . start ) . format ( this . format ) ,
285
292
}
@@ -288,19 +295,20 @@ const AtCalendar = Vue.extend({
288
295
info . end = dayjs ( selectDate . end ) . format ( this . format )
289
296
}
290
297
291
- this . onSelectDate ( {
298
+ this . atSelectDate ( {
292
299
value : info ,
293
300
} )
294
301
}
295
302
} ,
296
303
handleDayLongClick ( item ) {
297
- if ( typeof this . onDayLongClick === 'function' ) {
298
- this . onDayLongClick ( { value : item . value } )
304
+ if ( typeof this . atDayLongClick === 'function' ) {
305
+ this . atDayLongClick ( { value : item . value } )
299
306
}
300
307
} ,
301
308
} ,
302
309
render ( ) {
303
310
const { generateDate, selectedDate } = this . state
311
+ console . log ( 'selectedDate >>' , selectedDate )
304
312
const {
305
313
validDates,
306
314
marks,
@@ -323,9 +331,9 @@ const AtCalendar = Vue.extend({
323
331
hideArrow = { hideArrow }
324
332
monthFormat = { monthFormat }
325
333
generateDate = { generateDate }
326
- onPreMonth = { this . handleClickPreMonth }
327
- onNextMonth = { this . handleClickNextMonth }
328
- onSelectDate = { this . handleSelectDate }
334
+ atPreMonth = { this . handleClickPreMonth }
335
+ atNextMonth = { this . handleClickNextMonth }
336
+ atSelectDate = { this . handleSelectDate }
329
337
/>
330
338
< AtCalendarBody
331
339
validDates = { validDates }
@@ -338,9 +346,9 @@ const AtCalendar = Vue.extend({
338
346
selectedDate = { selectedDate }
339
347
selectedDates = { selectedDates }
340
348
generateDate = { generateDate }
341
- onDayClick = { this . handleDayClick }
342
- onSwipeMonth = { this . setMonth }
343
- onLongClick = { this . handleDayLongClick }
349
+ atDayClick = { this . handleDayClick }
350
+ atSwipeMonth = { this . setMonth }
351
+ atLongClick = { this . handleDayLongClick }
344
352
/>
345
353
</ view >
346
354
)
0 commit comments