update DatePicker

update DatePicker
This commit is contained in:
梁灏 2016-12-19 22:18:57 +08:00
parent 3732707ede
commit f92ef70f46
3 changed files with 20 additions and 3 deletions

View file

@ -234,14 +234,29 @@
} }
}, },
methods: { methods: {
resetDate () {
this.date = new Date(this.date);
this.leftTableYear = this.date.getFullYear();
this.rightTableYear = this.rightDate.getFullYear();
},
handleClear() { handleClear() {
this.minDate = null; this.minDate = null;
this.maxDate = null; this.maxDate = null;
this.date = new Date();
this.handleConfirm(); this.handleConfirm();
}, },
resetView() {
this.leftCurrentView = 'date';
this.rightCurrentView = 'date';
this.leftTableYear = this.leftYear;
this.rightTableYear = this.rightYear;
},
prevYear (direction) { prevYear (direction) {
if (this[`${direction}CurrentView`] === 'year') { if (this[`${direction}CurrentView`] === 'year') {
this.$refs[`${direction}YearTable`].prevTenYear(); this.$refs[`${direction}YearTable`].prevTenYear();
} else if (this[`${direction}CurrentView`] === 'month') {
this[`${direction}TableYear`]--;
} else { } else {
const date = this.date; const date = this.date;
date.setFullYear(date.getFullYear() - 1); date.setFullYear(date.getFullYear() - 1);
@ -251,6 +266,8 @@
nextYear (direction) { nextYear (direction) {
if (this[`${direction}CurrentView`] === 'year') { if (this[`${direction}CurrentView`] === 'year') {
this.$refs[`${direction}YearTable`].nextTenYear(); this.$refs[`${direction}YearTable`].nextTenYear();
} else if (this[`${direction}CurrentView`] === 'month') {
this[`${direction}TableYear`]--;
} else { } else {
const date = this.date; const date = this.date;
date.setFullYear(date.getFullYear() + 1); date.setFullYear(date.getFullYear() + 1);

View file

@ -124,6 +124,9 @@
} }
}, },
methods: { methods: {
resetDate () {
this.date = new Date(this.date);
},
handleClear() { handleClear() {
this.date = new Date(); this.date = new Date();
this.$emit('on-pick', ''); this.$emit('on-pick', '');

View file

@ -13,9 +13,6 @@ export default {
handleShortcutClick (shortcut) { handleShortcutClick (shortcut) {
if (shortcut.value) this.$emit('on-pick', shortcut.value()); if (shortcut.value) this.$emit('on-pick', shortcut.value());
if (shortcut.onClick) shortcut.onClick(this); if (shortcut.onClick) shortcut.onClick(this);
},
resetDate () {
this.date = new Date(this.date);
} }
} }
} }