Commit e8a990f54f6335c19d8de424b75b0f5e4e27bf86
1 parent
a781ad1a
hide ranges in month and year tables
Showing
2 changed files
with
2 additions
and
9 deletions
Show diff stats
src/components/date-picker/base/month-table.vue
| @@ -12,7 +12,7 @@ | @@ -12,7 +12,7 @@ | ||
| 12 | </div> | 12 | </div> |
| 13 | </template> | 13 | </template> |
| 14 | <script> | 14 | <script> |
| 15 | - import { clearHours, isInRange } from '../util'; | 15 | + import { clearHours } from '../util'; |
| 16 | import { deepCopy } from '../../../utils/assist'; | 16 | import { deepCopy } from '../../../utils/assist'; |
| 17 | import Locale from '../../../mixins/locale'; | 17 | import Locale from '../../../mixins/locale'; |
| 18 | import mixin from './mixin'; | 18 | import mixin from './mixin'; |
| @@ -37,8 +37,6 @@ | @@ -37,8 +37,6 @@ | ||
| 37 | }; | 37 | }; |
| 38 | 38 | ||
| 39 | const tableYear = this.tableDate.getFullYear(); | 39 | const tableYear = this.tableDate.getFullYear(); |
| 40 | - const rangeStart = this.rangeState.from && clearHours(new Date(this.rangeState.from.getFullYear(), this.rangeState.from.getMonth(), 1)); | ||
| 41 | - const rangeEnd = this.rangeState.to && clearHours(new Date(this.rangeState.to.getFullYear(), this.rangeState.to.getMonth(), 1)); | ||
| 42 | const selectedDays = this.dates.filter(Boolean).map(date => clearHours(new Date(date.getFullYear(), date.getMonth(), 1))); | 40 | const selectedDays = this.dates.filter(Boolean).map(date => clearHours(new Date(date.getFullYear(), date.getMonth(), 1))); |
| 43 | 41 | ||
| 44 | for (let i = 0; i < 12; i++) { | 42 | for (let i = 0; i < 12; i++) { |
| @@ -46,7 +44,6 @@ | @@ -46,7 +44,6 @@ | ||
| 46 | cell.date = new Date(tableYear, i, 1); | 44 | cell.date = new Date(tableYear, i, 1); |
| 47 | cell.text = this.tCell(i + 1); | 45 | cell.text = this.tCell(i + 1); |
| 48 | const time = clearHours(cell.date); | 46 | const time = clearHours(cell.date); |
| 49 | - cell.range = isInRange(time, rangeStart, rangeEnd); | ||
| 50 | cell.disabled = typeof this.disabledDate === 'function' && this.disabledDate(cell.date) && this.selectionMode === 'month'; | 47 | cell.disabled = typeof this.disabledDate === 'function' && this.disabledDate(cell.date) && this.selectionMode === 'month'; |
| 51 | cell.selected = selectedDays.includes(time); | 48 | cell.selected = selectedDays.includes(time); |
| 52 | cells.push(cell); | 49 | cells.push(cell); |
src/components/date-picker/base/year-table.vue
| @@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
| 11 | </div> | 11 | </div> |
| 12 | </template> | 12 | </template> |
| 13 | <script> | 13 | <script> |
| 14 | - import { clearHours, isInRange } from '../util'; | 14 | + import { clearHours } from '../util'; |
| 15 | import { deepCopy } from '../../../utils/assist'; | 15 | import { deepCopy } from '../../../utils/assist'; |
| 16 | import mixin from './mixin'; | 16 | import mixin from './mixin'; |
| 17 | import prefixCls from './prefixCls'; | 17 | import prefixCls from './prefixCls'; |
| @@ -38,17 +38,13 @@ | @@ -38,17 +38,13 @@ | ||
| 38 | disabled: false | 38 | disabled: false |
| 39 | }; | 39 | }; |
| 40 | 40 | ||
| 41 | - const rangeStart = this.rangeState.from && clearHours(new Date(this.rangeState.from.getFullYear(), 0, 1)); | ||
| 42 | - const rangeEnd = this.rangeState.to && clearHours(new Date(this.rangeState.to.getFullYear(), 0, 1)); | ||
| 43 | const selectedDays = this.dates.filter(Boolean).map(date => clearHours(new Date(date.getFullYear(), 0, 1))); | 41 | const selectedDays = this.dates.filter(Boolean).map(date => clearHours(new Date(date.getFullYear(), 0, 1))); |
| 44 | 42 | ||
| 45 | - | ||
| 46 | for (let i = 0; i < 10; i++) { | 43 | for (let i = 0; i < 10; i++) { |
| 47 | const cell = deepCopy(cell_tmpl); | 44 | const cell = deepCopy(cell_tmpl); |
| 48 | cell.date = new Date(this.startYear + i, 0, 1); | 45 | cell.date = new Date(this.startYear + i, 0, 1); |
| 49 | cell.disabled = typeof this.disabledDate === 'function' && this.disabledDate(cell.date) && this.selectionMode === 'year'; | 46 | cell.disabled = typeof this.disabledDate === 'function' && this.disabledDate(cell.date) && this.selectionMode === 'year'; |
| 50 | const time = clearHours(cell.date); | 47 | const time = clearHours(cell.date); |
| 51 | - cell.range = isInRange(time, rangeStart, rangeEnd); | ||
| 52 | cell.selected = selectedDays.includes(time); | 48 | cell.selected = selectedDays.includes(time); |
| 53 | cells.push(cell); | 49 | cells.push(cell); |
| 54 | } | 50 | } |