|
@ -38,40 +38,69 @@ class NoticeCalendar extends Component { |
|
|
} |
|
|
} |
|
|
monthCellRender(value, locale) { |
|
|
monthCellRender(value, locale) { |
|
|
const prefixCls = this.props.prefixCls; |
|
|
const prefixCls = this.props.prefixCls; |
|
|
|
|
|
const render = this.props.monthCellRender; |
|
|
|
|
|
let content; |
|
|
|
|
|
if (render) { |
|
|
|
|
|
content = <div className={`${prefixCls}-fullscreen-month`}> |
|
|
|
|
|
{render(value)} |
|
|
|
|
|
</div>; |
|
|
|
|
|
} else { |
|
|
const month = value.getMonth(); |
|
|
const month = value.getMonth(); |
|
|
const noteNum = this.props.getMonthData(value); |
|
|
const noteNum = this.props.getMonthData(value); |
|
|
if (noteNum > 0) { |
|
|
if (noteNum > 0) { |
|
|
return ( |
|
|
content = ( |
|
|
<a className={`${prefixCls}-fullscreen-month`}> |
|
|
<div className={`${prefixCls}-fullscreen-month`}> |
|
|
<span>{locale.format.shortMonths[month]}</span> |
|
|
<span>{locale.format.shortMonths[month]}</span> |
|
|
<MonthCellNoteNum num={noteNum} prefixCls={`${prefixCls}-notes`} /> |
|
|
<MonthCellNoteNum num={noteNum} prefixCls={`${prefixCls}-notes`} /> |
|
|
</a> |
|
|
</div> |
|
|
); |
|
|
); |
|
|
|
|
|
} else { |
|
|
|
|
|
content = <div className={`${prefixCls}-fullscreen-month`}> |
|
|
|
|
|
{locale.format.shortMonths[month]} |
|
|
|
|
|
</div>; |
|
|
} |
|
|
} |
|
|
return ( |
|
|
} |
|
|
<a className={`${prefixCls}-fullscreen-month`}>{locale.format.shortMonths[month]}</a> |
|
|
return content; |
|
|
); |
|
|
|
|
|
} |
|
|
} |
|
|
fullscreenDateCellRender(value) { |
|
|
fullscreenDateCellRender(value) { |
|
|
const prefixCls = this.props.prefixCls; |
|
|
const prefixCls = this.props.prefixCls; |
|
|
let listData = this.props.getDateData(value); |
|
|
const render = this.props.dateCellRender; |
|
|
return ( |
|
|
let content; |
|
|
<span className={`${prefixCls}-fullscreen-date`}> |
|
|
if (render) { |
|
|
|
|
|
content = <span className={`${prefixCls}-fullscreen-date`}> |
|
|
|
|
|
{render(value)} |
|
|
|
|
|
</span>; |
|
|
|
|
|
} else { |
|
|
|
|
|
content = <span className={`${prefixCls}-fullscreen-date`}> |
|
|
<span>{ zerofixed(value.getDayOfMonth()) }</span> |
|
|
<span>{ zerofixed(value.getDayOfMonth()) }</span> |
|
|
<div className={`${prefixCls}-note-list-wrapper`}><NoteList listData={listData} /></div> |
|
|
<div className={`${prefixCls}-note-list-wrapper`}> |
|
|
</span> |
|
|
<NoteList listData={this.props.getDateData(value)} /> |
|
|
); |
|
|
</div> |
|
|
|
|
|
</span>; |
|
|
|
|
|
} |
|
|
|
|
|
return content; |
|
|
} |
|
|
} |
|
|
dateCellRender(value) { |
|
|
dateCellRender(value) { |
|
|
const prefixCls = this.props.prefixCls; |
|
|
const prefixCls = this.props.prefixCls; |
|
|
const el = (<span className={`${prefixCls}-date ${prefixCls}-notes-date`}>{ zerofixed(value.getDayOfMonth()) }</span>); |
|
|
const render = this.props.dateCellRender; |
|
|
|
|
|
let content; |
|
|
|
|
|
if (render) { |
|
|
|
|
|
content = <div style={{ position: 'relative' }}> |
|
|
|
|
|
{render(value)} |
|
|
|
|
|
</div>; |
|
|
|
|
|
} else { |
|
|
const listData = this.props.getDateData(value); |
|
|
const listData = this.props.getDateData(value); |
|
|
return ( |
|
|
content = <div style={{ position: 'relative' }}> |
|
|
<div style={{ position: 'relative' }}> |
|
|
<span className={`${prefixCls}-date ${prefixCls}-notes-date`}> |
|
|
{ el } |
|
|
{zerofixed(value.getDayOfMonth())} |
|
|
{ (listData && listData.length > 0) ? <div className={`${prefixCls}-notes-wrapper`}><Notes listData={listData} /></div> : null } |
|
|
</span> |
|
|
</div> |
|
|
{(listData && listData.length > 0) ? |
|
|
); |
|
|
<div className={`${prefixCls}-notes-wrapper`}> |
|
|
|
|
|
<Notes listData={listData} /> |
|
|
|
|
|
</div> : null} |
|
|
|
|
|
</div>; |
|
|
|
|
|
} |
|
|
|
|
|
return content; |
|
|
} |
|
|
} |
|
|
setValue(value) { |
|
|
setValue(value) { |
|
|
if (this.state.value !== value) { |
|
|
if (this.state.value !== value) { |
|
@ -93,11 +122,10 @@ class NoticeCalendar extends Component { |
|
|
render() { |
|
|
render() { |
|
|
const props = this.props; |
|
|
const props = this.props; |
|
|
const {value, type} = this.state; |
|
|
const {value, type} = this.state; |
|
|
const {locale, prefixCls, style, className, fullscreen, monthCellRender, dateCellRender, fullscreenDateCellRender} = props; |
|
|
const {locale, prefixCls, style, className, fullscreen} = props; |
|
|
|
|
|
const dateCellRender = fullscreen |
|
|
|
|
|
? this.fullscreenDateCellRender : this.dateCellRender; |
|
|
|
|
|
|
|
|
const _monthCellRender = monthCellRender ? monthCellRender : this.monthCellRender; |
|
|
|
|
|
const _dateCellRender = dateCellRender ? dateCellRender : this.dateCellRender; |
|
|
|
|
|
const _fullscreenDateCellRender = fullscreenDateCellRender ? fullscreenDateCellRender : this.fullscreenDateCellRender; |
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<div className={prefixCls + '-wrapper' + (className ? ' ' + className : '') + (fullscreen ? ' ' + prefixCls + '-wrapper-fullscreen' : '' )} style={style}> |
|
|
<div className={prefixCls + '-wrapper' + (className ? ' ' + className : '') + (fullscreen ? ' ' + prefixCls + '-wrapper-fullscreen' : '' )} style={style}> |
|
|
<Header |
|
|
<Header |
|
@ -115,8 +143,8 @@ class NoticeCalendar extends Component { |
|
|
showHeader={false} |
|
|
showHeader={false} |
|
|
value={value} |
|
|
value={value} |
|
|
onChange={this.onPanelChange.bind(this)} |
|
|
onChange={this.onPanelChange.bind(this)} |
|
|
monthCellRender={ fullscreen ? _monthCellRender.bind(this) : null } |
|
|
monthCellRender={ this.monthCellRender.bind(this) } |
|
|
dateCellRender={ fullscreen ? _fullscreenDateCellRender.bind(this) : _dateCellRender.bind(this) }/> |
|
|
dateCellRender={ dateCellRender.bind(this) } /> |
|
|
</div> |
|
|
</div> |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
@ -136,6 +164,7 @@ NoticeCalendar.propTypes = { |
|
|
onChange: PropTypes.func, |
|
|
onChange: PropTypes.func, |
|
|
onTypeChange: PropTypes.func, |
|
|
onTypeChange: PropTypes.func, |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
NoticeCalendar.defaultProps = { |
|
|
NoticeCalendar.defaultProps = { |
|
|
locale: CalendarLocale, |
|
|
locale: CalendarLocale, |
|
|
getMonthData: noop, |
|
|
getMonthData: noop, |
|
|