Commit 344131a7af7e70a30eba662aea0f77cb03d8d21e
1 parent
e1874103
update DatePicker
update DatePicker
Showing
4 changed files
with
10 additions
and
4 deletions
Show diff stats
src/components/date-picker/base/year-table.vue
| @@ -67,6 +67,7 @@ | @@ -67,6 +67,7 @@ | ||
| 67 | if (target.tagName === 'EM') { | 67 | if (target.tagName === 'EM') { |
| 68 | const cell = this.cells[parseInt(event.target.getAttribute('index'))]; | 68 | const cell = this.cells[parseInt(event.target.getAttribute('index'))]; |
| 69 | if (cell.disabled) return; | 69 | if (cell.disabled) return; |
| 70 | + | ||
| 70 | this.$emit('on-pick', cell.text); | 71 | this.$emit('on-pick', cell.text); |
| 71 | } | 72 | } |
| 72 | } | 73 | } |
src/components/date-picker/panel/date.vue
| @@ -178,7 +178,7 @@ | @@ -178,7 +178,7 @@ | ||
| 178 | 178 | ||
| 179 | this.date.setFullYear(year); | 179 | this.date.setFullYear(year); |
| 180 | if (this.selectionMode === 'year') { | 180 | if (this.selectionMode === 'year') { |
| 181 | - this.$emit('on-pick', new Date(year)); | 181 | + this.$emit('on-pick', new Date(year, 0, 1)); |
| 182 | } else { | 182 | } else { |
| 183 | this.currentView = 'month'; | 183 | this.currentView = 'month'; |
| 184 | } | 184 | } |
src/components/date-picker/picker.vue
| @@ -269,6 +269,8 @@ | @@ -269,6 +269,8 @@ | ||
| 269 | this.visualValue = correctValue; | 269 | this.visualValue = correctValue; |
| 270 | event.target.value = correctValue; | 270 | event.target.value = correctValue; |
| 271 | this.internalValue = correctDate; | 271 | this.internalValue = correctDate; |
| 272 | + | ||
| 273 | + if (correctValue !== oldValue) this.emitChange(correctDate); | ||
| 272 | }, | 274 | }, |
| 273 | handleInputMouseenter () { | 275 | handleInputMouseenter () { |
| 274 | if (this.readonly || this.disabled) return; | 276 | if (this.readonly || this.disabled) return; |
| @@ -298,7 +300,7 @@ | @@ -298,7 +300,7 @@ | ||
| 298 | } | 300 | } |
| 299 | 301 | ||
| 300 | this.picker.$on('on-pick', (date, visible = false) => { | 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 | this.value = date; | 304 | this.value = date; |
| 303 | this.visible = visible; | 305 | this.visible = visible; |
| 304 | this.picker.value = date; | 306 | this.picker.value = date; |
| @@ -313,6 +315,9 @@ | @@ -313,6 +315,9 @@ | ||
| 313 | this.picker.value = this.internalValue; | 315 | this.picker.value = this.internalValue; |
| 314 | } | 316 | } |
| 315 | this.picker.resetView && this.picker.resetView(); | 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 | watch: { | 323 | watch: { |
test/routers/date.vue
| @@ -33,13 +33,13 @@ | @@ -33,13 +33,13 @@ | ||
| 33 | // return time && time.valueOf() < Date.now(); | 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 | computed: {}, | 39 | computed: {}, |
| 40 | methods: { | 40 | methods: { |
| 41 | change (date) { | 41 | change (date) { |
| 42 | -// console.log(date) | 42 | + console.log(date) |
| 43 | }, | 43 | }, |
| 44 | change2 (s) { | 44 | change2 (s) { |
| 45 | // console.log(s) | 45 | // console.log(s) |