Commit 8c2e53e8cc0c9c3046b9ddf018af2460ad5075cd
Committed by
GitHub
Merge pull request #2069 from dspangenberg/2.0
DatePicker: weekStartDay did not influence the order of the weekdays in the header
Showing
2 changed files
with
11 additions
and
1 deletions
Show diff stats
src/components/date-picker/base/date-table.vue
@@ -3,7 +3,9 @@ | @@ -3,7 +3,9 @@ | ||
3 | :class="classes" | 3 | :class="classes" |
4 | @mousemove="handleMouseMove"> | 4 | @mousemove="handleMouseMove"> |
5 | <div :class="[prefixCls + '-header']"> | 5 | <div :class="[prefixCls + '-header']"> |
6 | - <span>{{ t('i.datepicker.weeks.sun') }}</span><span>{{ t('i.datepicker.weeks.mon') }}</span><span>{{ t('i.datepicker.weeks.tue') }}</span><span>{{ t('i.datepicker.weeks.wed') }}</span><span>{{ t('i.datepicker.weeks.thu') }}</span><span>{{ t('i.datepicker.weeks.fri') }}</span><span>{{ t('i.datepicker.weeks.sat') }}</span> | 6 | + <span v-for="day in headerDays" :key="day"> |
7 | + {{day}} | ||
8 | + </span> | ||
7 | </div> | 9 | </div> |
8 | <span :class="getCellCls(cell)" v-for="(cell, index) in readCells"><em :index="index" @click="handleClick(cell)">{{ cell.text }}</em></span> | 10 | <span :class="getCellCls(cell)" v-for="(cell, index) in readCells"><em :index="index" @click="handleClick(cell)">{{ cell.text }}</em></span> |
9 | </div> | 11 | </div> |
@@ -87,6 +89,14 @@ | @@ -87,6 +89,14 @@ | ||
87 | `${prefixCls}` | 89 | `${prefixCls}` |
88 | ]; | 90 | ]; |
89 | }, | 91 | }, |
92 | + headerDays () { | ||
93 | + const weekStartDay = Number(this.t('i.datepicker.weekStartDay')); | ||
94 | + const translatedDays = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'].map(item => { | ||
95 | + return this.t('i.datepicker.weeks.' + item); | ||
96 | + }) | ||
97 | + const weekDays = translatedDays.splice(weekStartDay, 7 - weekStartDay).concat(translatedDays.splice(0, weekStartDay)); | ||
98 | + return weekDays; | ||
99 | + }, | ||
90 | cells () { | 100 | cells () { |
91 | const date = new Date(this.year, this.month, 1); | 101 | const date = new Date(this.year, this.month, 1); |
92 | const weekStartDay = Number(this.t('i.datepicker.weekStartDay')); | 102 | const weekStartDay = Number(this.t('i.datepicker.weekStartDay')); |