Based on written before the end date of restriction and limitation dates are in control element ui start date, the project has recently requested to be a limit date within 30 days, and then the previous code refactoring a bit.
code show as below
<el-form-item label="开始日期" label-width="90px" prop="startDate"> <el-date-picker v-model="statDate" :picker-options="startDateOptions" type="date" clearable style="width:140px" value-format="yyyy-MM-dd" placeholder="开始日期"/> </el-form-item> <Item-form-EL label = "End Date" label-width="90px" prop="endDate"> <el-date-picker v-model="endDate" :picker-options="EndDateOptions" type="date" clearable style="width:140px" value-format="yyyy-MM-dd" placeholder="结束日期"/> </el-form-item> export default{ data() { return { // 时间开始测试 startDateOptions: { // console.log(time) disabledDate: (Time) => { const * Day 24 * 30 = 3600 * 1000 milliseconds // convert the date return time.getTime ()> Date.now (this.endDate ) - 8.64e7 || time.getTime () <new date (this.endDate) .getTime ( ) - day // if the day is optional, do not cut 8.64e7, the limit date minus 30 days in an optional end date, no other dates optional } the else { return time.getTime () <a Date new new (this.endDate) .getTime () || time.getTime ()> Date.now () || time.getTime ()> Date.now (this.endDate) - 8.64e7 } } } // end of the test time EndDateOptions: { disabledDate: (time) => { IF (this.statDate) { const Day 30 = 24 * 3600 * 1000 * if (this.endDate) {
return time.getTime ()> new new a Date (this.statDate) .getTime () + Day || time.getTime ()> Date.now ()
|| time.getTime () <new Date (this.statDate) .getTime || time.getTime ()> Date.now (this.statDate) - 8.64e7 // if the day is optional, do not cut 8.64e7
the else {} return time.getTime () <a Date new new (this.statDate) .getTime () || time.getTime ()> Date.now () || time.getTime ()> Date.now (this.statDate) - 8.64e7 // if the day is optional, do not cut 8.64e7
} } }, statDate: '', // end date endDate: '', // start date to end date } } }
In fact, did not do much of a change, it is to return to the conditions changed a bit, a bit processing data on it. mutual encouragement!