mirror of
https://github.com/youzan/vant.git
synced 2025-10-19 10:07:07 +00:00
[Improvement] DatetimePicker: add new type & show-toolbar prop (#736)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<picker
|
||||
ref="picker"
|
||||
show-toolbar
|
||||
:show-toolbar="showToolbar"
|
||||
:columns="columns"
|
||||
:visible-item-count="visibleItemCount"
|
||||
@change="onChange"
|
||||
@@ -28,6 +28,10 @@ export default create({
|
||||
type: String,
|
||||
default: 'datetime'
|
||||
},
|
||||
showToolbar: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
format: {
|
||||
type: String,
|
||||
default: 'YYYY.MM.DD HH时 mm分'
|
||||
@@ -100,6 +104,7 @@ export default create({
|
||||
];
|
||||
|
||||
if (this.type === 'date') result.splice(3, 2);
|
||||
if (this.type === 'date-year-month') result.splice(2, 3);
|
||||
return result;
|
||||
},
|
||||
columns() {
|
||||
@@ -236,6 +241,9 @@ export default create({
|
||||
const month = this.getTrueValue(values[1]);
|
||||
const maxDate = this.getMonthEndDay(year, month);
|
||||
let date = this.getTrueValue(values[2]);
|
||||
if (this.type === 'date-year-month') {
|
||||
date = 1;
|
||||
}
|
||||
date = date > maxDate ? maxDate : date;
|
||||
let hour = 0;
|
||||
let minute = 0;
|
||||
@@ -270,6 +278,9 @@ export default create({
|
||||
`0${value.getMinutes()}`.slice(-2)
|
||||
);
|
||||
}
|
||||
if (this.type === 'date-year-month') {
|
||||
values = values.slice(0, 2);
|
||||
}
|
||||
}
|
||||
|
||||
this.$nextTick(() => {
|
||||
|
Reference in New Issue
Block a user