Skip to content

[Calendar] 年份相同,月份不同的日期范围显示有误 #3735

@liulyxandy-codemao

Description

@liulyxandy-codemao

tdesign-vue 版本

1.14.1

重现链接

No response

重现步骤

设置range为年份相同,月份不同的任意两值。如['2025-9', '2025-10']

期望结果

除了2025-9, 2025-10外,其他年月选择均被禁用。

实际结果

得到的实际结果为2025年中9月后的所有月份都被启用,没有被禁用。

框架版本

No response

浏览器版本

Chrome(141.0.7390.54)

系统版本

Windows 11 Dev(27954.1)

Node版本

22

补充说明

// src\calendar\calendar.tsx L535~549
checkMonthAndYearSelectorDisabled(year: number, month: number): boolean {
  let disabled = false;
  if (this.rangeFromTo && this.rangeFromTo.from && this.rangeFromTo.to) {
    const beginYear = dayjs(this.rangeFromTo.from).year();
    const endYear = dayjs(this.rangeFromTo.to).year();
    if (year === beginYear) {
      const beginMon = parseInt(dayjs(this.rangeFromTo.from).format('M'), 10);
      disabled = month < beginMon;
    } else if (year === endYear) {
      const endMon = parseInt(dayjs(this.rangeFromTo.to).format('M'), 10);
      disabled = month > endMon;
    }
  }
  return disabled;
},

若range为['2025-9', '2025-10'],则当检测2025-11是否可用时,因为year === beginYear,故month < beginMonfalse,月份选项不会被禁用。

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions