<FormItem label={item.name} >
{getFieldDecorator(${item.id}
, {initialValue:item.defaultValue||''})(<RangePicker
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={['开始时间', '结束时间']} />)}
</FormItem>
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')
}
网友评论