当前位置:网站首页>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
边栏推荐
- 4. DRF permission & access frequency & filtering & sorting
- Calculate the past date and days online, and calculate the number of live days
- 如何实现点击一下物体播放一次动画
- Buuctf Web [bjdctf2020] zjctf, but so
- Aviation core technology sharing | overview of safety characteristics of acm32 MCU
- 0基础可以考CPDA数据分析师证书吗
- QT double buffer drawing
- Introduction to metalama 4 Use fabric to manipulate items or namespaces
- leetcode:437. Path sum III [DFS selected or not selected?]
- QT redraw events and cuts
猜你喜欢
box-sizing
STM32 control stepper motor (ULN2003 + 28byj)
使用Source Insight查看编辑源代码
What are the forms of attack and tampering on the home page of the website
ZigBee CC2530 minimum system and register configuration (1)
如何防止网站被黑客入侵篡改
How do traditional enterprises cope with digital transformation? These books give you the answer
Introduction to kubernetes
梳理网络IP代理的几大用途
SSM framework series - annotation development day2-2
随机推荐
如何实现点击一下物体播放一次动画
梳理網絡IP代理的幾大用途
Deploying MySQL in cloud native kubesphere
Qt双缓冲绘图
Ad20 supplementary note 3 - shortcut key + continuous update
98. Error s.e.errormvcautoconfiguration $staticview reported by freemaker framework: cannot render error page for request
[unity note] basic lighting in l4unity
Stacks and queues a
Uni app native app local packaging integrated Aurora push (jg-jpush) detailed tutorial
STM32 project transplantation: transplantation between chip projects of different models: Ze to C8
leetcode-791. 自定义字符串排序
[csnote] ER diagram
box-sizing
SSM framework series - data source configuration day2-1
Labels and paths
对话PostgreSQL作者Bruce:“转行”是为了更好地前行
Softbank vision fund entered the Web3 security industry and led a new round of investment of US $60 million in certik
Everything can be expected in the future | one 2022 campus recruitment officially opened
NPDP | how can product managers not be excluded by programmers?
SSL证书退款说明