import {
    WeaDialog,
    WeaFormItem,
    WeaNewScroll,
    WeaSearchGroup,
    WeaMoreButton,
    WeaTable
} from 'ecCom'

import {
    Spin,
    Button,
} from 'antd'

import {
    WeaSwitch
} from 'comsMobx'

import {
    i18n
} from '../public/i18n';

export default class NewTableDialog extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            width: 800,
        }
    }



    render() {
        const {
            title,
            visible,
            onCancel,
            loading,
            height,
            dataSource,
            columns
        } = this.props, {
            width,
        } = this.state;

        const pagination = {
            total: dataSource.length,
            showSizeChanger: true,
            showQuickJumper: true,
            onShowSizeChange(current, pageSize) {
            },
            onChange(current) {
            },
            showTotal(total) {
                return `共 ${total} 条`
            }
        };

        const buttons = [
            //(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@jd6baw`} type="primary" onClick={() => save()} disabled={loading}>{i18n.button.save()}</Button>),
            (<WeaMoreButton ecId={`${this && this.props && this.props.ecId || ''}_WeaMoreButton@e4f4n1`} />)
        ];

        return (
            <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@1txk5f`}
                title={title}
                icon="icon-coms-hrm"
                iconBgcolor="#217346"
                visible={visible}
                closable={true}
                hasScroll={true}
                onCancel={() => onCancel()}
                buttons={buttons}
                style={{ width: width, height: height }}
            >
                {
                    loading ? <div className='hrm-loading-center-small'>
                        <Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@4ygl4a`} spinning={loading}></Spin>
                    </div> : <WeaTable rowKey={record => record.id}
                        dataSource={dataSource} childrenColumnName="children"
                        columns={columns}
                        loading={loading}
                        pagination={pagination}
                        indentSize={15}
                    />
                }

            </WeaDialog>
        )
    }
}