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