After receiving the customer's request, let the last date and time of the default time in the time control be 23:59:59 after the first selection and the previous one is 00:00:00
Add change event Add: picker-options="pickerOptions "
<el-date-picker
style="width: 100%"
v-model="form.Timeorder"
type="datetimerange"
value-format="yyyy-MM-dd HH:mm:ss"
@change="changeTimer"
:picker-options="pickerOptions"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
>
</el-date-picker>
Add in pickerOptions in data
timeDate :'',
pickerOptions : {
onPick: ({ end , start}) => {
if (start) {
this.choiceDate = start.getTime()
}
if (end ) {
document.getElementsByClassName('el-date-range-picker__time-picker-wrap')[3].getElementsByClassName('el-input__inner')[0].value = '23:59:59'
this.timeDate= ''
}
},
}
Process value in changeTimer event
changeTimer() {
let value
if (this.form.Timeorder) {
value = new Date(this.form.Timeorder[1])
if (value.getHours() === 0 && value.getMinutes() === 0 && value.getSeconds() === 0) {
let year = value.getFullYear()
let month = value.getMonth()
let date = value.getDate()
this.form.Timeorder[1] = `${year}-${month}-${date} 23:59:59`
}
}
}
Thanks to element ui datetimepicker How to modify the default time 00:00:00 that appears after clicking on the date? The answer on the second floor of the middle