Commit f92ef70f4602da625428a7a924303ab2d3b3eaee

Authored by 梁灏
1 parent 3732707e

update DatePicker

update DatePicker
src/components/date-picker/panel/date-range.vue
@@ -234,14 +234,29 @@ @@ -234,14 +234,29 @@
234 } 234 }
235 }, 235 },
236 methods: { 236 methods: {
  237 + resetDate () {
  238 + this.date = new Date(this.date);
  239 + this.leftTableYear = this.date.getFullYear();
  240 + this.rightTableYear = this.rightDate.getFullYear();
  241 + },
237 handleClear() { 242 handleClear() {
238 this.minDate = null; 243 this.minDate = null;
239 this.maxDate = null; 244 this.maxDate = null;
  245 + this.date = new Date();
240 this.handleConfirm(); 246 this.handleConfirm();
241 }, 247 },
  248 + resetView() {
  249 + this.leftCurrentView = 'date';
  250 + this.rightCurrentView = 'date';
  251 +
  252 + this.leftTableYear = this.leftYear;
  253 + this.rightTableYear = this.rightYear;
  254 + },
242 prevYear (direction) { 255 prevYear (direction) {
243 if (this[`${direction}CurrentView`] === 'year') { 256 if (this[`${direction}CurrentView`] === 'year') {
244 this.$refs[`${direction}YearTable`].prevTenYear(); 257 this.$refs[`${direction}YearTable`].prevTenYear();
  258 + } else if (this[`${direction}CurrentView`] === 'month') {
  259 + this[`${direction}TableYear`]--;
245 } else { 260 } else {
246 const date = this.date; 261 const date = this.date;
247 date.setFullYear(date.getFullYear() - 1); 262 date.setFullYear(date.getFullYear() - 1);
@@ -251,6 +266,8 @@ @@ -251,6 +266,8 @@
251 nextYear (direction) { 266 nextYear (direction) {
252 if (this[`${direction}CurrentView`] === 'year') { 267 if (this[`${direction}CurrentView`] === 'year') {
253 this.$refs[`${direction}YearTable`].nextTenYear(); 268 this.$refs[`${direction}YearTable`].nextTenYear();
  269 + } else if (this[`${direction}CurrentView`] === 'month') {
  270 + this[`${direction}TableYear`]--;
254 } else { 271 } else {
255 const date = this.date; 272 const date = this.date;
256 date.setFullYear(date.getFullYear() + 1); 273 date.setFullYear(date.getFullYear() + 1);
src/components/date-picker/panel/date.vue
@@ -124,6 +124,9 @@ @@ -124,6 +124,9 @@
124 } 124 }
125 }, 125 },
126 methods: { 126 methods: {
  127 + resetDate () {
  128 + this.date = new Date(this.date);
  129 + },
127 handleClear() { 130 handleClear() {
128 this.date = new Date(); 131 this.date = new Date();
129 this.$emit('on-pick', ''); 132 this.$emit('on-pick', '');
src/components/date-picker/panel/mixin.js
@@ -13,9 +13,6 @@ export default { @@ -13,9 +13,6 @@ export default {
13 handleShortcutClick (shortcut) { 13 handleShortcutClick (shortcut) {
14 if (shortcut.value) this.$emit('on-pick', shortcut.value()); 14 if (shortcut.value) this.$emit('on-pick', shortcut.value());
15 if (shortcut.onClick) shortcut.onClick(this); 15 if (shortcut.onClick) shortcut.onClick(this);
16 - },  
17 - resetDate () {  
18 - this.date = new Date(this.date);  
19 } 16 }
20 } 17 }
21 } 18 }
22 \ No newline at end of file 19 \ No newline at end of file