mirror of https://github.com/ElemeFE/element
DatePicker: 修复 DatePicker 日期选择器 属性的cellClassName属性值在显示类型为 year/month 时无效
parent
290e68ea6a
commit
96d115dbdf
|
@ -48,6 +48,7 @@
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
disabledDate: {},
|
disabledDate: {},
|
||||||
|
cellClassName: {},
|
||||||
value: {},
|
value: {},
|
||||||
selectionMode: {
|
selectionMode: {
|
||||||
default: 'month'
|
default: 'month'
|
||||||
|
@ -130,6 +131,11 @@
|
||||||
style['end-date'] = true;
|
style['end-date'] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (typeof this.cellClassName === 'function') {
|
||||||
|
const customClass = this.cellClassName(new Date(year, month, 1));
|
||||||
|
customClass && (style[customClass] = true);
|
||||||
|
style[customClass] = !!customClass;
|
||||||
|
}
|
||||||
return style;
|
return style;
|
||||||
},
|
},
|
||||||
getMonthOfCell(month) {
|
getMonthOfCell(month) {
|
||||||
|
|
|
@ -57,6 +57,7 @@
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
disabledDate: {},
|
disabledDate: {},
|
||||||
|
cellClassName: {},
|
||||||
value: {},
|
value: {},
|
||||||
defaultValue: {
|
defaultValue: {
|
||||||
validator(val) {
|
validator(val) {
|
||||||
|
@ -85,6 +86,11 @@
|
||||||
style.current = arrayFindIndex(coerceTruthyValueToArray(this.value), date => date.getFullYear() === year) >= 0;
|
style.current = arrayFindIndex(coerceTruthyValueToArray(this.value), date => date.getFullYear() === year) >= 0;
|
||||||
style.today = today.getFullYear() === year;
|
style.today = today.getFullYear() === year;
|
||||||
style.default = this.defaultValue && this.defaultValue.getFullYear() === year;
|
style.default = this.defaultValue && this.defaultValue.getFullYear() === year;
|
||||||
|
if (typeof this.cellClassName === 'function') {
|
||||||
|
const customClass = this.cellClassName(new Date(year, 0));
|
||||||
|
customClass && (style[customClass] = true);
|
||||||
|
style[customClass] = !!customClass;
|
||||||
|
}
|
||||||
|
|
||||||
return style;
|
return style;
|
||||||
},
|
},
|
||||||
|
|
|
@ -106,6 +106,7 @@
|
||||||
:value="value"
|
:value="value"
|
||||||
:default-value="defaultValue ? new Date(defaultValue) : null"
|
:default-value="defaultValue ? new Date(defaultValue) : null"
|
||||||
:date="date"
|
:date="date"
|
||||||
|
:cell-class-name="cellClassName"
|
||||||
:disabled-date="disabledDate">
|
:disabled-date="disabledDate">
|
||||||
</year-table>
|
</year-table>
|
||||||
<month-table
|
<month-table
|
||||||
|
@ -115,6 +116,7 @@
|
||||||
:value="value"
|
:value="value"
|
||||||
:default-value="defaultValue ? new Date(defaultValue) : null"
|
:default-value="defaultValue ? new Date(defaultValue) : null"
|
||||||
:date="date"
|
:date="date"
|
||||||
|
:cell-class-name="cellClassName"
|
||||||
:disabled-date="disabledDate">
|
:disabled-date="disabledDate">
|
||||||
</month-table>
|
</month-table>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue