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