mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 10:20:19 +08:00
[bugfix] DatetimePicker: incorrect value in confirm event when use filter on time type (#3816)
This commit is contained in:
parent
de5263137d
commit
c78524264f
@ -249,20 +249,23 @@ export default createComponent({
|
|||||||
let value;
|
let value;
|
||||||
|
|
||||||
if (this.type === 'time') {
|
if (this.type === 'time') {
|
||||||
const indexes = picker.getIndexes();
|
value = picker.getValues().join(':');
|
||||||
value = `${indexes[0] + this.minHour}:${indexes[1] + this.minMinute}`;
|
|
||||||
} else {
|
} else {
|
||||||
const values = picker.getValues();
|
const values = picker.getValues();
|
||||||
const year = getTrueValue(values[0]);
|
const year = getTrueValue(values[0]);
|
||||||
const month = getTrueValue(values[1]);
|
const month = getTrueValue(values[1]);
|
||||||
const maxDate = getMonthEndDay(year, month);
|
const maxDate = getMonthEndDay(year, month);
|
||||||
let date = getTrueValue(values[2]);
|
let date = getTrueValue(values[2]);
|
||||||
|
|
||||||
if (this.type === 'year-month') {
|
if (this.type === 'year-month') {
|
||||||
date = 1;
|
date = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
date = date > maxDate ? maxDate : date;
|
date = date > maxDate ? maxDate : date;
|
||||||
|
|
||||||
let hour = 0;
|
let hour = 0;
|
||||||
let minute = 0;
|
let minute = 0;
|
||||||
|
|
||||||
if (this.type === 'datetime') {
|
if (this.type === 'datetime') {
|
||||||
hour = getTrueValue(values[3]);
|
hour = getTrueValue(values[3]);
|
||||||
minute = getTrueValue(values[4]);
|
minute = getTrueValue(values[4]);
|
||||||
@ -293,12 +296,14 @@ export default createComponent({
|
|||||||
formatter('month', padZero(value.getMonth() + 1)),
|
formatter('month', padZero(value.getMonth() + 1)),
|
||||||
formatter('day', padZero(value.getDate()))
|
formatter('day', padZero(value.getDate()))
|
||||||
];
|
];
|
||||||
|
|
||||||
if (this.type === 'datetime') {
|
if (this.type === 'datetime') {
|
||||||
values.push(
|
values.push(
|
||||||
formatter('hour', padZero(value.getHours())),
|
formatter('hour', padZero(value.getHours())),
|
||||||
formatter('minute', padZero(value.getMinutes()))
|
formatter('minute', padZero(value.getMinutes()))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.type === 'year-month') {
|
if (this.type === 'year-month') {
|
||||||
values = values.slice(0, 2);
|
values = values.slice(0, 2);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user