fix datepicker year select mode bug (#1385)

pull/1389/head
baiyaaaaa 2016-11-26 23:19:08 +08:00 committed by cinwell.li
parent 75d248e107
commit ce13d974b5
3 changed files with 8 additions and 17 deletions

View File

@ -50,9 +50,7 @@
props: {
disabledDate: {},
date: {},
year: {
type: Number
}
year: {}
},
computed: {
@ -86,7 +84,7 @@
const target = event.target;
if (target.tagName === 'A') {
if (hasClass(target.parentNode, 'disabled')) return;
const year = parseInt(target.textContent || target.innerText, 10);
const year = target.textContent || target.innerText;
this.$emit('pick', year);
}
}

View File

@ -20,7 +20,7 @@
@click="handleShortcutClick(shortcut)">{{ shortcut.text }}</button>
</div>
<div class="el-picker-panel__body">
<div class="el-date-picker__time-header" v-if="showTime">
<div class="el-date-picker__time-header" v-if="showTime">
<span class="el-date-picker__editor-wrap">
<input
:placehoder="t('el.datepicker.selectDate')"
@ -310,7 +310,7 @@
this.date.setFullYear(year);
if (this.selectionMode === 'year') {
this.$emit('pick', year);
this.$emit('pick', new Date(year));
} else {
this.currentView = 'month';
}

View File

@ -58,7 +58,8 @@ const DEFAULT_FORMATS = {
time: 'HH:mm:ss',
timerange: 'HH:mm:ss',
daterange: 'yyyy-MM-dd',
datetimerange: 'yyyy-MM-dd HH:mm:ss'
datetimerange: 'yyyy-MM-dd HH:mm:ss',
year: 'yyyy'
};
const HAVE_TRIGGER_TYPES = [
'date',
@ -163,16 +164,8 @@ const TYPE_VALUE_RESOLVER_MAP = {
parser: DATE_PARSER
},
year: {
formatter(value) {
if (!value) return '';
return '' + value;
},
parser(text) {
const year = Number(text);
if (!isNaN(year)) return year;
return null;
}
formatter: DATE_FORMATTER,
parser: DATE_PARSER
},
number: {
formatter(value) {