当前位置:网站首页>Customize the shortcut options in El date picker, and dynamically set the disabled date
Customize the shortcut options in El date picker, and dynamically set the disabled date
2022-04-23 12:48:00 【ZMJ_ QQ】
1. demand
stay table In the table , Back end returned List, Every one of them list There is an occurrence date in the data occur_time, Click report delay to open the history dialog box , Click to open a dialog box for filling in information after applying for extension . The user can only select the current plan completion date list The date of occurrence plus 30 Days after , So it's in picker-options Set in disabledDate.

2. Implementation code
<el-date-picker
v-model="delayItem.plan_date"
align="right"
type="date"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
placeholder=" Please select the planned completion date "
:picker-options="pickerOptions"
>
</el-date-picker>
Because the back end returns analysis_occure_time The time format is 2021/12/20, So use replaceAll() convert to 2022-12-20.
new Date( ) The returned data is in Chinese standard format
Use setDate() Directly calculate the departure birthday plus 30 Days after , If you need to calculate the number of days before a certain date, you can directly subtract the number of days
data(){
return{
delayItem:{},
pickerOptions: {}
}
},
methods:{
// Apply for extension button click event , Open the dialog box for filling in extension application information
openDelay(row) {
this.pickerOptions = {};
this.delayReport = row;
this.delayDialogFormVisible = true;
// Calculate the date analysis_occure_time The format is 2021/12/20 It needs to be converted into 2021-12-20
let occure_time = this.delayReport.analysis_occure_time.replaceAll('/', '-');
let dateDis = new Date(occure_time);//new Date() Returns the Chinese standard time format
dateDis.setDate(dateDis.getDate() + 30); // Planned date plus 30 God
this.pickerOptions = {
disabledDate(time) {
return time.getTime() < new Date(dateDis).getTime();
},
}
},
}

disabledDate(time){ } Set the disable date in ,time.getTime The time format of is a timestamp , Therefore, the disabled date format should also be set through new Date( dateDis).getTime() Convert to timestamp format , Make sure that the two time formats are consistent .
版权声明
本文为[ZMJ_ QQ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230616457496.html
边栏推荐
- Plato farm - a game of farm metauniverse with Plato as the goal
- Analysis of InnoDB execution process in MySQL
- flask项目跨域拦截处理以及dbm数据库学习【包头文创网站开发】
- Sort out several uses of network IP agent
- 4. DRF permission & access frequency & filtering & sorting
- Qt绘制图像
- Keyword interpretation and some APIs in RT thread
- 只是不断地建构平台,不断地收拢流量,并不能够做好产业互联网
- ZigBee CC2530 minimum system and register configuration (1)
- Calculate the past date and days online, and calculate the number of live days
猜你喜欢

Plato Farm-以柏拉图为目标的农场元宇宙游戏
![[Blue Bridge Cup] April 17 provincial competition brushing training (the first three questions)](/img/7d/23e2a611bc6a0d0239abdc79e2e8cf.png)
[Blue Bridge Cup] April 17 provincial competition brushing training (the first three questions)

8 websites that should be known for product development to enhance work experience

Realize several "Postures" in which a box is horizontally and vertically centered in the parent box

SSM framework series - data source configuration day2-1

【csnote】ER图

SSM框架系列——Junit单元测试优化day2-3

QT double buffer drawing

What are the forms of attack and tampering on the home page of the website

Fashion cloud learning - input attribute summary
随机推荐
CGC: contractual graph clustering for community detection and tracking
教你快速开发一个 狼人杀微信小程序(附源码)
4. DRF permission & access frequency & filtering & sorting
Plato Farm-以柏拉图为目标的农场元宇宙游戏
Remote sensing image classification and recognition system based on convolutional neural network
Softbank vision fund entered the Web3 security industry and led a new round of investment of US $60 million in certik
box-sizing
BUUCTF WEB [BJDCTF2020]The mystery of ip
有趣的IDEA插件推荐,给你的开发工作增添色彩
Markdown grammar learning
Homomorphic encryption technology learning
Use source insight to view and edit source code
Resolve disagrees about version of symbol device_ create
使用Source Insight查看编辑源代码
Ad20 supplementary note 3 - shortcut key + continuous update
[unity note] basic lighting in l4unity
QT redraw events and cuts
PHP generates JSON to process Chinese
如何防止网站被黑客入侵篡改
【unity笔记】L4Unity中的基础光照