element UI DatePicker 日期选择器 点击时间点可选限制范围前后十五天

本文主要是介绍element UI DatePicker 日期选择器 点击时间点可选限制范围前后十五天,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

<el-date-picker v-model="timeRange" type="datetimerange" align="right" :default-time='defaultTime'value-format="yyyy-MM-dd HH:mm:dd" range-separator="至" start-placeholder="开始日期"end-placeholder="结束日期" :picker-options="pickerOptions" @change="handleChangeTime":clearable="false"></el-date-picker>

设置:picker-options="pickerOptions"

然后在data里面设置

pickerOptions: {onPick: ({maxDate,minDate}) => {this.selectDate = minDate.getTime()if (maxDate) {this.selectDate = ''}},disabledDate: (time) => {if (this.selectDate !== '') {const one = (15 * 24 * 3600 - 1) * 1000 // 00:00:00 到23:59:59const minTime = this.selectDate - oneconst maxTime = this.selectDate + onereturn time.getTime() < minTime || time.getTime() > maxTime}}}

源代码

<template><div class="promotion-page"><div class="promotion-box"><div class="title">通证估值</div><div class="time-box type-box"><span class="time-span">时间</span><el-date-picker v-model="time" type="datetimerange" range-separator="-" start-placeholder="选择开始时间"end-placeholder="选择结束日期" class="date" @change="getTableData" :picker-options="pickerOptions" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker><!-- <el-date-picker v-model="time" type="datetimerange"  align="right" :default-time='defaultTime'value-format="yyyy-MM-dd HH:mm:dd" range-separator="至" start-placeholder="开始日期"end-placeholder="结束日期" :picker-options="pickerOptions" @change="getTableData":clearable="false"></el-date-picker> --></div><div class="echarts_piece"><div class="echarts_piece_t"><span>8.55</span><span>昨日估值</span></div><div class="echarts_piece_t"><span>0.56%</span><span>涨幅</span></div></div><div ref="chart" style="width: 1126.11px; height: 491.66px;"></div></div></div>
</template><script>import * as echarts from 'echarts';export default {name: 'EChartsComponent',data() {return {chart: null,// 时间筛选time: [],selectDate: '',defaultTime: ['00:00:00', '23:59:59'],timeRange: [],pickerOptions: {onPick: ({maxDate,minDate}) => {this.selectDate = minDate.getTime()if (maxDate) {this.selectDate = ''}},disabledDate: (time) => {if (this.selectDate !== '') {const one = (15 * 24 * 3600 - 1) * 1000 // 00:00:00 到23:59:59const minTime = this.selectDate - oneconst maxTime = this.selectDate + onereturn time.getTime() < minTime || time.getTime() > maxTime}}}};},mounted() {this.chart = echarts.init(this.$refs.chart);this.drawChart();},methods: {// 获取数据async getTableData() {let params = {startTime: this.time?.[0],endTime: this.time?.[1],}console.log('请求参数@@@@', params);// let {// 	code,// 	total,// 	rows// } = await integralUserVOList(params)// if (code == 200) {// 	this.table_data = rows// 	this.total = total// 	console.log('当前的数据', this.table_data);// }},drawChart() {const option = {title: {text: ''},tooltip: {trigger: 'axis',axisPointer: {type: 'cross',label: {backgroundColor: '#fff'}}},legend: {data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine']},toolbox: {feature: {saveAsImage: {}}},grid: {left: '3%',right: '4%',bottom: '3%',containLabel: true},xAxis: [{type: 'category',boundaryGap: false,data: ['10/11', '10/12', '10/13', '10/13', '10/14', '10/16', '17']}],yAxis: [{show: false,type: 'value'}],series: [{name: '',type: 'line',stack: 'Total',color: '#F35555',areaStyle: {opacity: 0.8,color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{offset: 0,color: '#F35555'},{offset: 1,color: '#FFFFFF'}])},emphasis: {focus: 'series'},data: [0.000026, 0.000056, 0.000076, 0.000086, 0.000096, 0.000097, 0.000099]}]};this.chart.setOption(option);},},};
</script>
<style scoped lang="scss">.promotion-page {padding: 16px;.promotion-box {padding: 16px;min-width: 1280px;width: 100%;background: #FFFFFF;box-shadow: 0px 1px 4px 1px #E5E9F2;border-radius: 5px 5px 5px 5px;}}// 盒子的标题.title {margin-bottom: 0;text-align: left;font-size: 24px;font-weight: 500;color: #31394d;font-weight: bold;}::v-deep {.el-range-editor--medium .el-range__icon,.el-range-editor--medium .el-range__close-icon {line-height: 20px !important;}}// 时间筛选.time-box {display: flex;align-items: center;margin-top: 30px;padding-left: 56px;.time-span {padding-right: 10px;}// 深度选择.date {height: 28px;width: 380px;.el-input__icon {font-size: 12px;height: 24px;line-height: 24px;}.el-range-separator {font-size: 12px;height: 24px;line-height: 24px;}}}.echarts_piece {margin-left: 56px;margin-top: 32px;display: flex;width: 300px;justify-content: space-between;// border: 1px solid red ;.echarts_piece_t span {display: block;}.echarts_piece_t span:nth-child(1) {font-size: 36px;font-weight: bold;}.echarts_piece_t span:nth-child(2) {color: #999999;font-size: 14px;}}
</style>

这篇关于element UI DatePicker 日期选择器 点击时间点可选限制范围前后十五天的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/339423

相关文章

k8s容器放开锁内存限制问题

《k8s容器放开锁内存限制问题》nccl-test容器运行mpirun时因NCCL_BUFFSIZE过大导致OOM,需通过修改docker服务配置文件,将LimitMEMLOCK设为infinity并... 目录问题问题确认放开容器max locked memory限制总结参考:https://Access

Python的Darts库实现时间序列预测

《Python的Darts库实现时间序列预测》Darts一个集统计、机器学习与深度学习模型于一体的Python时间序列预测库,本文主要介绍了Python的Darts库实现时间序列预测,感兴趣的可以了解... 目录目录一、什么是 Darts?二、安装与基本配置安装 Darts导入基础模块三、时间序列数据结构与

MyBatis Plus实现时间字段自动填充的完整方案

《MyBatisPlus实现时间字段自动填充的完整方案》在日常开发中,我们经常需要记录数据的创建时间和更新时间,传统的做法是在每次插入或更新操作时手动设置这些时间字段,这种方式不仅繁琐,还容易遗漏,... 目录前言解决目标技术栈实现步骤1. 实体类注解配置2. 创建元数据处理器3. 服务层代码优化填充机制详

C++统计函数执行时间的最佳实践

《C++统计函数执行时间的最佳实践》在软件开发过程中,性能分析是优化程序的重要环节,了解函数的执行时间分布对于识别性能瓶颈至关重要,本文将分享一个C++函数执行时间统计工具,希望对大家有所帮助... 目录前言工具特性核心设计1. 数据结构设计2. 单例模式管理器3. RAII自动计时使用方法基本用法高级用法

C# LiteDB处理时间序列数据的高性能解决方案

《C#LiteDB处理时间序列数据的高性能解决方案》LiteDB作为.NET生态下的轻量级嵌入式NoSQL数据库,一直是时间序列处理的优选方案,本文将为大家大家简单介绍一下LiteDB处理时间序列数... 目录为什么选择LiteDB处理时间序列数据第一章:LiteDB时间序列数据模型设计1.1 核心设计原则

MySQL按时间维度对亿级数据表进行平滑分表

《MySQL按时间维度对亿级数据表进行平滑分表》本文将以一个真实的4亿数据表分表案例为基础,详细介绍如何在不影响线上业务的情况下,完成按时间维度分表的完整过程,感兴趣的小伙伴可以了解一下... 目录引言一、为什么我们需要分表1.1 单表数据量过大的问题1.2 分表方案选型二、分表前的准备工作2.1 数据评估

Python利用GeoPandas打造一个交互式中国地图选择器

《Python利用GeoPandas打造一个交互式中国地图选择器》在数据分析和可视化领域,地图是展示地理信息的强大工具,被将使用Python、wxPython和GeoPandas构建的交互式中国地图行... 目录技术栈概览代码结构分析1. __init__ 方法:初始化与状态管理2. init_ui 方法:

基于Python实现数字限制在指定范围内的五种方式

《基于Python实现数字限制在指定范围内的五种方式》在编程中,数字范围限制是常见需求,无论是游戏开发中的角色属性值、金融计算中的利率调整,还是传感器数据处理中的异常值过滤,都需要将数字控制在合理范围... 目录引言一、基础条件判断法二、数学运算巧解法三、装饰器模式法四、自定义类封装法五、NumPy数组处理

MySQL中DATE_FORMAT时间函数的使用小结

《MySQL中DATE_FORMAT时间函数的使用小结》本文主要介绍了MySQL中DATE_FORMAT时间函数的使用小结,用于格式化日期/时间字段,可提取年月、统计月份数据、精确到天,对大家的学习或... 目录前言DATE_FORMAT时间函数总结前言mysql可以使用DATE_FORMAT获取日期字段

Python标准库datetime模块日期和时间数据类型解读

《Python标准库datetime模块日期和时间数据类型解读》文章介绍Python中datetime模块的date、time、datetime类,用于处理日期、时间及日期时间结合体,通过属性获取时间... 目录Datetime常用类日期date类型使用时间 time 类型使用日期和时间的结合体–日期时间(