Commit 90ebd5a72cd2f18e9cb43c248052a9266c15bbbc
1 parent
eed57084
Expose changed date component
Showing
6 changed files
with
14 additions
and
14 deletions
Show diff stats
src/components/date-picker/panel/Date/date-range.vue
| @@ -317,7 +317,7 @@ | @@ -317,7 +317,7 @@ | ||
| 317 | this.changePanelDate(otherPanel, 'Month', 1, false); | 317 | this.changePanelDate(otherPanel, 'Month', 1, false); |
| 318 | } | 318 | } |
| 319 | }, | 319 | }, |
| 320 | - handleRangePick (val) { | 320 | + handleRangePick (val, type) { |
| 321 | if (this.rangeState.selecting || this.currentView === 'time'){ | 321 | if (this.rangeState.selecting || this.currentView === 'time'){ |
| 322 | if (this.currentView === 'time'){ | 322 | if (this.currentView === 'time'){ |
| 323 | this.dates = val; | 323 | this.dates = val; |
| @@ -330,7 +330,7 @@ | @@ -330,7 +330,7 @@ | ||
| 330 | selecting: false | 330 | selecting: false |
| 331 | }; | 331 | }; |
| 332 | } | 332 | } |
| 333 | - this.handleConfirm(false); | 333 | + this.handleConfirm(false, type || 'date'); |
| 334 | } else { | 334 | } else { |
| 335 | this.rangeState = { | 335 | this.rangeState = { |
| 336 | from: val, | 336 | from: val, |
src/components/date-picker/panel/Date/date.vue
| @@ -188,14 +188,14 @@ | @@ -188,14 +188,14 @@ | ||
| 188 | else this.pickerTable = this.getTableType(this.currentView); | 188 | else this.pickerTable = this.getTableType(this.currentView); |
| 189 | 189 | ||
| 190 | }, | 190 | }, |
| 191 | - handlePick (value) { | 191 | + handlePick (value, type) { |
| 192 | const {selectionMode, panelDate} = this; | 192 | const {selectionMode, panelDate} = this; |
| 193 | if (selectionMode === 'year') value = new Date(value.getFullYear(), 0, 1); | 193 | if (selectionMode === 'year') value = new Date(value.getFullYear(), 0, 1); |
| 194 | else if (selectionMode === 'month') value = new Date(panelDate.getFullYear(), value.getMonth(), 1); | 194 | else if (selectionMode === 'month') value = new Date(panelDate.getFullYear(), value.getMonth(), 1); |
| 195 | else value = new Date(value); | 195 | else value = new Date(value); |
| 196 | 196 | ||
| 197 | this.dates = [value]; | 197 | this.dates = [value]; |
| 198 | - this.$emit('on-pick', value); | 198 | + this.$emit('on-pick', value, false, type || selectionMode); |
| 199 | }, | 199 | }, |
| 200 | }, | 200 | }, |
| 201 | }; | 201 | }; |
src/components/date-picker/panel/Time/time-range.vue
| @@ -142,7 +142,7 @@ | @@ -142,7 +142,7 @@ | ||
| 142 | // judge endTime > startTime? | 142 | // judge endTime > startTime? |
| 143 | if (dateEnd < dateStart) dateEnd = dateStart; | 143 | if (dateEnd < dateStart) dateEnd = dateStart; |
| 144 | 144 | ||
| 145 | - if (emit) this.$emit('on-pick', [dateStart, dateEnd], true); | 145 | + if (emit) this.$emit('on-pick', [dateStart, dateEnd], 'time'); |
| 146 | }, | 146 | }, |
| 147 | handleStartChange (date) { | 147 | handleStartChange (date) { |
| 148 | this.handleChange(date, {}); | 148 | this.handleChange(date, {}); |
src/components/date-picker/panel/Time/time.vue
| @@ -135,7 +135,7 @@ | @@ -135,7 +135,7 @@ | ||
| 135 | type => newDate[`set${capitalize(type)}`](date[type]) | 135 | type => newDate[`set${capitalize(type)}`](date[type]) |
| 136 | ); | 136 | ); |
| 137 | 137 | ||
| 138 | - if (emit) this.$emit('on-pick', newDate, true); | 138 | + if (emit) this.$emit('on-pick', newDate, 'time'); |
| 139 | }, | 139 | }, |
| 140 | }, | 140 | }, |
| 141 | mounted () { | 141 | mounted () { |
src/components/date-picker/panel/panel-mixin.js
| @@ -44,8 +44,8 @@ export default { | @@ -44,8 +44,8 @@ export default { | ||
| 44 | this.handleConfirm(); | 44 | this.handleConfirm(); |
| 45 | // if (this.showTime) this.$refs.timePicker.handleClear(); | 45 | // if (this.showTime) this.$refs.timePicker.handleClear(); |
| 46 | }, | 46 | }, |
| 47 | - handleConfirm(visible) { | ||
| 48 | - this.$emit('on-pick', this.dates, visible); | 47 | + handleConfirm(visible, type) { |
| 48 | + this.$emit('on-pick', this.dates, visible, type || this.type); | ||
| 49 | }, | 49 | }, |
| 50 | onToggleVisibility(open){ | 50 | onToggleVisibility(open){ |
| 51 | const {timeSpinner, timeSpinnerEnd} = this.$refs; | 51 | const {timeSpinner, timeSpinnerEnd} = this.$refs; |
src/components/date-picker/picker.vue
| @@ -272,7 +272,7 @@ | @@ -272,7 +272,7 @@ | ||
| 272 | const isValidDate = newDate.reduce((valid, date) => valid && date instanceof Date, true); | 272 | const isValidDate = newDate.reduce((valid, date) => valid && date instanceof Date, true); |
| 273 | 273 | ||
| 274 | if (newValue !== oldValue && !isDisabled && isValidDate) { | 274 | if (newValue !== oldValue && !isDisabled && isValidDate) { |
| 275 | - this.emitChange(); | 275 | + this.emitChange(this.type); |
| 276 | this.internalValue = newDate; | 276 | this.internalValue = newDate; |
| 277 | } else { | 277 | } else { |
| 278 | this.forceInputRerender++; | 278 | this.forceInputRerender++; |
| @@ -299,7 +299,7 @@ | @@ -299,7 +299,7 @@ | ||
| 299 | this.internalValue = this.internalValue.map(() => null); | 299 | this.internalValue = this.internalValue.map(() => null); |
| 300 | this.$emit('on-clear'); | 300 | this.$emit('on-clear'); |
| 301 | this.dispatch('FormItem', 'on-form-change', ''); | 301 | this.dispatch('FormItem', 'on-form-change', ''); |
| 302 | - this.emitChange(); | 302 | + this.emitChange(this.type); |
| 303 | this.reset(); | 303 | this.reset(); |
| 304 | 304 | ||
| 305 | setTimeout( | 305 | setTimeout( |
| @@ -307,9 +307,9 @@ | @@ -307,9 +307,9 @@ | ||
| 307 | 500 // delay to improve dropdown close visual effect | 307 | 500 // delay to improve dropdown close visual effect |
| 308 | ); | 308 | ); |
| 309 | }, | 309 | }, |
| 310 | - emitChange () { | 310 | + emitChange (type) { |
| 311 | this.$nextTick(() => { | 311 | this.$nextTick(() => { |
| 312 | - this.$emit('on-change', this.publicStringValue); | 312 | + this.$emit('on-change', this.publicStringValue, type); |
| 313 | this.dispatch('FormItem', 'on-form-change', this.publicStringValue); | 313 | this.dispatch('FormItem', 'on-form-change', this.publicStringValue); |
| 314 | }); | 314 | }); |
| 315 | }, | 315 | }, |
| @@ -366,7 +366,7 @@ | @@ -366,7 +366,7 @@ | ||
| 366 | return formatter(value, this.format || format); | 366 | return formatter(value, this.format || format); |
| 367 | } | 367 | } |
| 368 | }, | 368 | }, |
| 369 | - onPick(dates, visible = false) { | 369 | + onPick(dates, visible = false, type) { |
| 370 | if (this.multiple){ | 370 | if (this.multiple){ |
| 371 | const pickedTimeStamp = dates.getTime(); | 371 | const pickedTimeStamp = dates.getTime(); |
| 372 | const indexOfPickedDate = this.internalValue.findIndex(date => date && date.getTime() === pickedTimeStamp); | 372 | const indexOfPickedDate = this.internalValue.findIndex(date => date && date.getTime() === pickedTimeStamp); |
| @@ -379,7 +379,7 @@ | @@ -379,7 +379,7 @@ | ||
| 379 | 379 | ||
| 380 | if (!this.isConfirm) this.onSelectionModeChange(this.type); // reset the selectionMode | 380 | if (!this.isConfirm) this.onSelectionModeChange(this.type); // reset the selectionMode |
| 381 | if (!this.isConfirm) this.visible = visible; | 381 | if (!this.isConfirm) this.visible = visible; |
| 382 | - this.emitChange(); | 382 | + this.emitChange(type); |
| 383 | }, | 383 | }, |
| 384 | onPickSuccess(){ | 384 | onPickSuccess(){ |
| 385 | this.visible = false; | 385 | this.visible = false; |