<el-date-picker v-model="ruleForm.dateTime"
type="datetime"
placeholder="选择日期时间"
:picker-options="pickerOptions"></el-date-picker>
<script>
export default {
data () {
const validateDateTime = (vm) => {
return (rule, value, callback) => {
const start = new Date(vm.ruleForm.dateTime).getTime();
if (start < Date.now()) {
callback(new Error('定时执行时间需大于当前时间'));
} else {
callback();
}
}
}
return {
ruleForm: {
dateTime:'',
},
pickerOptions: {
disabledDate(time) {
return time.getTime() < Date.now()- 8.64e7;
},
},
rules: {
dateTime:[
{ required: true, message: "必填,请输入", trigger: "blur" },
{ validator: validateDateTime(this), trigger: "blur" }
],
},
};
},
methods:{}
</script>