fix(Calendar): should show range prompt after select

This commit is contained in:
陈嘉涵
2020-01-15 18:54:01 +08:00
parent b41abcde48
commit ff09011e0e
7 changed files with 28 additions and 16 deletions
+22 -10
View File
@@ -23,8 +23,9 @@ export default createComponent({
color: String,
value: Boolean,
formatter: Function,
defaultDate: [Date, Array],
confirmText: String,
rangePrompt: String,
defaultDate: [Date, Array],
confirmDisabledText: String,
type: {
type: String,
@@ -78,12 +79,6 @@ export default createComponent({
maxRange: {
type: Number,
default: null
},
rangePrompt: {
type: String,
default() {
return t('rangePromptText', this.maxRange);
}
}
},
@@ -260,15 +255,32 @@ export default createComponent({
this.currentDate = date;
this.$emit('select', this.currentDate);
if (complete && this.type === 'range') {
const valid = this.checkRange();
if (!valid) {
return;
}
}
if (complete && !this.showConfirm) {
this.onConfirm();
}
},
checkRange() {
const { maxRange, currentDate, rangePrompt } = this;
if (maxRange && calcDateNum(currentDate) > maxRange) {
Toast(rangePrompt || t('rangePrompt', maxRange));
return false;
}
return true;
},
onConfirm() {
if (this.maxRange && calcDateNum(this.currentDate) > this.maxRange) {
Toast(this.rangePrompt);
} else {
if (this.checkRange()) {
this.$emit('confirm', this.currentDate);
}
},