Commit 344131a7af7e70a30eba662aea0f77cb03d8d21e

Authored by 梁灏
1 parent e1874103

update DatePicker

update DatePicker
src/components/date-picker/base/year-table.vue
... ... @@ -67,6 +67,7 @@
67 67 if (target.tagName === 'EM') {
68 68 const cell = this.cells[parseInt(event.target.getAttribute('index'))];
69 69 if (cell.disabled) return;
  70 +
70 71 this.$emit('on-pick', cell.text);
71 72 }
72 73 }
... ...
src/components/date-picker/panel/date.vue
... ... @@ -178,7 +178,7 @@
178 178  
179 179 this.date.setFullYear(year);
180 180 if (this.selectionMode === 'year') {
181   - this.$emit('on-pick', new Date(year));
  181 + this.$emit('on-pick', new Date(year, 0, 1));
182 182 } else {
183 183 this.currentView = 'month';
184 184 }
... ...
src/components/date-picker/picker.vue
... ... @@ -269,6 +269,8 @@
269 269 this.visualValue = correctValue;
270 270 event.target.value = correctValue;
271 271 this.internalValue = correctDate;
  272 +
  273 + if (correctValue !== oldValue) this.emitChange(correctDate);
272 274 },
273 275 handleInputMouseenter () {
274 276 if (this.readonly || this.disabled) return;
... ... @@ -298,7 +300,7 @@
298 300 }
299 301  
300 302 this.picker.$on('on-pick', (date, visible = false) => {
301   - this.$emit('on-change', formatDate(date, this.format || DEFAULT_FORMATS[this.type]));
  303 + this.emitChange(date);
302 304 this.value = date;
303 305 this.visible = visible;
304 306 this.picker.value = date;
... ... @@ -313,6 +315,9 @@
313 315 this.picker.value = this.internalValue;
314 316 }
315 317 this.picker.resetView && this.picker.resetView();
  318 + },
  319 + emitChange (date) {
  320 + this.$emit('on-change', formatDate(date, this.format || DEFAULT_FORMATS[this.type]));
316 321 }
317 322 },
318 323 watch: {
... ...
test/routers/date.vue
... ... @@ -33,13 +33,13 @@
33 33 // return time && time.valueOf() < Date.now();
34 34 }
35 35 },
36   - format: 'yyyy/MM/dd'
  36 + format: 'yyyy年MM月dd日'
37 37 }
38 38 },
39 39 computed: {},
40 40 methods: {
41 41 change (date) {
42   -// console.log(date)
  42 + console.log(date)
43 43 },
44 44 change2 (s) {
45 45 // console.log(s)
... ...