Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Component] [date-picker] 动态修改disabled-date不生效 #12633

Open
liliting opened this issue Apr 27, 2023 · 6 comments
Open

[Component] [date-picker] 动态修改disabled-date不生效 #12633

liliting opened this issue Apr 27, 2023 · 6 comments
Labels

Comments

@liliting
Copy link

Bug Type: Component

Environment

  • Vue Version: 3.2.39
  • Element Plus Version: 2.2.32
  • Browser / OS: Chrome 112.0.5615.137(正式版本) (x86_64)
  • Build Tool: Vite

Reproduction

Related Component

  • el-date-picker

Reproduction Link

Element Plus Playground

Steps to reproduce

1、页面加载出来后disabled-date是初始设置的时间,
2、点击【修改不可用日期】后,数据表更,但时间选择器的不可用日期未更新

What is Expected?

期望不可用日期跟随设置变动

What is actually happening?

不可用日期未更新

Additional comments

(empty)

@liliting liliting changed the title [Component] [date-picker] [Component][el-date-picker]动态修改disabled-date不生效 [Component] [date-picker] 动态修改disabled-date不生效 Apr 27, 2023
@2048920439
Copy link

测试了一下确实有这个问题,不过你的Demo写错了,看看能不能去改一下,我晚点有时间了回去尝试修复这个问题
image

@2048920439
Copy link

我提交了一段代码可以解决这个问题,但是我另一次PR还没有审核通过我不知道怎么再次提交PR
你可以先看看这个
2048920439@c0f56f5

@zhengsixsix
Copy link
Contributor

我提交了一段代码可以解决这个问题,但是我另一次PR还没有审核通过我不知道怎么再次提交PR 你可以先看看这个 2048920439@c0f56f5

rebase一份新代码 之后 把hade指向初始化的commitid 自己fork的项目 新开一个分支 就行了

@wrrc
Copy link

wrrc commented Jul 13, 2024

所以这个什么时候能被合并呢🥲

@alonelucky
Copy link

alonelucky commented Jul 16, 2024

所以这个什么时候能被合并呢🥲

<el-date-picker v-model="time" type="date" placeholder="起始时间" class="origin" @change="changeEnd">
   <template #default="cell">
    <div class="cell" :class="{ disabled: cell.dayjs.format('YYYY-MM-DD') < maxt }" @click="(e: Event) => {
            if (cell.dayjs.format('YYYY-MM-DD') < max) e.stopPropagation();
        }">
      <span class="text">{{ cell.text }}</span>
    </div>
  </template>
</el-date-picker>

<style scoped>
.cell.disabled .text {
    color: var(--el-datepicker-off-text-color);
    cursor: auto;
}
</style>

@wrrc 暂时这样绕过了,自定义 cell date-picker.html#自定义内容

@wrrc
Copy link

wrrc commented Jul 16, 2024

@alonelucky 我最后改的是:函数固定,增加 开始时间结束时间

<el-date-picker
    :disabled-date="disabledDate"
/>
function disabledDate (time: Date) {
    if (props.disabledDateStart || props.disabledDateEnd) {
        // undefined 也没关系,会返回 false 的
         return (
            time < props.disabledDateStart! ||
            time > props.disabledDateEnd!
        )
    }
    return false
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants