Commit 90ebd5a72cd2f18e9cb43c248052a9266c15bbbc

Authored by Sergio Crisostomo
1 parent eed57084

Expose changed date component

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