Commit 13be443453a2ef19c7a8d77b2e17e90356ead3c9
1 parent
344131a7
update DatePicker
update DatePicker
Showing
4 changed files
with
14 additions
and
6 deletions
Show diff stats
src/components/date-picker/base/month-table.vue
| ... | ... | @@ -13,7 +13,10 @@ |
| 13 | 13 | month: { |
| 14 | 14 | type: Number |
| 15 | 15 | }, |
| 16 | - disabledDate: {} | |
| 16 | + disabledDate: {}, | |
| 17 | + selectionMode: { | |
| 18 | + default: 'month' | |
| 19 | + } | |
| 17 | 20 | }, |
| 18 | 21 | computed: { |
| 19 | 22 | classes () { |
| ... | ... | @@ -36,7 +39,7 @@ |
| 36 | 39 | |
| 37 | 40 | const date = new Date(this.date); |
| 38 | 41 | date.setMonth(i); |
| 39 | - cell.disabled = typeof this.disabledDate === 'function' && this.disabledDate(date); | |
| 42 | + cell.disabled = typeof this.disabledDate === 'function' && this.disabledDate(date) && this.selectionMode === 'month'; | |
| 40 | 43 | |
| 41 | 44 | cell.selected = Number(this.month) === i; |
| 42 | 45 | cells.push(cell); | ... | ... |
src/components/date-picker/base/year-table.vue
| ... | ... | @@ -11,7 +11,10 @@ |
| 11 | 11 | props: { |
| 12 | 12 | date: {}, |
| 13 | 13 | year: {}, |
| 14 | - disabledDate: {} | |
| 14 | + disabledDate: {}, | |
| 15 | + selectionMode: { | |
| 16 | + default: 'year' | |
| 17 | + } | |
| 15 | 18 | }, |
| 16 | 19 | computed: { |
| 17 | 20 | classes () { |
| ... | ... | @@ -37,7 +40,7 @@ |
| 37 | 40 | |
| 38 | 41 | const date = new Date(this.date); |
| 39 | 42 | date.setFullYear(cell.text); |
| 40 | - cell.disabled = typeof this.disabledDate === 'function' && this.disabledDate(date); | |
| 43 | + cell.disabled = typeof this.disabledDate === 'function' && this.disabledDate(date) && this.selectionMode === 'year'; | |
| 41 | 44 | |
| 42 | 45 | cell.selected = Number(this.year) === cell.text; |
| 43 | 46 | cells.push(cell); | ... | ... |
src/components/date-picker/panel/date.vue
| ... | ... | @@ -37,7 +37,6 @@ |
| 37 | 37 | :month="month" |
| 38 | 38 | :date="date" |
| 39 | 39 | :value="value" |
| 40 | - :week="week" | |
| 41 | 40 | :selection-mode="selectionMode" |
| 42 | 41 | :disabled-date="disabledDate" |
| 43 | 42 | @on-pick="handleDatePick"></date-table> |
| ... | ... | @@ -46,6 +45,7 @@ |
| 46 | 45 | v-show="currentView === 'year'" |
| 47 | 46 | :year="year" |
| 48 | 47 | :date="date" |
| 48 | + :selection-mode="selectionMode" | |
| 49 | 49 | :disabled-date="disabledDate" |
| 50 | 50 | @on-pick="handleYearPick"></year-table> |
| 51 | 51 | <month-table |
| ... | ... | @@ -53,6 +53,7 @@ |
| 53 | 53 | v-show="currentView === 'month'" |
| 54 | 54 | :month="month" |
| 55 | 55 | :date="date" |
| 56 | + :selection-mode="selectionMode" | |
| 56 | 57 | :disabled-date="disabledDate" |
| 57 | 58 | @on-pick="handleMonthPick"></month-table> |
| 58 | 59 | </div> |
| ... | ... | @@ -85,7 +86,6 @@ |
| 85 | 86 | disabledDate: '', |
| 86 | 87 | year: null, |
| 87 | 88 | month: null, |
| 88 | - week: null, | |
| 89 | 89 | showWeekNumber: false, |
| 90 | 90 | timePickerVisible: false |
| 91 | 91 | } | ... | ... |
test/routers/date.vue