<el-date-picker
v-model="exportList.value"
type="daterange"
range-separator="-"
:start-placeholder="exportList.exportStartTime"
:end-placeholder="exportList.exportStartTime"
:picker-options="exportList.pickerOptions"
>
</el-date-picker>
// 导出日期配置
exportList:{
choiceDate: "",
pickerOptions: {
onPick: ({ maxDate, minDate }) => {
// 把选择的第一个日期赋值给一个变量。
this.choiceDate = minDate.getTime();
// 如何你选择了两个日期了,就把那个变量置空
if (maxDate) this.choiceDate = "";
},
disabledDate: (time) => {
// console.log("time",time)
// 如何选择了一个日期
if (this.choiceDate) {
// 7天的时间戳
const one = 31 * 24 * 3600 * 1000;
// 当前日期 - one = 7天之前
const minTime = this.choiceDate - one;
// 当前日期 + one = 7天之后
const maxTime = this.choiceDate + one;
return (
time.getTime() < minTime ||
time.getTime() > maxTime ||
// 限制不能选择今天及以后
time.getTime() > Date.now()
);
} else {
// 如果没有选择日期,就要限制不能选择今天及以后
return time.getTime() > Date.now();
}
},
},
exportStartTime:'开始时间',
exportEndTime:'结束时间',
value:'',
},