修改日期 | 修改人 | 备注 |
2020-11-27 10:29:38[当前版本] | 郁冲冲 | 1.1.0 |
2020-11-27 10:27:13 | 郁冲冲 | 1.1.0 |
<FormItem label="">
<Row>
<Col span="11">
<DatePicker type="date" :options="startTimeOptions" @on-change="startTimeChange" placeholder="开始时间"
v-model="starttime"></DatePicker>
</Col>
<Col span="2" style="text-align: center">-</Col>
<Col span="11">
<DatePicker type="date" :options="endTimeOptions" @on-change="endTimeChange" placeholder="结束时间"
v-model="endtime"></DatePicker>
</Col>
</Row>
</FormItem>
-
export
default {
-
data() {
-
return {
-
startTimeOptions: {},
//开始日期约束
-
endTimeOptions: {},
//结束日期约束
-
starttime:
'',
//开始日期
-
endtime:
'',
//结束日期
-
}
-
},
-
-
methods: {
-
startTimeChange:
function(e) {
//设置开始时间
-
this.starttime = e;
-
this.endTimeOptions = {
-
disabledDate:
date => {
-
let startTime =
this.starttime ?
new
Date(
this.starttime).valueOf() :
'';
-
return date && (date.valueOf() < startTime);
-
// return date && (date.valueOf() < startDate-86400000 || date.valueOf() > Date.now()-86400000) ; 此约束为当日之前开始日期之后
-
}
-
}
-
},
-
endTimeChange:
function(e) {
//设置结束时间
-
this.endtime = e;
-
let endTime =
this.endtime ?
new
Date(
this.endtime).valueOf() -
1 *
24 *
60 *
60 *
1000 :
'';
-
this.startTimeOptions = {
-
disabledDate(date) {
-
return date && date.valueOf() > endTime;
-
}
-
}
-
},
-
}
-
}