DatePicker: 当format不包括秒时,时间下拉菜单不展示ss

pull/4526/head
ousiri 2017-04-26 19:59:28 +08:00 committed by 杨奕
parent 45043754df
commit 313ec8de51
2 changed files with 15 additions and 4 deletions

View File

@ -41,7 +41,8 @@
:date="date" :date="date"
:picker-width="pickerWidth" :picker-width="pickerWidth"
@pick="handleTimePick" @pick="handleTimePick"
:visible="timePickerVisible"> :visible="timePickerVisible"
@mounted="$refs.timepicker.format=timeFormat">
</time-picker> </time-picker>
</span> </span>
</div> </div>
@ -371,7 +372,8 @@
week: null, week: null,
showWeekNumber: false, showWeekNumber: false,
timePickerVisible: false, timePickerVisible: false,
width: 0 width: 0,
format: ''
}; };
}, },
@ -382,12 +384,12 @@
visibleTime: { visibleTime: {
get() { get() {
return formatDate(this.date, 'HH:mm:ss'); return formatDate(this.date, this.timeFormat);
}, },
set(val) { set(val) {
if (val) { if (val) {
const date = parseDate(val, 'HH:mm:ss'); const date = parseDate(val, this.timeFormat);
if (date) { if (date) {
date.setFullYear(this.date.getFullYear()); date.setFullYear(this.date.getFullYear());
date.setMonth(this.date.getMonth()); date.setMonth(this.date.getMonth());
@ -433,6 +435,14 @@
return startYear + ' - ' + (startYear + 9); return startYear + ' - ' + (startYear + 9);
} }
return this.year + ' ' + yearTranslation; return this.year + ' ' + yearTranslation;
},
timeFormat() {
if (this.format && this.format.indexOf('ss') === -1) {
return 'HH:mm';
} else {
return 'HH:mm:ss';
}
} }
} }
}; };

View File

@ -151,6 +151,7 @@
mounted() { mounted() {
this.$nextTick(() => this.handleConfirm(true, true)); this.$nextTick(() => this.handleConfirm(true, true));
this.$emit('mounted');
} }
}; };
</script> </script>