import '../../../style/report.less';
import React, {Component} from 'react';
import {inject,observer} from 'mobx-react';
import {WeaTop, WeaAlertPage, WeaRightMenu, WeaLocaleProvider} from 'ecCom';
import {Spin} from 'antd';
import {i18n} from '../../../public/i18n';
import SearchGroup from './SearchGroup';
import DataList from './DataList';
const getLabel = WeaLocaleProvider.getLabel;


@inject('hrmAttendanceMonthCalendarReport')
@observer
export default class MonthCalendarReport extends Component{
    constructor(props) {
		super(props);
	}

	componentDidMount() {
        this.init();
	}

	componentWillReceiveProps(nextProps) {
		if (this.props.location.key !== nextProps.location.key) {
			this.init();
		}
    }

    init = () => {
        const {
            hrmAttendanceMonthCalendarReport: store
        } = this.props;
        store.init();
    }
    
    render(){
        const {hrmAttendanceMonthCalendarReport: store} = this.props;
        const {containerInitFinished, getTopProps, spinning, spinTip} = store;
        const {buttons, menus} = getTopProps();
        const topProps = {
            title: getLabel('506322','考勤日历报表'),
			icon: <i className='icon-coms-hrm'/>,
			iconBgcolor: '#217346',
			showDropIcon: true,
			buttons: buttons,
			dropMenuDatas: menus
        }
        return (
            <div className="hrm_module_container report">
			{
                containerInitFinished.init && containerInitFinished.authorized &&
                <Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@wrb9dd`} spinning={spinning} tip={spinTip}>
                    <WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@h9kkyl`} {...topProps}>
                        <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@y4s3ma`} datas={menus} >
                            <div className='layout'>
                                <div className='layoutContent includeFoot'>
                                    <SearchGroup ecId={`${this && this.props && this.props.ecId || ''}_SearchGroup@qlzp5y`} store={store}/>
                                    <DataList ecId={`${this && this.props && this.props.ecId || ''}_DataList@d7l7e9`} store={store} />
                                </div>
                            </div>
                        </WeaRightMenu>
                    </WeaTop>
                </Spin>
			}
			{
				containerInitFinished.init && !containerInitFinished.authorized && 
              	<WeaAlertPage ecId={`${this && this.props && this.props.ecId || ''}_WeaAlertPage@0wuudu`}>
                  	<div style={{ color: '#000' }}>{i18n.message.authFailed()}</div>
              	</WeaAlertPage>
			}
            </div>
        )
    }
}