mirror of
https://github.com/tenrok/vue2-datepicker.git
synced 2026-06-19 10:30:35 +03:00
45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
import locale from '@/mixins/locale'
|
|
|
|
export default {
|
|
name: 'panelMonth',
|
|
mixins: [locale],
|
|
props: {
|
|
value: null,
|
|
calendarYear: {
|
|
default: new Date().getFullYear()
|
|
},
|
|
disabledMonth: Function
|
|
},
|
|
methods: {
|
|
isDisabled (month) {
|
|
if (typeof this.disabledMonth === 'function' && this.disabledMonth(month)) {
|
|
return true
|
|
}
|
|
return false
|
|
},
|
|
selectMonth (month) {
|
|
if (this.isDisabled(month)) {
|
|
return
|
|
}
|
|
this.$emit('select', month)
|
|
}
|
|
},
|
|
render (h) {
|
|
let months = this.t('months')
|
|
const currentYear = this.value && new Date(this.value).getFullYear()
|
|
const currentMonth = this.value && new Date(this.value).getMonth()
|
|
months = months.map((v, i) => {
|
|
return <span
|
|
class={{
|
|
'cell': true,
|
|
'actived': currentYear === this.calendarYear && currentMonth === i,
|
|
'disabled': this.isDisabled(i)
|
|
}}
|
|
onClick={this.selectMonth.bind(this, i)}>
|
|
{v}
|
|
</span>
|
|
})
|
|
return <div class="mx-panel mx-panel-month">{months}</div>
|
|
}
|
|
}
|