Commit c365be46337dc9b222ad349d0e0c195a6afbc81b
Committed by
GitHub
Merge pull request #3096 from SergioCrisostomo/use-last-picked-date-in-multiple-mode-for-panel-date
Use last picked date in multiple mode for panel date
Showing
2 changed files
with
8 additions
and
2 deletions
Show diff stats
src/components/date-picker/panel/Date/date.vue
... | ... | @@ -92,7 +92,11 @@ |
92 | 92 | mixins: [ Mixin, Locale, DateMixin ], |
93 | 93 | components: { Icon, DateTable, YearTable, MonthTable, TimePicker, Confirm, datePanelLabel }, |
94 | 94 | props: { |
95 | - // in the mixin | |
95 | + // more props in the mixin | |
96 | + multiple: { | |
97 | + type: Boolean, | |
98 | + default: false | |
99 | + } | |
96 | 100 | }, |
97 | 101 | data () { |
98 | 102 | const {selectionMode, value} = this; |
... | ... | @@ -141,7 +145,7 @@ |
141 | 145 | watch: { |
142 | 146 | value (newVal) { |
143 | 147 | this.dates = newVal; |
144 | - this.panelDate = this.startDate || this.dates[0] || new Date(); | |
148 | + this.panelDate = this.startDate || (this.multiple ? this.dates[this.dates.length - 1] : this.dates[0]) || new Date(); | |
145 | 149 | }, |
146 | 150 | currentView (currentView) { |
147 | 151 | this.$emit('on-selection-mode-change', currentView); | ... | ... |
src/components/date-picker/picker.vue
... | ... | @@ -47,6 +47,7 @@ |
47 | 47 | :split-panels="splitPanels" |
48 | 48 | :show-week-numbers="showWeekNumbers" |
49 | 49 | :picker-type="type" |
50 | + :multiple="multiple" | |
50 | 51 | |
51 | 52 | :time-picker-options="timePickerOptions" |
52 | 53 | |
... | ... | @@ -198,6 +199,7 @@ |
198 | 199 | publicStringValue(){ |
199 | 200 | const {formatDate, publicVModelValue, type} = this; |
200 | 201 | if (type.match(/^time/)) return publicVModelValue; |
202 | + if (this.multiple) return formatDate(publicVModelValue); | |
201 | 203 | return Array.isArray(publicVModelValue) ? publicVModelValue.map(formatDate) : formatDate(publicVModelValue); |
202 | 204 | }, |
203 | 205 | opened () { | ... | ... |