时间选择器,某个时间之前不可选
<el-form-item label="处理时间">
<el-date-picker
clearable
v-model="timeDealForm.nodeTime"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="请选择处理时间"
:picker-options="pickerOptions1"
>
</el-date-picker>
watch: {
'timeDealForm.nodeTime'(selectTime) {
const date = moment(selectTime).format('YYYY-MM-DD');
if(this.preNode){
const preNodeTime = moment(this.preNode.nodeTime).format('YYYY-MM-DD');
if (date === preNodeTime){
this.pickerOptions1.selectableRange = `${moment(this.preNode.nodeTime).format('HH:mm:ss')} - 23:59:59`
} else {
this.pickerOptions1.selectableRange = '00:00:00 - 23:59:59'
}
}
},
},
getTimePickerRange(dateStr) {
this.pickerOptions1 = {
disabledDate(time) {
var date = new Date(dateStr);
var time1 = date.getTime() - 1 * 24 * 60 * 60 * 1000; //得到时间戳
return time.getTime() < time1;
},
selectableRange: '00:00:00 - 23:59:59'
};
},
this.getTimePickerRange("2022-12-20 10:10:50");