diff --git a/README.md b/README.md index 2a9aaf8..2d1b7cd 100644 --- a/README.md +++ b/README.md @@ -39,24 +39,25 @@ export default { ``` ## Attributes -| Prop | Type | Default | Description | -|-----------------|---------------|-------------|---------------------------------------------------| -| range | Boolean | false | if true, the type is daterange | -| format | String | yyyy-MM-dd | Date formatting string | -| lang | String | zh | Translation (en/zh/es) | -| placeholder | String | | input placeholder text | -| width | String/Number | 210 | input size | -| disabled-days | Array | [] | Days in YYYY-MM-DD format to disable | -| not-before | String | '' | Disable all dates before date in YYY-MM-DD format | -| not-after | String | '' | Disable all dates after date in YYY-MM-DD format | -| shortcuts | Boolean/Array | true | the shortcuts for the range picker | +| Prop | Type | Default | Description | +|-------------------|---------------|-------------|---------------------------------------------------| +| range | Boolean | false | if true, the type is daterange | +| format | String | yyyy-MM-dd | Date formatting string | +| lang | String | zh | Translation (en/zh/es) | +| placeholder | String | | input placeholder text | +| width | String/Number | 210 | input size | +| disabled-days | Array | [] | Days in YYYY-MM-DD format to disable | +| not-before | String | '' | Disable all dates before date in YYY-MM-DD format | +| not-after | String | '' | Disable all dates after date in YYY-MM-DD format | +| shortcuts | Boolean/Array | true | the shortcuts for the range picker | +| first-day-of-week | Number | 7 | set the first day of week (1-7) | ## shortcuts * true - show the default shortcuts diff --git a/datepicker/calendar-panel.vue b/datepicker/calendar-panel.vue index 68ac86f..e3df7cd 100644 --- a/datepicker/calendar-panel.vue +++ b/datepicker/calendar-panel.vue @@ -42,7 +42,6 @@ export default { data () { const translation = this.$parent.translation return { - days: translation.days, months: translation.months, dates: [], now: new Date(), // calendar-header 显示的时间, 用于切换日历 @@ -51,6 +50,11 @@ export default { } }, computed: { + days () { + const days = this.$parent.translation.days + const firstday = +this.$parent.firstDayOfWeek + return days.concat(days).slice(firstday, firstday + 7) + }, currentYear () { return this.now.getFullYear() }, @@ -94,9 +98,10 @@ export default { } }) } + const firstDayOfWeek = this.$parent.firstDayOfWeek const time = new Date(this.now) time.setDate(0) // 把时间切换到上个月最后一天 - const lastMonthLength = time.getDay() + 1 // time.getDay() 0是星期天, 1是星期一 ... + const lastMonthLength = (time.getDay() + 7 - firstDayOfWeek) % 7 + 1 // time.getDay() 0是星期天, 1是星期一 ... const lastMonthfirst = time.getDate() - (lastMonthLength - 1) const lastMonth = getCalendar(time, lastMonthfirst, lastMonthLength, 'lastMonth') @@ -214,7 +219,6 @@ export default { } } } -