<template>
<el-form-item label="启用起止时间" prop="startDate">
<el-col :span="11">
<el-date-picker type="date" placeholder="选择日期" value-format="timestamp" v-model="form.startDate" style='width:100%' :picker-options="startTime1" ></el-date-picker>
</el-col>
<el-col class="line" :span="2" style="text-align:center" >-</el-col>
<el-col :span="11">
<el-date-picker
v-model="form.endDate"
type="date"
style='width:100%'
value-format="timestamp"
placeholder="选择日期" :picker-options="endTime1">
</el-date-picker>
</el-col>
</el-form-item>
</template>
data(){
return{
form{
startDate:null, // 启用起止时间
endDate: null, // 启用起止时间
},
startTime1: {
disabledDate: time => {
//如果已知开始日期,就把开始日期之前的日期禁用掉
if (this.form.endDate) {
return (
time.getTime() >new Date(this.form.endDate).getTime()
);
}
}
},
endTime1: {
disabledDate: time => {
//如果已知开始日期,就把开始日期之前的日期禁用掉
if (this.form.startDate) {
return (
time.getTime()<new Date(this.form.startDate).getTime()- (1 * 24 * 60 * 60 * 1000)+1
);
}
}
},
}
}
mounted(){
this.getdatatime()
},
methods: {
getdatatime(){//默认显示今天
this.form.startDate= new Date().getTime();
},
}
|