import '../../style/attendanceSynSetting.less';
import React, {
	Component
} from 'react';
import {
	inject,
	observer
} from 'mobx-react';
import {Spin} from 'antd';
import {
	WeaTop,
	WeaAlertPage,
	WeaRightMenu,
	WeaLocaleProvider
} from 'ecCom';
import SyncSetting from './SyncSetting';
import FieldSetting from './FieldSetting';
import FieldSettingExplain from './FieldSettingExplain';
const getLabel = WeaLocaleProvider.getLabel;
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@dbuvx2`} spinning={spinning}>
					<WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@7ce6bq`}
						title={getLabel(33740, '数据同步设置')}
						icon={<i className='icon-coms-hrm'/>}
						iconBgcolor='#217346'
						showDropIcon={true}
						buttons={btns}
						dropMenuDatas={menus}
					>
						<WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@eo9h6g`} datas={menus}>
							<SyncSetting ecId={`${this && this.props && this.props.ecId || ''}_SyncSetting@wirlhl`} store={store} />
							<FieldSetting ecId={`${this && this.props && this.props.ecId || ''}_FieldSetting@6hkz5r`} store={store} />
							<FieldSettingExplain ecId={`${this && this.props && this.props.ecId || ''}_FieldSettingExplain@szhpph`} store={store} />
						</WeaRightMenu>
					</WeaTop>
					</Spin>
				}
				{
					containerInitFinished.init && !containerInitFinished.authorized && 
	              	<WeaAlertPage ecId={`${this && this.props && this.props.ecId || ''}_WeaAlertPage@qdtzgw`}>
	                  	<div style={{ color: '#000' }}>{i18n.message.authFailed()}</div> 
	                </WeaAlertPage>
				} 
			</div>
		)
	}
}