mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(Calendar): should show range prompt after select
This commit is contained in:
parent
b41abcde48
commit
ff09011e0e
@ -23,8 +23,9 @@ export default createComponent({
|
|||||||
color: String,
|
color: String,
|
||||||
value: Boolean,
|
value: Boolean,
|
||||||
formatter: Function,
|
formatter: Function,
|
||||||
defaultDate: [Date, Array],
|
|
||||||
confirmText: String,
|
confirmText: String,
|
||||||
|
rangePrompt: String,
|
||||||
|
defaultDate: [Date, Array],
|
||||||
confirmDisabledText: String,
|
confirmDisabledText: String,
|
||||||
type: {
|
type: {
|
||||||
type: String,
|
type: String,
|
||||||
@ -78,12 +79,6 @@ export default createComponent({
|
|||||||
maxRange: {
|
maxRange: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: null
|
default: null
|
||||||
},
|
|
||||||
rangePrompt: {
|
|
||||||
type: String,
|
|
||||||
default() {
|
|
||||||
return t('rangePromptText', this.maxRange);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -260,15 +255,32 @@ export default createComponent({
|
|||||||
this.currentDate = date;
|
this.currentDate = date;
|
||||||
this.$emit('select', this.currentDate);
|
this.$emit('select', this.currentDate);
|
||||||
|
|
||||||
|
if (complete && this.type === 'range') {
|
||||||
|
const valid = this.checkRange();
|
||||||
|
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (complete && !this.showConfirm) {
|
if (complete && !this.showConfirm) {
|
||||||
this.onConfirm();
|
this.onConfirm();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
checkRange() {
|
||||||
|
const { maxRange, currentDate, rangePrompt } = this;
|
||||||
|
|
||||||
|
if (maxRange && calcDateNum(currentDate) > maxRange) {
|
||||||
|
Toast(rangePrompt || t('rangePrompt', maxRange));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
onConfirm() {
|
onConfirm() {
|
||||||
if (this.maxRange && calcDateNum(this.currentDate) > this.maxRange) {
|
if (this.checkRange()) {
|
||||||
Toast(this.rangePrompt);
|
|
||||||
} else {
|
|
||||||
this.$emit('confirm', this.currentDate);
|
this.$emit('confirm', this.currentDate);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -18,7 +18,7 @@ export default {
|
|||||||
title: 'Calendar',
|
title: 'Calendar',
|
||||||
weekdays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
|
weekdays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
|
||||||
monthTitle: (year: number, month: number) => `${year}/${month}`,
|
monthTitle: (year: number, month: number) => `${year}/${month}`,
|
||||||
rangePromptText: (maxRange: Number) => `Choose no more than ${maxRange} days`
|
rangePrompt: (maxRange: Number) => `Choose no more than ${maxRange} days`
|
||||||
},
|
},
|
||||||
vanContactCard: {
|
vanContactCard: {
|
||||||
addText: 'Add contact info'
|
addText: 'Add contact info'
|
||||||
|
@ -18,7 +18,7 @@ export default {
|
|||||||
title: 'Calendario',
|
title: 'Calendario',
|
||||||
weekdays: ['Dom', 'Lun', 'Mar', 'Mié', 'Jue', 'Vie', 'Sáb'],
|
weekdays: ['Dom', 'Lun', 'Mar', 'Mié', 'Jue', 'Vie', 'Sáb'],
|
||||||
monthTitle: (year: number, month: number) => `${year}/${month}`,
|
monthTitle: (year: number, month: number) => `${year}/${month}`,
|
||||||
rangePromptText: (maxRange: Number) => `Elija no más de ${maxRange} días`
|
rangePrompt: (maxRange: Number) => `Elija no más de ${maxRange} días`
|
||||||
},
|
},
|
||||||
vanContactCard: {
|
vanContactCard: {
|
||||||
addText: 'Añadir información de contacto'
|
addText: 'Añadir información de contacto'
|
||||||
|
@ -18,7 +18,7 @@ export default {
|
|||||||
title: 'Takvim',
|
title: 'Takvim',
|
||||||
weekdays: ['Paz', 'Pzt', 'Sal', 'Çar', 'Per', 'Cum', 'Cmt'],
|
weekdays: ['Paz', 'Pzt', 'Sal', 'Çar', 'Per', 'Cum', 'Cmt'],
|
||||||
monthTitle: (year: number, month: number) => `${year}/${month}`,
|
monthTitle: (year: number, month: number) => `${year}/${month}`,
|
||||||
rangePromptText: (maxRange: Number) => `En fazla ${maxRange} gün seçin`
|
rangePrompt: (maxRange: Number) => `En fazla ${maxRange} gün seçin`
|
||||||
},
|
},
|
||||||
vanContactCard: {
|
vanContactCard: {
|
||||||
addText: 'Kişi bilgisi ekle'
|
addText: 'Kişi bilgisi ekle'
|
||||||
|
@ -19,7 +19,7 @@ export default {
|
|||||||
confirm: '确定',
|
confirm: '确定',
|
||||||
weekdays: ['日', '一', '二', '三', '四', '五', '六'],
|
weekdays: ['日', '一', '二', '三', '四', '五', '六'],
|
||||||
monthTitle: (year: number, month: number) => `${year}年${month}月`,
|
monthTitle: (year: number, month: number) => `${year}年${month}月`,
|
||||||
rangePromptText: (maxRange: Number) => `选择天数不能超过 ${maxRange} 天`
|
rangePrompt: (maxRange: Number) => `选择天数不能超过 ${maxRange} 天`
|
||||||
},
|
},
|
||||||
vanContactCard: {
|
vanContactCard: {
|
||||||
addText: '添加联系人'
|
addText: '添加联系人'
|
||||||
|
@ -19,7 +19,7 @@ export default {
|
|||||||
confirm: '確定',
|
confirm: '確定',
|
||||||
weekdays: ['日', '壹', '二', '三', '四', '五', '六'],
|
weekdays: ['日', '壹', '二', '三', '四', '五', '六'],
|
||||||
monthTitle: (year: number, month: number) => `${year}年${month}月`,
|
monthTitle: (year: number, month: number) => `${year}年${month}月`,
|
||||||
rangePromptText: (maxRange: Number) => `選擇天數不能超過 ${maxRange} 天`
|
rangePrompt: (maxRange: Number) => `選擇天數不能超過 ${maxRange} 天`
|
||||||
},
|
},
|
||||||
vanContactCard: {
|
vanContactCard: {
|
||||||
addText: '添加聯系人'
|
addText: '添加聯系人'
|
||||||
|
@ -19,7 +19,7 @@ export default {
|
|||||||
confirm: '確定',
|
confirm: '確定',
|
||||||
weekdays: ['日', '壹', '二', '三', '四', '五', '六'],
|
weekdays: ['日', '壹', '二', '三', '四', '五', '六'],
|
||||||
monthTitle: (year: number, month: number) => `${year}年${month}月`,
|
monthTitle: (year: number, month: number) => `${year}年${month}月`,
|
||||||
rangePromptText: (maxRange: Number) => `選擇天數不能超過 ${maxRange} 天`
|
rangePrompt: (maxRange: Number) => `選擇天數不能超過 ${maxRange} 天`
|
||||||
},
|
},
|
||||||
vanContactCard: {
|
vanContactCard: {
|
||||||
addText: '新增聯絡人'
|
addText: '新增聯絡人'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user