import { observer } from 'mobx-react';
import React, {Component} from 'react';
import { WeaAuth, WeaLocaleProvider } from 'ecCom';
import classnames from 'classnames';
import {WeaTableNew} from 'comsMobx';
const getLabel = WeaLocaleProvider.getLabel;

const {WeaTable} = WeaTableNew;

const classes = classnames({
    ['tabPane']: true,
    ['tabPane-dialog']: true
});

@observer
export default class ConditionSetting extends Component{
    onOperatesClick = (record, index, operate, tableName) => {
		const func = operate.href ? operate.href.split(':')[1].split('(')[0] : '';
		func === 'doDelete' && this.doDelete(record);
    }

    doDelete = record => {
        const {store: {deleteCondition}} = this.props;
        deleteCondition(record.id);
    }

    render(){
        const {store} = this.props;
        const {conditionList, mSettingDialogHeight, conditionSettingForm} = store;

		const tableProps = {
			scroll: {
				y: mSettingDialogHeight - 140
			}
        }

        return (
            <div className={classes}>
                <WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@rwi3ea`}
                    comsWeaTableStore={conditionList}
                    hasOrder={true}
                    needScroll={true}
                    uniqueId={true}
                    {...tableProps}
                    // getColumns={cols => this.renderCol(cols)}
                    onOperatesClick={(record, index, operate) => this.onOperatesClick(record, index, operate)}
                />
                {
                    conditionSettingForm.visible && <WeaAuth ecId={`${this && this.props && this.props.ecId || ''}_WeaAuth@4hp40l`} {...conditionSettingForm} title={getLabel('510223','添加可维护条件')} />
                }
            </div>
        )
    }
}