import {
	inject,
	observer,
} from 'mobx-react'
import {
	toJS
} from 'mobx'
import {
	WeaRightMenu,
} from 'ecCom'
import {
	WeaTableNew
} from 'comsMobx'
import {
	i18n
} from '../../public/i18n';
const WeaTable = WeaTableNew.WeaTable;

@inject('hrmAssImple')
@observer
export default class ThirdTable extends React.Component {
	constructor(props) {
		super(props);
	}

	componentDidMount() {
		this.props.hrmAssImple.getTableInfo();
	}

	getDropMenuDatas = () => {
		const {
			hrmAssImple,
		} = this.props, {
			menu,
		} = hrmAssImple, {
			rightMenu
		} = menu;

		let menus = [];
		toJS(rightMenu).map((item, index) => {
			let obj = {
				key: item.menuFun,
				icon: <i className={`${item.menuIcon}`}/>,
				content: item.menuName,
			}
			if (item.menuFun == 'log' || item.menuFun == 'collection' || item.menuFun == 'help' || item.menuFun == 'pageAddress') {
				obj.disabled = true;
			}
			menus.push(obj);
		})

		return menus;
	}

	handleMenuClick = (key) => {
		this[key] && this[key]();
	}

	custom = () => {
		const {
			hrmAssImple
		} = this.props, {
			thirdTable,
		} = hrmAssImple, {
			tableStore
		} = thirdTable;

		tableStore.setColSetVisible(true);
		tableStore.tableColSet(true);
	}

	render() {
		const {
			hrmAssImple,
		} = this.props, {
			thirdTable,
		} = hrmAssImple, {
			tableStore
		} = thirdTable;

		return (
			<WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@y61081`} datas={this.getDropMenuDatas()} onClick={ key => this.handleMenuClick(key)}>
				<WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@6h9a2s`} 
				 	comsWeaTableStore={tableStore}
				 	hasOrder={true}
				 	needScroll={true}
				/>
			</WeaRightMenu>
		)

	}
}