import React, {
	Component
} from 'react';
import {
	observer
} from 'mobx-react';
import {
	WeaRightMenu,
	WeaDialog
} from 'ecCom';
import {
	WeaTableNew
} from 'comsMobx';
const WeaTable = WeaTableNew.WeaTable;

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

	componentDidMount() {}

	componentWillReceiveProps(nextProps) {}

	openDialog = (id) => {
		const {
			store
		} = this.props;
		store.create(false, {
			id
		});
	}

	doDel = (id) => {
		const {
			store
		} = this.props;
		store.remove({
			ids: id
		});
	}

	onOperatesClick = (record, index, operate) => {
		const func = operate.href ? operate.href.split(':')[1].split('(')[0] : '';
		const id = record.id ? record.id : '';
		this[func] && this[func](id);
	}

	render() {
		const {
			store,
			rightMenu
		} = this.props;
		const {
			table,
			dialogParams,
			getDialogOpButtons
		} = store;
		const dProps = {
			...dialogParams,
			buttons: getDialogOpButtons()
		}
		return (
			<div className='tabPane tabPane-include'>
				<WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@ohsjes`} datas={rightMenu}>
					<WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@cdsnnw`} comsWeaTableStore={table} hasOrder={true}
	                    onOperatesClick={(record, index, operate) => this.onOperatesClick(record, index, operate)}/>
                </WeaRightMenu>
                <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@001g91`} {...dProps}>
                {dProps.coms}
                </WeaDialog>
			</div>
		)
	}
}