<template>
<el-date-picker
v-model="historyQuery.condition.lastUpdatedStart"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择开始时间"
@change="getHistoryData"
:picker-options="startDatePicker"
size="small"
>
</el-date-picker>
<span class="duration">至</span>
<el-date-picker
v-model="historyQuery.condition.lastUpdatedEnd"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择结束时间"
@change="getHistoryData"
:picker-options="endDatePicker"
size="small"
>
</el-date-picker>
</template>
<script>
data(){
return{
startDatePicker: this.beginDate(),
endDatePicker: this.endDate()
},
methods:{
// 开始日期选择约束
beginDate() {
const self = this;
return {
disabledDate(time) {
if (self.historyQuery.condition.lastUpdatedStart) {
//如果结束时间不为空,则小于结束时间
return (
new Date(self.historyQuery.condition.lastUpdatedStart).getTime() <
time.getTime()
);
}
}
};
},
//结束日期选择的约束
endDate() {
const self = this;
return {
disabledDate(time) {
if (self.historyQuery.condition.lastUpdatedEnd) {
//如果开始时间不为空,则结束时间大于开始时间
return (
new Date(self.historyQuery.condition.lastUpdatedEnd).getTime() >
time.getTime()
);
}
}
};
}
}
}
</script>
el-date约束日期
最新推荐文章于 2024-03-07 18:29:35 发布