<el-form-item label="计划年度:" prop="annual"> <el-date-picker v-model="formSelectVo.beginTime" style="width: calc(37.5% - 11px)" :picker-options="ispickerOptionEditStart" value-format="yyyy" type="year" @input="hQuery" />至 <el-date-picker v-model="formSelectVo.endTime" style="width: calc(37.5% - 11px)" :picker-options="ispickerOptionEditEnd" value-format="yyyy" type="year" @input="hQuery" /> </el-form-item>
computed: {
ispickerOptionEditEnd: function() {
const _this = this
return {
disabledDate(timeEd) {
const timeStart = new Date(_this.formSelectVo.beginTime)
return timeEd.getTime() < timeStart.getTime()
}
}
},
ispickerOptionEditStart: function() {
const _this = this
return {
disabledDate(timeSt) {
const timeEnd = new Date(_this.formSelectVo.endTime)
if (_this.formSelectVo.beginTime) {
return timeSt.getTime() > timeEnd.getTime()
}
}
}
},
},
disabledDate 设置禁用状态,参数为当前日期,要求返回 Boolean
:picker-options="pickerOptions1"
picker-options 当前时间日期选择器特有的选项参考下表
shortcuts | 设置快捷选项,需要传入 { text, onClick } 对象用法参考 demo 或下表 | Object[] | — | — |
disabledDate | 设置禁用状态,参数为当前日期,要求返回 Boolean | Function | — | — |
cellClassName | 设置日期的 className | Function(Date) | — | — |
firstDayOfWeek | 周起始日 | Number | 1 到 7 | 7 |
onPick | 选中日期后会执行的回调,只有当 daterange 或 datetimerange 才生效 |
Function({ maxDate, minDate }) | — | — |