Expose changed date component
This commit is contained in:
parent
eed5708494
commit
90ebd5a72c
6 changed files with 14 additions and 14 deletions
|
@ -317,7 +317,7 @@
|
||||||
this.changePanelDate(otherPanel, 'Month', 1, false);
|
this.changePanelDate(otherPanel, 'Month', 1, false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleRangePick (val) {
|
handleRangePick (val, type) {
|
||||||
if (this.rangeState.selecting || this.currentView === 'time'){
|
if (this.rangeState.selecting || this.currentView === 'time'){
|
||||||
if (this.currentView === 'time'){
|
if (this.currentView === 'time'){
|
||||||
this.dates = val;
|
this.dates = val;
|
||||||
|
@ -330,7 +330,7 @@
|
||||||
selecting: false
|
selecting: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
this.handleConfirm(false);
|
this.handleConfirm(false, type || 'date');
|
||||||
} else {
|
} else {
|
||||||
this.rangeState = {
|
this.rangeState = {
|
||||||
from: val,
|
from: val,
|
||||||
|
|
|
@ -188,14 +188,14 @@
|
||||||
else this.pickerTable = this.getTableType(this.currentView);
|
else this.pickerTable = this.getTableType(this.currentView);
|
||||||
|
|
||||||
},
|
},
|
||||||
handlePick (value) {
|
handlePick (value, type) {
|
||||||
const {selectionMode, panelDate} = this;
|
const {selectionMode, panelDate} = this;
|
||||||
if (selectionMode === 'year') value = new Date(value.getFullYear(), 0, 1);
|
if (selectionMode === 'year') value = new Date(value.getFullYear(), 0, 1);
|
||||||
else if (selectionMode === 'month') value = new Date(panelDate.getFullYear(), value.getMonth(), 1);
|
else if (selectionMode === 'month') value = new Date(panelDate.getFullYear(), value.getMonth(), 1);
|
||||||
else value = new Date(value);
|
else value = new Date(value);
|
||||||
|
|
||||||
this.dates = [value];
|
this.dates = [value];
|
||||||
this.$emit('on-pick', value);
|
this.$emit('on-pick', value, false, type || selectionMode);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -142,7 +142,7 @@
|
||||||
// judge endTime > startTime?
|
// judge endTime > startTime?
|
||||||
if (dateEnd < dateStart) dateEnd = dateStart;
|
if (dateEnd < dateStart) dateEnd = dateStart;
|
||||||
|
|
||||||
if (emit) this.$emit('on-pick', [dateStart, dateEnd], true);
|
if (emit) this.$emit('on-pick', [dateStart, dateEnd], 'time');
|
||||||
},
|
},
|
||||||
handleStartChange (date) {
|
handleStartChange (date) {
|
||||||
this.handleChange(date, {});
|
this.handleChange(date, {});
|
||||||
|
|
|
@ -135,7 +135,7 @@
|
||||||
type => newDate[`set${capitalize(type)}`](date[type])
|
type => newDate[`set${capitalize(type)}`](date[type])
|
||||||
);
|
);
|
||||||
|
|
||||||
if (emit) this.$emit('on-pick', newDate, true);
|
if (emit) this.$emit('on-pick', newDate, 'time');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
|
|
|
@ -44,8 +44,8 @@ export default {
|
||||||
this.handleConfirm();
|
this.handleConfirm();
|
||||||
// if (this.showTime) this.$refs.timePicker.handleClear();
|
// if (this.showTime) this.$refs.timePicker.handleClear();
|
||||||
},
|
},
|
||||||
handleConfirm(visible) {
|
handleConfirm(visible, type) {
|
||||||
this.$emit('on-pick', this.dates, visible);
|
this.$emit('on-pick', this.dates, visible, type || this.type);
|
||||||
},
|
},
|
||||||
onToggleVisibility(open){
|
onToggleVisibility(open){
|
||||||
const {timeSpinner, timeSpinnerEnd} = this.$refs;
|
const {timeSpinner, timeSpinnerEnd} = this.$refs;
|
||||||
|
|
|
@ -272,7 +272,7 @@
|
||||||
const isValidDate = newDate.reduce((valid, date) => valid && date instanceof Date, true);
|
const isValidDate = newDate.reduce((valid, date) => valid && date instanceof Date, true);
|
||||||
|
|
||||||
if (newValue !== oldValue && !isDisabled && isValidDate) {
|
if (newValue !== oldValue && !isDisabled && isValidDate) {
|
||||||
this.emitChange();
|
this.emitChange(this.type);
|
||||||
this.internalValue = newDate;
|
this.internalValue = newDate;
|
||||||
} else {
|
} else {
|
||||||
this.forceInputRerender++;
|
this.forceInputRerender++;
|
||||||
|
@ -299,7 +299,7 @@
|
||||||
this.internalValue = this.internalValue.map(() => null);
|
this.internalValue = this.internalValue.map(() => null);
|
||||||
this.$emit('on-clear');
|
this.$emit('on-clear');
|
||||||
this.dispatch('FormItem', 'on-form-change', '');
|
this.dispatch('FormItem', 'on-form-change', '');
|
||||||
this.emitChange();
|
this.emitChange(this.type);
|
||||||
this.reset();
|
this.reset();
|
||||||
|
|
||||||
setTimeout(
|
setTimeout(
|
||||||
|
@ -307,9 +307,9 @@
|
||||||
500 // delay to improve dropdown close visual effect
|
500 // delay to improve dropdown close visual effect
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
emitChange () {
|
emitChange (type) {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$emit('on-change', this.publicStringValue);
|
this.$emit('on-change', this.publicStringValue, type);
|
||||||
this.dispatch('FormItem', 'on-form-change', this.publicStringValue);
|
this.dispatch('FormItem', 'on-form-change', this.publicStringValue);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -366,7 +366,7 @@
|
||||||
return formatter(value, this.format || format);
|
return formatter(value, this.format || format);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onPick(dates, visible = false) {
|
onPick(dates, visible = false, type) {
|
||||||
if (this.multiple){
|
if (this.multiple){
|
||||||
const pickedTimeStamp = dates.getTime();
|
const pickedTimeStamp = dates.getTime();
|
||||||
const indexOfPickedDate = this.internalValue.findIndex(date => date && date.getTime() === pickedTimeStamp);
|
const indexOfPickedDate = this.internalValue.findIndex(date => date && date.getTime() === pickedTimeStamp);
|
||||||
|
@ -379,7 +379,7 @@
|
||||||
|
|
||||||
if (!this.isConfirm) this.onSelectionModeChange(this.type); // reset the selectionMode
|
if (!this.isConfirm) this.onSelectionModeChange(this.type); // reset the selectionMode
|
||||||
if (!this.isConfirm) this.visible = visible;
|
if (!this.isConfirm) this.visible = visible;
|
||||||
this.emitChange();
|
this.emitChange(type);
|
||||||
},
|
},
|
||||||
onPickSuccess(){
|
onPickSuccess(){
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue