feat(Calendar): add max-range、range-prompt prop (#5583)

This commit is contained in:
KongYe
2020-01-15 16:34:13 +08:00
committed by neverland
parent cfd40f2eaf
commit 670b346963
11 changed files with 45 additions and 8 deletions
+17 -1
View File
@@ -7,11 +7,13 @@ import {
compareDay,
compareMonth,
createComponent,
calcDateNum,
ROW_HEIGHT
} from './utils';
import Popup from '../popup';
import Button from '../button';
import Toast from '../toast';
import Month from './components/Month';
import Header from './components/Header';
@@ -72,6 +74,16 @@ export default createComponent({
closeOnClickOverlay: {
type: Boolean,
default: true
},
maxRange: {
type: Number,
default: null
},
rangePrompt: {
type: String,
default() {
return t('rangePromptText', this.maxRange);
}
}
},
@@ -254,7 +266,11 @@ export default createComponent({
},
onConfirm() {
this.$emit('confirm', this.currentDate);
if (this.maxRange && calcDateNum(this.currentDate) > this.maxRange) {
Toast(this.rangePrompt);
} else {
this.$emit('confirm', this.currentDate);
}
},
genMonth(date, index) {