import '../../style/roleSetting.less';
import React, {
	Component
} from 'react';
import {
	inject,
	observer
} from 'mobx-react';
import {
	WeaDialog
} from 'ecCom';
import RoleEdit from './RoleEdit';

@inject('hrmRoleSetting')

@observer
export default class RoleEditDialog extends Component {
	constructor(props) {
		super(props);
	}

	componentDidMount() {
		const {
			opt,
			hrmRoleSetting: store
		} = this.props;
		const {
			getTabInfo,
			roleEditTabConfig
		} = store;
		getTabInfo(null, store.authorizationInfo.canEdit);
	}

	componentWillReceiveProps(nextProps) {
		const {
			opt,
			hrmRoleSetting: store
		} = nextProps;
		const {
			initRoleEditDialog
		} = store;
		initRoleEditDialog(
			opt.params,
			opt.tabKey
		);
	}

	render() {
		const {
			hrmRoleSetting: store
		} = this.props;
		const {
			dialogParams,
			getDialogOpButtons,
			setDialogVisible,
			clearData,
			refreshTab,
			editorDialogRightMenu
		} = store;
		const {
			edit: editDialog
		} = dialogParams;

		const roleEditDialogProps = {
			icon: "icon-coms-hrm",
			iconBgcolor: "#217346",
			style: {
				width: 820,
				height: 550
			},
			title: editDialog.title,
			visible: editDialog.visible,
			onCancel: () => setDialogVisible('edit', false, '', clearData),
			buttons: getDialogOpButtons(),
			moreBtn: {datas: editorDialogRightMenu}
		}

		return (
			<WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@m8z5rc`} {...roleEditDialogProps}>
            	<RoleEdit ecId={`${this && this.props && this.props.ecId || ''}_RoleEdit@knpl8j`} store={store}/>
            </WeaDialog>
		)
	}
}