mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
feat(Calendar): add over-range event (#4212)
* feat(Calendar): add over-range event - forbid range-prompt toast when range-prompt is null - emit over-range event when dateRange > maxRange * docs(Calendar): doc typo * feat(Calendar): add show-range-prompt prop * docs(calendar): doc modify
This commit is contained in:
parent
e835808a39
commit
0d08ec1489
@ -294,7 +294,8 @@ Page({
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
| --- | --- | --- | --- |
|
||||
| max-range | 日期区间最多可选天数,默认无限制 | _number \| string_ | - |
|
||||
| range-prompt | 范围选择超过最多可选天数时的提示文案 | _string_ | `选择天数不能超过 xx 天` |
|
||||
| range-prompt | 范围选择超过最多可选天数时的提示文案 | _string \| null_ | `选择天数不能超过 xx 天` |
|
||||
| show-range-prompt | 范围选择超过最多可选天数时,是否展示提示文案 | _boolean_ | `true` |
|
||||
| allow-same-day | 是否允许日期范围的起止时间为同一天 | _boolean_ | `false` |
|
||||
|
||||
### Day 数据结构
|
||||
@ -320,6 +321,7 @@ Page({
|
||||
| close | 关闭弹出层时触发 | - |
|
||||
| opened | 打开弹出层且动画结束后触发 | - |
|
||||
| closed | 关闭弹出层且动画结束后触发 | - |
|
||||
| over-range | 范围选择超过最多可选天数时触发 | - |
|
||||
|
||||
### Slots
|
||||
|
||||
|
@ -36,6 +36,10 @@ VantComponent({
|
||||
value: '确定',
|
||||
},
|
||||
rangePrompt: String,
|
||||
showRangePrompt: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
defaultDate: {
|
||||
type: null,
|
||||
observer(val) {
|
||||
@ -308,13 +312,18 @@ VantComponent({
|
||||
},
|
||||
|
||||
checkRange(date) {
|
||||
const { maxRange, rangePrompt } = this.data;
|
||||
const { maxRange, rangePrompt, showRangePrompt } = this.data;
|
||||
|
||||
if (maxRange && calcDateNum(date) > maxRange) {
|
||||
Toast({
|
||||
context: this,
|
||||
message: rangePrompt || `选择天数不能超过 ${maxRange} 天`,
|
||||
});
|
||||
if (showRangePrompt) {
|
||||
Toast({
|
||||
duration: 0,
|
||||
context: this,
|
||||
message: rangePrompt || `选择天数不能超过 ${maxRange} 天`,
|
||||
});
|
||||
}
|
||||
this.$emit('over-range');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user