import '../../style/matrixDataMaintenance.less';
import React, {
	Component
} from 'react';
import {
	inject,
	observer
} from 'mobx-react';
import {
	WeaRightMenu,
	WeaTableEdit,
	WeaDialog,
} from 'ecCom';
import {
	WeaTableNew
} from 'comsMobx';
import {
	Pagination,
	Spin
} from 'antd';
import Tabs from '../../coms/Tabs';
import ImportResource from '../importresource/Import';
import {
	i18n
} from '../../public/i18n';
import * as mobx from 'mobx';
import {
	getColumIndex
} from '../../util/index';
import DataList from './DataList';
import HiddenTable from './HiddenTable';

const {
	toJS
} = mobx;
const {
	WeaTable
} = WeaTableNew;

@inject("hrmMatrixDataMaintenance")
@inject('hrmImportResource')
@observer
export default class MatrixDataMaintenance extends Component {
	constructor(props) {
		super(props);
	}

	componentDidMount() {
		const {
			hrmMatrixDataMaintenance: store,
			hrmImportResource,
			matrix,
			rootStore
		} = this.props;
		store.setRootStore(rootStore);
		store.setImportStore(hrmImportResource)
		rootStore.dialogParams.visible && store.initData(matrix);
	}

	componentWillReceiveProps(nextProps) {
		const {
			hrmMatrixDataMaintenance: store,
			hrmImportResource,
			matrix,
			rootStore
		} = nextProps;
		store.setRootStore(rootStore);
		store.setImportStore(hrmImportResource)
		rootStore.dialogParams.visible && store.initData(matrix);
	}

	render() {
		const {
			hrmMatrixDataMaintenance: store,
			rootStore
		} = this.props;
		const {
			matrixInfo,
			loading,
		} = store;
		if (matrixInfo == null) 
			return <div></div>
		return (
			<Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@leqfwu`} spinning={loading}>
				<DataList ecId={`${this && this.props && this.props.ecId || ''}_DataList@rznkj4`} store={store} rootStore={rootStore}/>
				<HiddenTable ecId={`${this && this.props && this.props.ecId || ''}_HiddenTable@h1t897`} store={store} />
			</Spin>
		);
	}
}