mirror of https://github.com/ElemeFE/element
DatePicker: fix set initial value
parent
1cae9b35b3
commit
7de5306b27
|
@ -30,7 +30,7 @@
|
||||||
</table>
|
</table>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script type="text/ecmascript-6">
|
<script>
|
||||||
import { $t, getFirstDayOfMonth, getDayCountOfMonth, getWeekNumber, getStartDateOfMonth, DAY_DURATION } from '../util';
|
import { $t, getFirstDayOfMonth, getDayCountOfMonth, getWeekNumber, getStartDateOfMonth, DAY_DURATION } from '../util';
|
||||||
import { hasClass } from 'wind-dom/src/class';
|
import { hasClass } from 'wind-dom/src/class';
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
|
|
|
@ -129,7 +129,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script type="text/ecmascript-6">
|
<script type="text/ecmascript-6">
|
||||||
import { nextMonth, prevMonth, $t, formatDate, parseDate } from '../util';
|
import { nextMonth, prevMonth, toDate, $t, formatDate, parseDate } from '../util';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -292,8 +292,8 @@
|
||||||
this.minDate = null;
|
this.minDate = null;
|
||||||
this.maxDate = null;
|
this.maxDate = null;
|
||||||
} else if (Array.isArray(newVal)) {
|
} else if (Array.isArray(newVal)) {
|
||||||
this.minDate = newVal[0];
|
this.minDate = toDate(newVal[0]);
|
||||||
this.maxDate = newVal[1];
|
this.maxDate = toDate(newVal[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -290,9 +290,7 @@ export default {
|
||||||
const type = this.type;
|
const type = this.type;
|
||||||
|
|
||||||
if (HAVE_TRIGGER_TYPES.indexOf(type) !== -1) {
|
if (HAVE_TRIGGER_TYPES.indexOf(type) !== -1) {
|
||||||
if (!this.pickerVisible) {
|
this.pickerVisible = !this.pickerVisible;
|
||||||
this.showPicker();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.$emit('focus', this);
|
this.$emit('focus', this);
|
||||||
},
|
},
|
||||||
|
@ -451,7 +449,7 @@ export default {
|
||||||
this.$emit('input', date);
|
this.$emit('input', date);
|
||||||
|
|
||||||
if (!visible) {
|
if (!visible) {
|
||||||
this.pickerVisible = this.picker.visible = false;
|
this.pickerVisible = this.picker.visible = !this.picker.visible;
|
||||||
}
|
}
|
||||||
this.picker.resetView && this.picker.resetView();
|
this.picker.resetView && this.picker.resetView();
|
||||||
});
|
});
|
||||||
|
@ -467,10 +465,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
if (this.popper) {
|
if (this.popper) return;
|
||||||
this.popper.update();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.popper = new Popper(this.$refs.reference, this.picker.$el, {
|
this.popper = new Popper(this.$refs.reference, this.picker.$el, {
|
||||||
gpuAcceleration: false,
|
gpuAcceleration: false,
|
||||||
|
|
|
@ -24,9 +24,15 @@ export const merge = function(target) {
|
||||||
return target;
|
return target;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const formatDate = function(date, format) {
|
export const toDate = function(date) {
|
||||||
date = new Date(date);
|
date = new Date(date);
|
||||||
if (isNaN(date.getTime())) return '';
|
if (isNaN(date.getTime())) return null;
|
||||||
|
return date;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const formatDate = function(date, format) {
|
||||||
|
date = toDate(date);
|
||||||
|
if (!date) return '';
|
||||||
return dateUtil.format(date, format || 'yyyy-MM-dd');
|
return dateUtil.format(date, format || 'yyyy-MM-dd');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue