2
0
mirror of https://github.com/tenrok/vue2-datepicker.git synced 2026-06-12 16:12:47 +03:00

add month year type

This commit is contained in:
zendy kim
2018-07-17 09:55:29 +09:00
parent dd19f4cda9
commit df270f1b7a
3 changed files with 2859 additions and 2842 deletions
+1 -1
View File
@@ -43,7 +43,7 @@ new Vue({ // eslint-disable-line
},
render (h) {
const example1 = {
'base': '<date-picker v-model="value1" lang="en" :not-before="new Date()"></date-picker>',
'base': '<date-picker v-model="value1" lang="en" :not-before="new Date()" type="month"></date-picker>',
'range': '<date-picker v-model="value2" range ></date-picker>'
}
const example2 = {
+2838 -2838
View File
File diff suppressed because it is too large Load Diff
+20 -3
View File
@@ -92,7 +92,7 @@ export default {
// below user set
type: {
type: String,
default: 'date' // ['date', 'datetime']
default: 'date' // ['date', 'datetime'] zendy added 'month', 'year'
},
firstDayOfWeek: {
default: 7,
@@ -135,7 +135,7 @@ export default {
const calendarMonth = now.getMonth()
const firstYear = Math.floor(calendarYear / 10) * 10
return {
panel: 'DATE',
panel: 'MONTH',
dates: [],
calendarMonth,
calendarYear,
@@ -176,6 +176,7 @@ export default {
},
methods: {
handelPanelChange (panel) {
console.log('panel changed')
if (panel === 'YEAR') {
this.firstYear = Math.floor(this.calendarYear / 10) * 10
} else if (panel === 'TIME') {
@@ -187,7 +188,14 @@ export default {
}
},
init () {
this.panel = 'DATE'
if (this.type.toLowerCase() == 'month') {
this.panel = 'MONTH'
} else if (this.type.toLowerCase() == 'year') {
this.panel = 'YEAR'
} else {
this.panel = 'DATE'
}
this.updateNow(this.value)
},
// 根据value更新日历
@@ -248,10 +256,18 @@ export default {
},
selectYear (year) {
this.changeCalendarYear(year)
if (this.type.toLowerCase() === 'year') {
return this.selectDate(this.now)
}
this.showPanelMonth()
},
selectMonth (month) {
this.changeCalendarMonth(month)
if (this.type.toLowerCase() === 'month') {
return this.selectDate(this.now)
}
this.showPanelDate()
},
selectTime (time) {
@@ -291,6 +307,7 @@ export default {
this.firstYear = this.firstYear + flag * 10
},
showPanelDate () {
console.log('date')
this.panel = 'DATE'
},
showPanelYear () {