mirror of https://github.com/ElemeFE/element
fix datepicker year select mode bug (#1385)
parent
75d248e107
commit
ce13d974b5
|
@ -50,9 +50,7 @@
|
||||||
props: {
|
props: {
|
||||||
disabledDate: {},
|
disabledDate: {},
|
||||||
date: {},
|
date: {},
|
||||||
year: {
|
year: {}
|
||||||
type: Number
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -86,7 +84,7 @@
|
||||||
const target = event.target;
|
const target = event.target;
|
||||||
if (target.tagName === 'A') {
|
if (target.tagName === 'A') {
|
||||||
if (hasClass(target.parentNode, 'disabled')) return;
|
if (hasClass(target.parentNode, 'disabled')) return;
|
||||||
const year = parseInt(target.textContent || target.innerText, 10);
|
const year = target.textContent || target.innerText;
|
||||||
this.$emit('pick', year);
|
this.$emit('pick', year);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
@click="handleShortcutClick(shortcut)">{{ shortcut.text }}</button>
|
@click="handleShortcutClick(shortcut)">{{ shortcut.text }}</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="el-picker-panel__body">
|
<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">
|
<span class="el-date-picker__editor-wrap">
|
||||||
<input
|
<input
|
||||||
:placehoder="t('el.datepicker.selectDate')"
|
:placehoder="t('el.datepicker.selectDate')"
|
||||||
|
@ -310,7 +310,7 @@
|
||||||
|
|
||||||
this.date.setFullYear(year);
|
this.date.setFullYear(year);
|
||||||
if (this.selectionMode === 'year') {
|
if (this.selectionMode === 'year') {
|
||||||
this.$emit('pick', year);
|
this.$emit('pick', new Date(year));
|
||||||
} else {
|
} else {
|
||||||
this.currentView = 'month';
|
this.currentView = 'month';
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,8 @@ const DEFAULT_FORMATS = {
|
||||||
time: 'HH:mm:ss',
|
time: 'HH:mm:ss',
|
||||||
timerange: 'HH:mm:ss',
|
timerange: 'HH:mm:ss',
|
||||||
daterange: 'yyyy-MM-dd',
|
daterange: 'yyyy-MM-dd',
|
||||||
datetimerange: 'yyyy-MM-dd HH:mm:ss'
|
datetimerange: 'yyyy-MM-dd HH:mm:ss',
|
||||||
|
year: 'yyyy'
|
||||||
};
|
};
|
||||||
const HAVE_TRIGGER_TYPES = [
|
const HAVE_TRIGGER_TYPES = [
|
||||||
'date',
|
'date',
|
||||||
|
@ -163,16 +164,8 @@ const TYPE_VALUE_RESOLVER_MAP = {
|
||||||
parser: DATE_PARSER
|
parser: DATE_PARSER
|
||||||
},
|
},
|
||||||
year: {
|
year: {
|
||||||
formatter(value) {
|
formatter: DATE_FORMATTER,
|
||||||
if (!value) return '';
|
parser: DATE_PARSER
|
||||||
return '' + value;
|
|
||||||
},
|
|
||||||
parser(text) {
|
|
||||||
const year = Number(text);
|
|
||||||
if (!isNaN(year)) return year;
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
number: {
|
number: {
|
||||||
formatter(value) {
|
formatter(value) {
|
||||||
|
|
Loading…
Reference in New Issue