Commit 63bd0f7d3fda0cb15a6f83705f8c71ed2c7108f1

Authored by Sergio Crisostomo
1 parent 4c683651

Add start-date prop to force placing of date picker in date

src/components/date-picker/panel/Date/date-panel-mixin.js
... ... @@ -35,6 +35,9 @@ export default {
35 35 value: {
36 36 type: Array,
37 37 default: () => [initTimeDate(), initTimeDate()]
  38 + },
  39 + startDate: {
  40 + type: Date
38 41 }
39 42 },
40 43 computed: {
... ...
src/components/date-picker/panel/Date/date-range.vue
... ... @@ -129,14 +129,16 @@
129 129 },
130 130 data(){
131 131 const [minDate, maxDate] = this.value.map(date => date || initTimeDate());
  132 + const leftPanelDate = this.startDate ? this.startDate : minDate;
  133 +
132 134 return {
133 135 prefixCls: prefixCls,
134 136 datePrefixCls: datePrefixCls,
135 137 dates: this.value,
136 138 rangeState: {from: this.value[0], to: this.value[1], selecting: minDate && !maxDate},
137 139 currentView: this.selectionMode || 'range',
138   - leftPanelDate: minDate,
139   - rightPanelDate: new Date(minDate.getFullYear(), minDate.getMonth() + 1, minDate.getDate())
  140 + leftPanelDate: leftPanelDate,
  141 + rightPanelDate: new Date(leftPanelDate.getFullYear(), leftPanelDate.getMonth() + 1, leftPanelDate.getDate())
140 142 };
141 143 },
142 144 computed: {
... ...
src/components/date-picker/panel/Date/date.vue
... ... @@ -97,7 +97,7 @@
97 97 datePrefixCls: datePrefixCls,
98 98 currentView: this.selectionMode || 'date',
99 99 dates: dates,
100   - panelDate: dates[0] || new Date()
  100 + panelDate: this.startDate || dates[0] || new Date()
101 101 };
102 102 },
103 103 computed: {
... ...
src/components/date-picker/picker.vue
... ... @@ -39,6 +39,7 @@
39 39 :steps="steps"
40 40 :format="format"
41 41 :value="internalValue"
  42 + :start-date="startDate"
42 43  
43 44 v-bind="ownPickerProps"
44 45  
... ... @@ -204,6 +205,9 @@
204 205 type: Boolean,
205 206 default: false
206 207 },
  208 + startDate: {
  209 + type: Date
  210 + },
207 211 size: {
208 212 validator (value) {
209 213 return oneOf(value, ['small', 'large', 'default']);
... ...