update DateTimePicker

update DateTimePicker
This commit is contained in:
梁灏 2016-12-30 13:56:34 +08:00
parent acde7262ef
commit 3693144258
4 changed files with 39 additions and 26 deletions

View file

@ -60,8 +60,8 @@
@on-pick="handleMonthPick"
@on-pick-click="handlePickClick"></month-table>
<time-picker
v-show="currentView === 'time'"
v-ref:time-picker
v-show="currentView === 'time'"
:date="date"
:value="value"
:format="format"
@ -142,6 +142,13 @@
this.year = newVal.getFullYear();
this.month = newVal.getMonth();
}
if (this.showTime) this.$refs.timePicker.value = newVal;
},
date (val) {
if (this.showTime) this.$refs.timePicker.date = val;
},
format (val) {
if (this.showTime) this.$refs.timePicker.format = val;
},
currentView (val) {
if (val === 'time') this.$refs.timePicker.updateScroll();
@ -268,6 +275,12 @@
this.year = this.date.getFullYear();
this.month = this.date.getMonth();
}
if (this.showTime) {
this.$refs.timePicker.date = this.date;
this.$refs.timePicker.value = this.value;
this.$refs.timePicker.format = this.format;
this.$refs.timePicker.showDate = true;
}
}
};
</script>

View file

@ -37,29 +37,32 @@
export default {
mixins: [Mixin],
components: { TimeSpinner, Confirm },
props: {
date: {
default () {
return initTimeDate();
}
},
value: {
default: ''
},
showDate: {
type: Boolean,
default: false
},
format: {
type: String,
default: 'HH:mm:ss'
}
},
// props: {
// date: {
// default () {
// return initTimeDate();
// }
// },
// value: {
// default: ''
// },
// showDate: {
// type: Boolean,
// default: false
// },
// format: {
// type: String,
// default: 'HH:mm:ss'
// }
// },
data () {
return {
prefixCls: prefixCls,
timePrefixCls: timePrefixCls,
// format: 'HH:mm:ss',
date: initTimeDate(),
value: '',
showDate: false,
format: 'HH:mm:ss',
hours: '',
minutes: '',
seconds: '',