时间控件DatePicker-RangePicker


{getFieldDecorator(${item.id}, {initialValue:item.defaultValue||''})( ranges={item.ranges || { 今天: [moment(todayDate.beginTime, 'YYYY/MM/DD HH:mm:ss'), moment(todayDate.endTime, 'YYYY/MM/DD HH:mm:ss')] }}
disabledDate={item.isAllowAfterTime ? () => false :(e)=>this.disabledDate(e,item)}
onCalendarChange={this.onCalendarChange}
onOpenChange={this.onDateOpenChange}
allowClear={item.allowClear || false}
showTime={{
hideDisabledOptions: true,
defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')],
}}
format="YYYY/MM/DD HH:mm:ss"
placeholder={['开始时间', '结束时间']} />)}

onCalendarChange = (dates) =>{
if (!dates || !dates.length) {
return
}
this.setState({
selectDate:dates[1]
})
};

onDateOpenChange = ()=>{
this.setState({
selectDate:null
})
}

disabledDate = (current,item) =>{
const { selectDate } = this.state;
if (!current){
return false
}
if(current&&!selectDate&&item.defaultValue){
return current < moment().subtract(3,'month').subtract(1,'day') || current > moment().endOf('day')
}

if(current&&selectDate){
  let selectV = moment(selectDate.valueOf()).format('YYYY/MM/DD HH:mm:ss');
  return current < moment(selectV).subtract(3, 'months')  || current > moment().endOf('day') // ||current >  moment(selectV).add(3,'month') //选择的之后三个月
};

return current > moment().endOf('day')

}

你可能感兴趣的:(时间控件DatePicker-RangePicker)