From 63bd0f7d3fda0cb15a6f83705f8c71ed2c7108f1 Mon Sep 17 00:00:00 2001 From: Sergio Crisostomo Date: Wed, 17 Jan 2018 13:05:15 +0100 Subject: [PATCH] Add start-date prop to force placing of date picker in date --- src/components/date-picker/panel/Date/date-panel-mixin.js | 3 +++ src/components/date-picker/panel/Date/date-range.vue | 6 ++++-- src/components/date-picker/panel/Date/date.vue | 2 +- src/components/date-picker/picker.vue | 4 ++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/date-picker/panel/Date/date-panel-mixin.js b/src/components/date-picker/panel/Date/date-panel-mixin.js index 3c4ec99..8050ced 100644 --- a/src/components/date-picker/panel/Date/date-panel-mixin.js +++ b/src/components/date-picker/panel/Date/date-panel-mixin.js @@ -35,6 +35,9 @@ export default { value: { type: Array, default: () => [initTimeDate(), initTimeDate()] + }, + startDate: { + type: Date } }, computed: { diff --git a/src/components/date-picker/panel/Date/date-range.vue b/src/components/date-picker/panel/Date/date-range.vue index f0225d3..8e7a884 100644 --- a/src/components/date-picker/panel/Date/date-range.vue +++ b/src/components/date-picker/panel/Date/date-range.vue @@ -129,14 +129,16 @@ }, data(){ const [minDate, maxDate] = this.value.map(date => date || initTimeDate()); + const leftPanelDate = this.startDate ? this.startDate : minDate; + return { prefixCls: prefixCls, datePrefixCls: datePrefixCls, dates: this.value, rangeState: {from: this.value[0], to: this.value[1], selecting: minDate && !maxDate}, currentView: this.selectionMode || 'range', - leftPanelDate: minDate, - rightPanelDate: new Date(minDate.getFullYear(), minDate.getMonth() + 1, minDate.getDate()) + leftPanelDate: leftPanelDate, + rightPanelDate: new Date(leftPanelDate.getFullYear(), leftPanelDate.getMonth() + 1, leftPanelDate.getDate()) }; }, computed: { diff --git a/src/components/date-picker/panel/Date/date.vue b/src/components/date-picker/panel/Date/date.vue index 052ce87..adec411 100644 --- a/src/components/date-picker/panel/Date/date.vue +++ b/src/components/date-picker/panel/Date/date.vue @@ -97,7 +97,7 @@ datePrefixCls: datePrefixCls, currentView: this.selectionMode || 'date', dates: dates, - panelDate: dates[0] || new Date() + panelDate: this.startDate || dates[0] || new Date() }; }, computed: { diff --git a/src/components/date-picker/picker.vue b/src/components/date-picker/picker.vue index 17982a3..67566ef 100644 --- a/src/components/date-picker/picker.vue +++ b/src/components/date-picker/picker.vue @@ -39,6 +39,7 @@ :steps="steps" :format="format" :value="internalValue" + :start-date="startDate" v-bind="ownPickerProps" @@ -204,6 +205,9 @@ type: Boolean, default: false }, + startDate: { + type: Date + }, size: { validator (value) { return oneOf(value, ['small', 'large', 'default']); -- libgit2 0.21.4