From 96d115dbdf01eadd8c8f882c8dca5f91b41b1a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=98=8E=E5=8D=8E?= <735161977@qq.com> Date: Wed, 18 Oct 2023 11:32:56 +0800 Subject: [PATCH] =?UTF-8?q?DatePicker:=20=E4=BF=AE=E5=A4=8D=20DatePicker?= =?UTF-8?q?=20=E6=97=A5=E6=9C=9F=E9=80=89=E6=8B=A9=E5=99=A8=20=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E7=9A=84cellClassName=E5=B1=9E=E6=80=A7=E5=80=BC?= =?UTF-8?q?=E5=9C=A8=E6=98=BE=E7=A4=BA=E7=B1=BB=E5=9E=8B=E4=B8=BA=20year/m?= =?UTF-8?q?onth=20=E6=97=B6=E6=97=A0=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/date-picker/src/basic/month-table.vue | 6 ++++++ packages/date-picker/src/basic/year-table.vue | 6 ++++++ packages/date-picker/src/panel/date.vue | 2 ++ 3 files changed, 14 insertions(+) diff --git a/packages/date-picker/src/basic/month-table.vue b/packages/date-picker/src/basic/month-table.vue index 18083070f..2e4ae752a 100644 --- a/packages/date-picker/src/basic/month-table.vue +++ b/packages/date-picker/src/basic/month-table.vue @@ -48,6 +48,7 @@ export default { props: { disabledDate: {}, + cellClassName: {}, value: {}, selectionMode: { default: 'month' @@ -130,6 +131,11 @@ 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; }, getMonthOfCell(month) { diff --git a/packages/date-picker/src/basic/year-table.vue b/packages/date-picker/src/basic/year-table.vue index 74eb59aac..12ff5bbc5 100644 --- a/packages/date-picker/src/basic/year-table.vue +++ b/packages/date-picker/src/basic/year-table.vue @@ -57,6 +57,7 @@ export default { props: { disabledDate: {}, + cellClassName: {}, value: {}, defaultValue: { validator(val) { @@ -85,6 +86,11 @@ style.current = arrayFindIndex(coerceTruthyValueToArray(this.value), date => date.getFullYear() === year) >= 0; style.today = today.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; }, diff --git a/packages/date-picker/src/panel/date.vue b/packages/date-picker/src/panel/date.vue index a0fa95b63..66880ae9b 100644 --- a/packages/date-picker/src/panel/date.vue +++ b/packages/date-picker/src/panel/date.vue @@ -106,6 +106,7 @@ :value="value" :default-value="defaultValue ? new Date(defaultValue) : null" :date="date" + :cell-class-name="cellClassName" :disabled-date="disabledDate">