動(dòng)態(tài)禁用日期
<el-form-item label="合同終止時(shí)間" prop="contractEndDate">
<el-date-picker
v-model="addFrom.contractEndDate"
:clearable="false"
:picker-options="pickerOptions"
value-format="yyyy-MM-dd HH:mm:ss"
type="datetime"
placeholder="請(qǐng)選擇合同結(jié)束時(shí)間" />
</el-form-item>
computed: {
pickerOptions: function() {
const _this = this
return {
disabledDate(time) {
const licenseStart = new Date(_this.addFrom.contractStartDate)
licenseStart.setDate(licenseStart.getDate() + 1)
return time.getTime() < licenseStart.getTime()
}
}
}
},
只可選擇此時(shí)此刻后面的日期
<el-form-item label="上門服務(wù)時(shí)間" label-width="100px">
<el-date-picker
v-model="registerForm.onSiteServiceTime"
:editable="false"
type="datetime"
:picker-options="pickerOptions"
:clearable="false"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="選擇日期"
/>
</el-form-item>
selectableRange: (() => {
const data = new Date()
const hour = data.getHours()
const minute = data.getMinutes()
const second = data.getSeconds()
return [`${hour}:${minute}:${second} - 23:59:59`]
})(),
disabledDate(time) {
var date = new Date()
date.setFullYear(date.getFullYear() + 2)
date.setDate(date.getDate() - 1)
return time.getTime() < Date.now() - 8.64e7 || time.getTime() > date.getTime()
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者