import React, {Component} from 'react';
import {
	observer,
	inject
} from 'mobx-react';
import {Button} from 'antd';
import {WeaTop, WeaLocaleProvider} from 'ecCom';
import {FormInfo} from '../../../hrmComsPublic/index';
import UpgradeResult from './UpgradeResult';
import {addContentPath} from '../../util/index.js'
const getLabel = WeaLocaleProvider.getLabel;

@observer
export default class Right extends Component{
    render(){
        const {store} = this.props;
        const {upgradeInfo, checkUpgrade, viewType, formTarget, refreshTime,itemRender} = store;
        const topProps = {
			title: upgradeInfo.title,
			icon: <i className='icon-coms-hrm'/>,
			iconBgcolor: '#217346'
        }
        const {
            form,
            formFields: fields
        } = formTarget;
        return (
            <div className='right'>
                <WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@jh2ibw`} {...topProps}>
                    {
                        viewType == 1 ? 
                        <div className='upgradeInfo'>
                            <div className='content'>
                                <div className='icon'>
                                    <img src={addContentPath('/hrm/hrm_e9/images/upgrade.png')} />
                                </div>
                                <div className='info'>{upgradeInfo.count}</div>
                                {
                                    form != null && form.isFormInit && 
                                    <div className='calendarForm'>
                                        <div className='label'>{getLabel('503421','升级数据时间段:')}</div>
                                        <FormInfo ecId={`${this && this.props && this.props.ecId || ''}_FormInfo@i2c219`} 
                                        className='formComponent'
                                        showLabel={false} 
                                        center={false} 
                                        form={form} 
                                        formFields={fields} 
                                        itemRender={itemRender}/>
                                    </div>
                                }
                                <div className='doUpgrade'>
                                    <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@32mm4s`} type='primary' onClick={checkUpgrade}>{getLabel('505867','开始升级')}</Button>
                                </div>
                            </div>
                        </div>
                        :
                        <UpgradeResult ecId={`${this && this.props && this.props.ecId || ''}_UpgradeResult@oyxzfu`} store={store} />
                    }
                </WeaTop>
            </div>
        )
    }
}