import React from "react";
import {inject, observer} from 'mobx-react';
import {WeaDialog,WeaSearchGroup,WeaProgress,WeaLocaleProvider,WeaNewScroll,WeaRightMenu} from "ecCom";
import {Button} from 'antd';
import "./style/default.css"

import SycnProcess from './sycnProcess'

const getLabel = WeaLocaleProvider.getLabel;

@inject("coremailStore")
@inject('intelogin')
@observer
class InitializedData extends React.Component{
    constructor(props) {
        super(props);
        this.getButtons = this.getButtons.bind(this);
        this.getRightMenus = this.getRightMenus.bind(this);
    }


    componentWillUnmount() {
        const {coremailStore:cs}= this.props;
        cs.clearTimer();
    }

    getButtons(){
        let buttons = [];
        return buttons;
    }

    getRightMenus(){
        let menus = [];
        return menus;
    }

    render() {
        const footer = [];
        const {coremailStore: cs} = this.props;
        const {oncancelInit} = cs;
        const {showInit} = this.props;
        const moreBtn = {
            datas: [
                {
                    key: "1",
                    disabled: false,
                    icon: <i className="icon-coms-Clear"/>,
                    content: getLabel('309','关闭') ,
                    onClick: key => oncancelInit()
                },

            ]
        };
        let {initialList} = this.props;
        if (!initialList) {
            initialList = [];
        }
        return <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@6xd6gg`}
            title={getLabel('506793','CoreMail集成初始化') }
            icon="icon-coms-portal"
            iconBgcolor='#1a57a0'
            style={{width: 1050, height: 734, paddingTop: '16px'}}
            zIndex={100}
            buttons={footer}
            hasScroll={true}
            scalable
            visible={showInit}
            onCancel={() => oncancelInit()}
            moreBtn={moreBtn}
            buttons={this.getButtons()}
        >
            <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@zu96fp`} datas={this.getRightMenus()}>
                <WeaNewScroll ecId={`${this && this.props && this.props.ecId || ''}_WeaNewScroll@6zdgys`}
                    height={'100%'}
                    onScroll={(e) => {
                        this.setState({
                            scrollTop: e.target.scrollTop,
                        })
                    }}
                >
                    {initialList.length>0?
                        initialList.map((item, idx) =>
                            <WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@rr4s6c@integrationCoremailInitisalizeData${idx}`} key={idx} title={item.title} style={{width: '100%', height: '210px'}}
                                            showGroup={true}>
                                <div className={'int-initial-sycn-item'}>
                                    <SycnProcess ecId={`${this && this.props && this.props.ecId || ''}_SycnProcess@vi2zyo@integrationCoremailInitisalizeDataSub${idx}`} type={1} syncData={item.subSyncProcess}/>
                                    <SycnProcess ecId={`${this && this.props && this.props.ecId || ''}_SycnProcess@zp0gpp@integrationCoremailInitisalizeDataDept${idx}`} type={2} syncData={item.deptSyncProcess}/>
                                    <SycnProcess ecId={`${this && this.props && this.props.ecId || ''}_SycnProcess@ffvh2i@integrationCoremailInitisalizeDataHr${idx}`} type={3} syncData={item.hrSyncProcess}/>
                                </div>
                            </WeaSearchGroup>
                        ):<div style={{width: '100%',
                            height: '30px',
                            position: 'relative',
                            top: '50%',
                            textAlign: 'center',
                            marginTop: '-15px',
                            color: '#333333',
                            fontSize: '14px',}}>
                            {getLabel('506794','暂无同步数据！') }
                    </div>
                    }
                </WeaNewScroll>
            </WeaRightMenu>
        </WeaDialog>
    }
}

export default InitializedData;