mirror of
https://github.com/tenrok/vue2-datepicker.git
synced 2026-06-23 20:50:37 +03:00
feat: add event 'change-calendar-year' 'change-calendar-month'
This commit is contained in:
+22
-2
@@ -290,14 +290,34 @@ export default {
|
|||||||
changeCalendarMonth (month) {
|
changeCalendarMonth (month) {
|
||||||
this.now = new Date(this.calendarYear, month)
|
this.now = new Date(this.calendarYear, month)
|
||||||
},
|
},
|
||||||
|
getSibling () {
|
||||||
|
const calendars = this.$parent.$children.filter(v => v.$options.name === this.$options.name)
|
||||||
|
const index = calendars.indexOf(this)
|
||||||
|
const sibling = calendars[index ^ 1]
|
||||||
|
return sibling
|
||||||
|
},
|
||||||
handleIconMonth (flag) {
|
handleIconMonth (flag) {
|
||||||
this.changeCalendarMonth(this.calendarMonth + flag)
|
const month = this.calendarMonth
|
||||||
|
this.changeCalendarMonth(month + flag)
|
||||||
|
this.$parent.$emit('change-calendar-month', {
|
||||||
|
month,
|
||||||
|
flag,
|
||||||
|
vm: this,
|
||||||
|
sibling: this.getSibling()
|
||||||
|
})
|
||||||
},
|
},
|
||||||
handleIconYear (flag) {
|
handleIconYear (flag) {
|
||||||
if (this.panel === 'YEAR') {
|
if (this.panel === 'YEAR') {
|
||||||
this.changePanelYears(flag)
|
this.changePanelYears(flag)
|
||||||
} else {
|
} else {
|
||||||
this.changeCalendarYear(this.calendarYear + flag)
|
const year = this.calendarYear
|
||||||
|
this.changeCalendarYear(year + flag)
|
||||||
|
this.$parent.$emit('change-calendar-year', {
|
||||||
|
year,
|
||||||
|
flag,
|
||||||
|
vm: this,
|
||||||
|
sibling: this.getSibling()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleBtnYear () {
|
handleBtnYear () {
|
||||||
|
|||||||
Reference in New Issue
Block a user