import {
    inject,
    observer
} from 'mobx-react'
import {
    WeaTableNew
} from 'comsMobx'
import { //TODO
    WeaPopoverHrm
} from 'ecCom';
const WeaTable = WeaTableNew.WeaTable;

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

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

    reRenderColumns = (columns) => {
        const {
            hrmRecruitPlan
        } = this.props, {
            openDialog,
        } = hrmRecruitPlan;

        columns.map(c => {
            if (c.dataIndex == 'topic') {
                c.render = (t, r) => {
                    const {
                        randomFieldId,
                        startdatespan,
                        topicspan,
                    } = r;

                    return <a onClick={() => openDialog('0',randomFieldId,startdatespan)}>{topicspan}</a>
                }
            }
        })
    }

    render() {
        const {
            hrmRecruitPlan,
        } = this.props, {
            mainTable,
            onOperatesClick,
        } = hrmRecruitPlan, {
            tableStore
        } = mainTable;

        return (
            <WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@ch0a8o`} 
                comsWeaTableStore={tableStore}
                hasOrder={true}
                needScroll={true}
                // getColumns={columns => this.reRenderColumns(columns)}
                onOperatesClick={(record, rowIndex, operate) => onOperatesClick(record, rowIndex, operate)}
            />
        )

    }
}