当前位置: 首页 > news >正文

el-date-picker 有效时间精确到时分秒 且给有效时间添加标记

el-date-picker实现有效日期做标记且时分秒限制选择范围


在这里插入图片描述
代码如下:

// html部分
<el-date-pickerv-model="dateTime"type="datetime":picker-options="pickerOptions"
>
</el-date-picker>// js部分
/*** 回放有效日期开始时间*/
@Prop({default: function() {return null},required: false
})
recordStartTime!: Date/*** 回放有效日期结束时间*/
@Prop({default: function() {return null},required: false
})
recordStopTime!: Date// el-date-picker绑定的值
dateTime: number = new Date().getTime()get choosedDate() {let dateObj = {year: new Date(this.dateTime).getFullYear(),month: new Date(this.dateTime).getMonth(),date: new Date(this.dateTime).getDate()}return JSON.stringify(dateObj)
}@Watch('choosedDate', { immediate: true })
watchChoosedDate(newVal) {let dateObj = JSON.parse(newVal)/*** 开始时间限制*/if (dateObj.year == new Date(this.recordStartTime).getFullYear() &&dateObj.month == new Date(this.recordStartTime).getMonth() &&dateObj.date == new Date(this.recordStartTime).getDate()) {this.pickerOptions = {cellClassName: (time) => {let that = thisif(time.getTime() > new Date(that.recordStartTime).getTime() - 8.64e7 && time.getTime() < new Date(that.recordStopTime).getTime()){return 'custom_date_class';}},selectableRange: `${new Date(this.recordStartTime).format('hh:mm:ss')} - 23:59:59`}} /*** 结束时间限制*/else if (dateObj.year == new Date(this.recordStopTime).getFullYear() &&dateObj.month == new Date(this.recordStopTime).getMonth() &&dateObj.date == new Date(this.recordStopTime).getDate()) {this.pickerOptions = {cellClassName: (time) => {let that = thisif(time.getTime() > new Date(that.recordStartTime).getTime() - 8.64e7 && time.getTime() < new Date(that.recordStopTime).getTime()){return 'custom_date_class';}},selectableRange: `00:00:00 - ${new Date(this.recordStopTime).format('hh:mm:ss')}`}} /*** 其他时间*/else {this.pickerOptions = {cellClassName: (time) => {let that = thisif(time.getTime() > new Date(that.recordStartTime).getTime() - 8.64e7 && time.getTime() < new Date(that.recordStopTime).getTime()){return 'custom_date_class';}},selectableRange: `00:00:00 - 23:59:59`}}
}// css部分 给有效日期下面添加标记
<style lang="less">
.custom_date_class {&::after {content: "";display: block;position: absolute;width: 4px;height: 4px;border-radius: 100%;background-color: var(--mb-main-color);left: 50%;transform: translateX(-2px);}
}
</style>

相关文章:

  • Ubuntu 22.04 下 CURL(C++) 实现分块上传/下载文件源码
  • 学习笔记——交通安全分析05
  • leetcode45 跳跃游戏II
  • 使用Python进行音频处理
  • k8s学习笔记(一)
  • 【AI】消融实验ablation study
  • Zookeeper 集群节点故障剔除、切换、恢复原理
  • CFD笔记
  • 【ai】tx2-nx:搭配torch的torchvision
  • MySQL之复制(七)
  • RPM命令和YUM命令
  • fastadmin多语言切换设置
  • Python里引用了time包后,不能再命名time变量了吗?
  • 基于springboot的人口老龄化社区服务与管理平台源码数据库
  • 1039. 多边形三角剖分的最低得分
  • 【RocksDB】TransactionDB源码分析
  • 2017 年终总结 —— 在路上
  • Android组件 - 收藏集 - 掘金
  • docker-consul
  • JavaScript/HTML5图表开发工具JavaScript Charts v3.19.6发布【附下载】
  • java第三方包学习之lombok
  • Making An Indicator With Pure CSS
  • Python利用正则抓取网页内容保存到本地
  • SAP云平台运行环境Cloud Foundry和Neo的区别
  • spring-boot List转Page
  • Transformer-XL: Unleashing the Potential of Attention Models
  • Vue.js-Day01
  • 阿里云容器服务区块链解决方案全新升级 支持Hyperledger Fabric v1.1
  • 浅谈web中前端模板引擎的使用
  • 入门到放弃node系列之Hello Word篇
  • 微信小程序--------语音识别(前端自己也能玩)
  • 积累各种好的链接
  • ​iOS安全加固方法及实现
  • (1)Nginx简介和安装教程
  • (4)事件处理——(6)给.ready()回调函数传递一个参数(Passing an argument to the .ready() callback)...
  • (aiohttp-asyncio-FFmpeg-Docker-SRS)实现异步摄像头转码服务器
  • (Matalb分类预测)GA-BP遗传算法优化BP神经网络的多维分类预测
  • (SERIES10)DM逻辑备份还原
  • (二十一)devops持续集成开发——使用jenkins的Docker Pipeline插件完成docker项目的pipeline流水线发布
  • (分布式缓存)Redis哨兵
  • (文章复现)基于主从博弈的售电商多元零售套餐设计与多级市场购电策略
  • (一)pytest自动化测试框架之生成测试报告(mac系统)
  • .NET CF命令行调试器MDbg入门(二) 设备模拟器
  • .NET CORE使用Redis分布式锁续命(续期)问题
  • .NET/C# 反射的的性能数据,以及高性能开发建议(反射获取 Attribute 和反射调用方法)
  • .NetCore 如何动态路由
  • .vue文件怎么使用_vue调试工具vue-devtools的安装
  • /deep/和 >>>以及 ::v-deep 三者的区别
  • []常用AT命令解释()
  • [001-03-007].第07节:Redis中的管道
  • [012-1].第12节:Mysql的配置文件的使用
  • [100天算法】-二叉树剪枝(day 48)
  • [20190401]关于semtimedop函数调用.txt
  • [acm算法学习] 后缀数组SA
  • [AIGC] Java List接口详解