[Improvement] DatetimePicker: add new type & show-toolbar prop (#736)

This commit is contained in:
酱酱酱酱
2018-03-21 20:23:37 +08:00
committed by neverland
parent 9459eeab93
commit 3032d30bf8
2 changed files with 48 additions and 1 deletions

View File

@@ -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(() => {