|
63 | 63 | import { getWeek, format } from 'date-format-parse'; |
64 | 64 | import IconButton from './icon-button'; |
65 | 65 | import { chunk } from '../util/base'; |
66 | | -import { createDate, getCalendar } from '../util/date'; |
| 66 | +import { getCalendar, setMonth, setYear } from '../util/date'; |
67 | 67 | import { getLocale } from '../locale'; |
68 | 68 |
|
69 | 69 | export default { |
@@ -141,22 +141,33 @@ export default { |
141 | 141 | }, |
142 | 142 | }, |
143 | 143 | methods: { |
144 | | - getNextCalendar(diffMonth) { |
145 | | - const year = this.calendar.getFullYear(); |
146 | | - const month = this.calendar.getMonth(); |
147 | | - return createDate(year, month + diffMonth); |
148 | | - }, |
149 | 144 | handleIconLeftClick() { |
150 | | - this.$emit('changecalendar', this.getNextCalendar(-1), 'last-month'); |
| 145 | + this.$emit( |
| 146 | + 'changecalendar', |
| 147 | + setMonth(this.calendar, v => v - 1), |
| 148 | + 'last-month' |
| 149 | + ); |
151 | 150 | }, |
152 | 151 | handleIconRightClick() { |
153 | | - this.$emit('changecalendar', this.getNextCalendar(1), 'next-month'); |
| 152 | + this.$emit( |
| 153 | + 'changecalendar', |
| 154 | + setMonth(this.calendar, v => v + 1), |
| 155 | + 'next-month' |
| 156 | + ); |
154 | 157 | }, |
155 | 158 | handleIconDoubleLeftClick() { |
156 | | - this.$emit('changecalendar', this.getNextCalendar(-12), 'last-year'); |
| 159 | + this.$emit( |
| 160 | + 'changecalendar', |
| 161 | + setYear(this.calendar, v => v - 1), |
| 162 | + 'last-year' |
| 163 | + ); |
157 | 164 | }, |
158 | 165 | handleIconDoubleRightClick() { |
159 | | - this.$emit('changecalendar', this.getNextCalendar(12), 'next-year'); |
| 166 | + this.$emit( |
| 167 | + 'changecalendar', |
| 168 | + setYear(this.calendar, v => v + 1), |
| 169 | + 'next-year' |
| 170 | + ); |
160 | 171 | }, |
161 | 172 | handlePanelChange(panel) { |
162 | 173 | this.$emit('changepanel', panel); |
|
0 commit comments