From 21f57180e0a9e018820ca778808582e1b8556e39 Mon Sep 17 00:00:00 2001 From: mengxiong10 <15623530290@163.com> Date: Thu, 2 Dec 2021 16:11:33 +0800 Subject: [PATCH] fix: disabledtime for ampm (#664) --- __test__/__snapshots__/time-range.test.js.snap | 2 +- src/time/time-panel.vue | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/__test__/__snapshots__/time-range.test.js.snap b/__test__/__snapshots__/time-range.test.js.snap index c0251a1..567f561 100644 --- a/__test__/__snapshots__/time-range.test.js.snap +++ b/__test__/__snapshots__/time-range.test.js.snap @@ -307,7 +307,7 @@ exports[`TimeRange render: correct classes of the columns 1`] = ` data-type="ampm" >
  • diff --git a/src/time/time-panel.vue b/src/time/time-panel.vue index d9dd1da..bd03876 100644 --- a/src/time/time-panel.vue +++ b/src/time/time-panel.vue @@ -180,6 +180,16 @@ export default { this.isDisabledTime(value.setSeconds(59, 999)) ); }, + isDisabledAMPM(date) { + const value = new Date(date); + const minHour = value.getHours() < 12 ? 0 : 12; + const maxHour = minHour + 11; + return ( + this.isDisabledTime(value) && + this.isDisabledTime(value.setHours(minHour, 0, 0, 0)) && + this.isDisabledTime(value.setHours(maxHour, 59, 59, 999)) + ); + }, isDisabled(date, type) { if (type === 'hour') { return this.isDisabledHour(date); @@ -187,6 +197,9 @@ export default { if (type === 'minute') { return this.isDisabledMinute(date); } + if (type === 'ampm') { + return this.isDisabledAMPM(date); + } return this.isDisabledTime(date); }, handleSelect(value, type) {