import '../../style/finance.less';
import React, {Component} from 'react';
import {inject,observer} from 'mobx-react';
import {WeaTop, WeaRightMenu} from 'ecCom';
import Authority from '../../public/coms/Authority';
import Content from './Content';

@inject('financeStore')
@inject('hrmCard')
@observer
export default class Finance extends Component{
    componentDidMount(){
        this.init(this.props);
    }

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

    init = props => {
        this.props.financeStore.init(props)
    }

    render(){
        const {financeStore: store} = this.props;
        const {fromcard, topProps} = store;

        let com;
        if(fromcard){
            com = (
                <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@pxe5hg`} datas={topProps.dropMenuDatas}>
                    <Content ecId={`${this && this.props && this.props.ecId || ''}_Content@pzgnr9`} store={store} />
                </WeaRightMenu>
            )
        }else{
            com = (
                <WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@tog55a`} {...topProps}>
                    <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@fcxnug`} datas={topProps.dropMenuDatas}>
                        <Content ecId={`${this && this.props && this.props.ecId || ''}_Content@j7qze4`} store={store} />
                    </WeaRightMenu>
                </WeaTop>
            )
        }

        return (
            <div className='hrm_finance'>
                <Authority ecId={`${this && this.props && this.props.ecId || ''}_Authority@lulowc`} store={store}>
                    {com}
                </Authority>
            </div>
        )
    }
}