<DatePicker @on-change="changeBeginDate" :options="beginDateOption" :value="formValidate.effectiveStartTime" @on-clear="clearBeginDate" type="datetime" format="yyyy-MM-dd HH:mm:ss" ></DatePicker>
<DatePicker @on-change="changeEndDate" :options="endDateOption" :value="formValidate.effectiveEndTime" @on-clear="clearEndDate" type="datetime" format="yyyy-MM-dd HH:mm:ss"></DatePicker>
changeBeginDate(e) { // 获取有效期开始时间
this.formValidate.effectiveStartTime = e;
if (e) { //判断日期的值为空时,不要设置disabledDate
this.endDateOption = {
disabledDate: date => {
let startTime = "";
let curD = new Date(e).toLocaleDateString();
if (new Date(curD).valueOf() < new Date(e).valueOf()) {
let s = new Date(e).valueOf() - new Date(curD).valueOf();
startTime = e ? new Date(e).valueOf() - s : "";
} else {
startTime = e ? new Date(e).valueOf() : "";
}
return date && date.valueOf() < startTime;
}
};
}
},
changeEndDate(e) { // 获取有效期结束时间
this.formValidate.effectiveEndTime = e;
if (e) { //判断日期的值为空时,不要设置disabledDate
this.beginDateOption = {
disabledDate: date => {
let endTime = e ? new Date(e).valueOf() : "";
return date && date.valueOf() > endTime;
}
};
}
},
clearBeginDate() {
// 清除有效期开始
this.endDateOption = {
disabledDate: date => {
return date.valueOf() < 0
}
}
},
clearEndDate() {
// 清除有效期结束
this.beginDateOption = {
disabledDate: date => {
return date.valueOf() < 0
}
}
},