import '../../style/attendanceSynSetting.less';
import React, {
	Component
} from 'react';
import {
	inject,
	observer
} from 'mobx-react';
import {Spin} from 'antd';
import {
	WeaTop,
	WeaAlertPage,
	WeaRightMenu,
	WeaSearchGroup,
	WeaTableEdit
} from 'ecCom';
import SyncSetting from './SyncSetting';
import FieldSetting from './FieldSetting';
import FieldSettingExplain from './FieldSettingExplain';
import {
	i18n
} from '../../public/i18n';

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

	componentDidMount() {
		this.init();
	}

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

	init = () => {
		const {
			hrmAttendanceSyncSetting: store,
			hrmImportResource
		} = this.props;
		const {
			checkAuthorized,
			initData
		} = store;
		checkAuthorized('schedulesignimport', null, initData);
	}

	render() {
		const {
			hrmAttendanceSyncSetting: store
		} = this.props;
		const {
			containerInitFinished,
			topBtnAndMenu,
			searchGroupList,
			spinning
			// editTableConfig
		} = store;
		const {
			btns,
			menus
		} = topBtnAndMenu();

		return (
			<div className="hrm_module_container attendanceSynSetting">
				{
					containerInitFinished.init && containerInitFinished.authorized &&
					<Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@2zgdou`} spinning={spinning}>
					<WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@89rsnw`}
						title={i18n.module.dataSyncSetting()}
						icon={<i className='icon-coms-hrm'/>}
						iconBgcolor='#217346'
						showDropIcon={true}
						buttons={btns}
						dropMenuDatas={menus}
					>
						<WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@xdibfj`} datas={menus}>
							<SyncSetting ecId={`${this && this.props && this.props.ecId || ''}_SyncSetting@lwn5n3`} store={store} />
							<FieldSetting ecId={`${this && this.props && this.props.ecId || ''}_FieldSetting@6n1c2s`} store={store} />
							<FieldSettingExplain ecId={`${this && this.props && this.props.ecId || ''}_FieldSettingExplain@veiqzy`} store={store} />
						</WeaRightMenu>
					</WeaTop>
					</Spin>
				}
				{
					containerInitFinished.init && !containerInitFinished.authorized && 
	              	<WeaAlertPage ecId={`${this && this.props && this.props.ecId || ''}_WeaAlertPage@xkubmf`}>
	                  	<div style={{ color: '#000' }}>{i18n.message.authFailed()}</div> 
	                </WeaAlertPage>
				} 
			</div>
		)
	}
}