import React from 'react';
import {
	inject,
	observer
} from 'mobx-react';
import {
	WeaLocaleProvider
} from 'ecCom';
import Base from './Base';
import * as asyncFetch from '../../apis/dutyType';
const getLabel = WeaLocaleProvider.getLabel;
const {
	getLocaleLabelByCode
} = WeaLocaleProvider;

@inject('hrmBrowseBoxLinkPage')
@observer
export default class DutyType extends React.Component {
	constructor(props) {
		super(props);
		this.state = {
			reRender: false
		}
	}

	componentDidMount() {
		getLocaleLabelByCode('hrm').then(() => this.setState({
			reRender: true
		}));
		['setTopTitle', 'getFormElements'].map((f, i) => {
			let params;
			if (i === 0) {
				params = {
					title: () => getLabel('391222', "职务类别")
				}
			} else {
				params = {
					asyncFetch,
					fetchParams: {
						jobgroupid: this.props.location.query.id
					}
				};
			}

			this.props.hrmBrowseBoxLinkPage[f](params);
		});
	}

	render() {
		if (!this.state.reRender)
			return <div />
		return (
			<Base ecId={`${this && this.props && this.props.ecId || ''}_Base@2jldyh`} />
		)
	}
}