import _defineProperty from 'babel-runtime/helpers/defineProperty';
import _extends from 'babel-runtime/helpers/extends';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _createClass from 'babel-runtime/helpers/createClass';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
var _jsxFileName = 'src/table/Table.jsx';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import merge from '../util/merge';
import ItemTable from './ItemTable';
import pubsub from '../util/observer';
import { isObject } from '../util/isType';
import measureScrollbar from '../util/measureScrollbar';
import Loading from '../loading';
import Pagination from '../pagination';
import Icon from '../icon';
import listenCssRender from '../util/listenCssRender';
import debounce from 'lodash.debounce';
import getByteLen from '../util/getByteLen';

var Table = function (_PureComponent) {
    _inherits(Table, _PureComponent);

    /***
     *  params:
     *  columns: 表格设定。
     *  title: string类型，标题，非可选
     *  key: string类型，键值，非可选
     *  style: object类型，样式，可选
     *  render: func类型，渲染自定义html，可选
     *  dataSource: array类型，表格渲染的数据，可选。
     *  onClickTh: 函数类型，点击标题触发的回调函数。
     *  loading: bool类型，当图表未加载到数据时候使用，显示正在加载数据状态。
     *  filterData: array类型，表单过滤，可选。
     *  selectSort: array类型，表单排序，可选。
     *  checkboxCallback: func类型，表单选择回调函数，参数：selectDatas, array类型，选择的行数据。
     *  allBorder: bool类型，是否显示全边框，true为显示，false为只显示下边框，可选，默认为false
     *  stripe: bool类型，是否显示条纹表格，true为显示，false为不显示，可选，默认为不显示。
     * */
    function Table(props, context) {
        _classCallCheck(this, Table);

        var _this = _possibleConstructorReturn(this, (Table.__proto__ || Object.getPrototypeOf(Table)).call(this, props, context));

        _initialiseProps.call(_this);

        _this.initFixedColumns = _this.initFixedColumns.bind(_this);
        _this.pubsubEventString = {
            token: new Date().getTime()
        };
        var _this$props = _this.props,
            columns = _this$props.columns,
            expandOpt = _this$props.expandOpt;

        var dataSource = _this.expandColumnsFunc(expandOpt, _this.props.dataSource);
        columns.forEach(function (item) {
            var width = void 0;
            if (!item.width) {
                width = 16 * getByteLen(item.title) * 2;
                if (item.sort) {
                    width += 25;
                }
                if (item.filters) {
                    width += 25;
                }
                item.width = width;
            }
        });
        _this.state = {
            tableConatinerWidth: '100%',
            tdWidthArray: {},
            rowHeightArray: {},
            dataSource: dataSource
        };
        return _this;
    }

    _createClass(Table, [{
        key: 'componentDidMount',
        value: function componentDidMount() {
            var _this2 = this;

            /**
             * 监听scroll滚动事件，判断存在固定栏的表格的滚动位置 todo
             * */
            var _props = this.props,
                leftFixed = _props.leftFixed,
                rightFixed = _props.rightFixed,
                prefixCls = _props.prefixCls;

            var leftClassName = '';
            var rightClassName = '';
            var leftShadowBorder = prefixCls + '-left-fixed-shadow-border';
            var rightShadowBorder = prefixCls + '-right-fixed-shadow-border';
            if (leftFixed || rightFixed) {
                this.innerTable.addEventListener('scroll', function (event) {
                    var targetNode = event.target;
                    var targetScroll = targetNode.getBoundingClientRect().width - 2 + targetNode.scrollLeft;
                    var leftCls = _this2.leftTableItem ? _this2.leftTableItem.className : '';
                    var rightCls = _this2.rightTableItem ? _this2.rightTableItem.className : '';
                    if (targetNode.scrollLeft === 0) {
                        leftClassName = leftCls.match(leftShadowBorder) ? leftCls.split(' ' + leftShadowBorder)[0] : leftCls;
                        rightClassName = rightCls.match(rightShadowBorder) ? rightCls : rightCls + (' ' + rightShadowBorder);
                    } else if (targetScroll + 10 >= _this2.getScrollTableWidth()) {
                        leftClassName = leftCls.match(leftShadowBorder) ? leftCls : leftCls + (' ' + leftShadowBorder);
                        rightClassName = rightCls.match(rightShadowBorder) ? rightCls.split(' ' + rightShadowBorder)[0] : rightCls;
                    } else {
                        leftClassName = leftCls.match(leftShadowBorder) ? leftCls : leftCls + (' ' + leftShadowBorder);
                        rightClassName = rightCls.match(rightShadowBorder) ? rightCls : rightCls + (' ' + rightShadowBorder);
                    }
                    if (_this2.leftTableItem) {
                        _this2.leftTableItem.className = leftClassName;
                    }
                    if (_this2.rightTableItem) {
                        _this2.rightTableItem.className = rightClassName;
                    }
                }, false);
            }
            var initInnerTableWidth = function initInnerTableWidth() {
                var _innerTable$getBoundi = _this2.innerTable.getBoundingClientRect(),
                    width = _innerTable$getBoundi.width;

                _this2.setState({
                    tableConatinerWidth: width
                });
            };
            listenCssRender(initInnerTableWidth);
            listenCssRender(this.handleResizeEvent);
            window.addEventListener('resize', this.handleResizeEvent, false);
        }
    }, {
        key: 'componentWillReceiveProps',
        value: function componentWillReceiveProps(nextProps) {
            var _props2 = this.props,
                dataSource = _props2.dataSource,
                stripe = _props2.stripe,
                allBorder = _props2.allBorder,
                warpBorder = _props2.warpBorder,
                expandOpt = _props2.expandOpt;

            var reRenderWidthHeight = false;
            if (dataSource !== nextProps.dataSource) {
                var _dataSource = this.expandColumnsFunc(expandOpt, nextProps.dataSource);
                this.setState({
                    dataSource: _dataSource
                });
                this.initFixedColumns();
                reRenderWidthHeight = true;
            }
            if (stripe !== nextProps.stripe || allBorder !== nextProps.allBorder || warpBorder !== nextProps.warpBorder) {
                reRenderWidthHeight = true;
            }
            if (reRenderWidthHeight) {
                listenCssRender(this.initItemTableWidthHeight);
            }
        }
    }, {
        key: 'componentWillUnmount',
        value: function componentWillUnmount() {
            window.removeEventListener('resize', this.handleResizeEvent, false);
        }

        /**
         * 得到当前鼠标所在位置的表格类型
         * **/


        /**
         * 扩展栏
         * **/

        /**
         * 初始化三类表格
         * */

    }, {
        key: 'render',
        value: function render() {
            var _this3 = this;

            var _props3 = this.props,
                onClickTh = _props3.onClickTh,
                styles = _props3.styles,
                className = _props3.className,
                allBorder = _props3.allBorder,
                stripe = _props3.stripe,
                textCenter = _props3.textCenter,
                rowHeight = _props3.rowHeight,
                prefixCls = _props3.prefixCls,
                checkboxCallback = _props3.checkboxCallback,
                checkbox = _props3.checkbox,
                expandOpt = _props3.expandOpt,
                width = _props3.width,
                hideTableTitle = _props3.hideTableTitle,
                leftFixed = _props3.leftFixed,
                rightFixed = _props3.rightFixed,
                onSort = _props3.onSort,
                warpBorder = _props3.warpBorder,
                pagination = _props3.pagination,
                scroll = _props3.scroll,
                loading = _props3.loading,
                isHover = _props3.isHover,
                loadingCls = _props3.loadingCls,
                scrollBarWidth = _props3.scrollBarWidth,
                noDataRender = _props3.noDataRender;
            var _state = this.state,
                tableConatinerWidth = _state.tableConatinerWidth,
                scrollPosition = _state.scrollPosition,
                scrollTop = _state.scrollTop,
                rowHeightArray = _state.rowHeightArray,
                tdWidthArray = _state.tdWidthArray,
                baseHeaderHeight = _state.baseHeaderHeight;

            var containerCN = prefixCls + ' ' + className;
            /**
             * 是否具有区分背景
             * */
            if (stripe) {
                containerCN += ' stripe';
            } else {
                containerCN += ' ' + prefixCls + '-border-row';
            }

            /**
             * border样式
             * */
            if (warpBorder) {
                containerCN += ' ' + prefixCls + '-warp-border';
            }

            if (!warpBorder && allBorder) {
                containerCN += ' ' + prefixCls + '-all-border';
            }
            if (textCenter) {
                containerCN += ' text-center';
            }

            var _initFixedColumns = this.initFixedColumns(),
                leftFixedProps = _initFixedColumns.leftFixedProps,
                rightFixedProps = _initFixedColumns.rightFixedProps,
                mainProps = _initFixedColumns.mainProps;

            var leftStyles = _extends({}, styles, { width: leftFixedProps.width });
            var rightStyles = _extends({}, styles, { width: rightFixedProps.width });
            var tableInnerWidth = this.getScrollTableWidth();
            var shouldScroll = tableConatinerWidth < tableInnerWidth;
            var warpWidth = null;
            var finalWidth = tableConatinerWidth;
            if (shouldScroll) {
                warpWidth = scrollBarWidth ? tableConatinerWidth - scrollBarWidth : null;
                finalWidth = tableInnerWidth;
            }
            var mainTableProps = {
                isHover: isHover,
                scroll: scroll,
                onSort: onSort,
                leftFixed: leftFixed,
                rightFixed: rightFixed,
                onClickTh: onClickTh,
                textCenter: textCenter,
                rowHeight: rowHeight,
                prefixCls: prefixCls,
                checkbox: checkbox,
                checkboxCallback: checkboxCallback,
                expandOpt: expandOpt,
                hideTableTitle: hideTableTitle,
                stripe: stripe,
                baseHeaderHeight: baseHeaderHeight,
                shouldScroll: shouldScroll,
                scrollTop: scrollTop,
                scrollBarWidth: scrollBarWidth,
                rowHeightArray: rowHeightArray,
                tdWidthArray: tdWidthArray,
                warpBorder: warpBorder,
                allBorder: allBorder,
                activeMouse: this.activeMouse,
                columns: mainProps.columns,
                dataSource: mainProps.dataSource,
                handlePassScrollPosition: this.handlePassScrollPosition,
                handleBodyScrollVertical: this.handleBodyScrollVertical,
                theadRef: function theadRef(el) {
                    _this3.mainThead = el;
                },
                tbodyRef: function tbodyRef(el) {
                    _this3.mainTbody = el;
                },
                tableRef: function tableRef(el) {
                    _this3.mainTableItem = el;
                },
                pubsubEventString: this.pubsubEventString,
                handleInnerScrollEvent: function handleInnerScrollEvent(elm) {
                    return _this3.innerTable = elm;
                },
                noDataRender: noDataRender,
                styles: styles,
                warpWidth: warpWidth,
                position: 'main',
                width: finalWidth
            };

            var leftTableProps = {
                isHover: isHover,
                scroll: scroll,
                onSort: onSort,
                leftFixed: leftFixed,
                rightFixed: rightFixed,
                onClickTh: onClickTh,
                textCenter: textCenter,
                rowHeight: rowHeight,
                prefixCls: prefixCls,
                checkbox: checkbox,
                checkboxCallback: checkboxCallback,
                expandOpt: expandOpt,
                hideTableTitle: hideTableTitle,
                stripe: stripe,
                baseHeaderHeight: baseHeaderHeight,
                shouldScroll: shouldScroll,
                scrollTop: scrollTop,
                scrollBarWidth: scrollBarWidth,
                rowHeightArray: rowHeightArray,
                tdWidthArray: tdWidthArray,
                warpBorder: warpBorder,
                allBorder: allBorder,
                activeMouse: this.activeMouse,
                columns: leftFixedProps.columns,
                dataSource: leftFixedProps.dataSource,
                handlePassScrollPosition: this.handlePassScrollPosition,
                handleBodyScrollVertical: this.handleBodyScrollVertical,
                theadRef: function theadRef(el) {
                    _this3.leftFixColumnThead = el;
                },
                tbodyRef: function tbodyRef(el) {
                    _this3.leftFixColumnTbody = el;
                },
                tableRef: function tableRef(el) {
                    _this3.leftTableItem = el;
                },
                pubsubEventString: this.pubsubEventString,
                mainTbody: this.mainTbody,
                columnsId: leftFixedProps.columnsId,
                position: leftFixedProps.position,
                styles: leftStyles,
                scrollPosition: scrollPosition
            };

            var rightTableProps = {
                isHover: isHover,
                scroll: scroll,
                onSort: onSort,
                position: rightFixedProps.position,
                dataSource: rightFixedProps.dataSource,
                columns: rightFixedProps.columns,
                columnsId: rightFixedProps.columnsId,
                leftFixed: leftFixed,
                rightFixed: rightFixed,
                onClickTh: onClickTh,
                styles: rightStyles,
                textCenter: textCenter,
                rowHeight: rowHeight,
                prefixCls: prefixCls,
                hideTableTitle: hideTableTitle,
                stripe: stripe,
                width: width,
                scrollPosition: scrollPosition,
                shouldScroll: shouldScroll,
                scrollTop: scrollTop,
                scrollBarWidth: scrollBarWidth,
                baseHeaderHeight: baseHeaderHeight,
                expandOpt: expandOpt,
                rowHeightArray: rowHeightArray,
                tdWidthArray: tdWidthArray,
                warpBorder: warpBorder,
                allBorder: allBorder,
                activeMouse: this.activeMouse,
                theadRef: function theadRef(el) {
                    _this3.rightFixColumnThead = el;
                },
                tbodyRef: function tbodyRef(el) {
                    _this3.rightFixColumnTbody = el;
                },
                tableRef: function tableRef(el) {
                    _this3.rightTableItem = el;
                },
                handlePassScrollPosition: this.handlePassScrollPosition,
                handleBodyScrollVertical: this.handleBodyScrollVertical,
                pubsubEventString: this.pubsubEventString,
                mainTbody: this.mainTbody
            };
            return React.createElement(
                Loading,
                { show: loading, className: loadingCls, __source: {
                        fileName: _jsxFileName,
                        lineNumber: 669
                    },
                    __self: this
                },
                React.createElement(
                    'div',
                    { className: containerCN, style: { width: width || scroll.x }, ref: function ref(table) {
                            return _this3.neTable = table;
                        }, __source: {
                            fileName: _jsxFileName,
                            lineNumber: 670
                        },
                        __self: this
                    },
                    React.createElement(ItemTable, Object.assign({}, mainTableProps, {
                        __source: {
                            fileName: _jsxFileName,
                            lineNumber: 671
                        },
                        __self: this
                    })),
                    leftFixed && React.createElement(ItemTable, Object.assign({}, leftTableProps, {
                        __source: {
                            fileName: _jsxFileName,
                            lineNumber: 672
                        },
                        __self: this
                    })),
                    rightFixed && React.createElement(ItemTable, Object.assign({}, rightTableProps, {
                        __source: {
                            fileName: _jsxFileName,
                            lineNumber: 673
                        },
                        __self: this
                    }))
                ),
                isObject(pagination) ? React.createElement(
                    'div',
                    { className: prefixCls + '-pagination', __source: {
                            fileName: _jsxFileName,
                            lineNumber: 676
                        },
                        __self: this
                    },
                    React.createElement(Pagination, Object.assign({ isCompact: true }, pagination, {
                        __source: {
                            fileName: _jsxFileName,
                            lineNumber: 677
                        },
                        __self: this
                    }))
                ) : null
            );
        }
    }]);

    return Table;
}(PureComponent);

Table.propTypes = {
    /**
     * 加载数据的时候是否显示loading
     * */
    loading: PropTypes.bool,
    /**
     * 表格列设定
     * */
    columns: PropTypes.array,
    /**
     * 普通表格数据源，
     * */
    dataSource: PropTypes.array,
    /**
     * 点击标题回调函数，
     * */
    onClickTh: PropTypes.func,
    /**
     * 自定义类名
     * */
    className: PropTypes.string,
    /**
     * 表格的高度，不设定则为自定义
     * */
    rowHeight: PropTypes.string,
    /**
     * 文字内容是否居中
     * */
    textCenter: PropTypes.bool,
    /**
     * 是否显示选择框
     * */
    checkbox: PropTypes.bool,
    /**
     * 触发选择框的回调函数
     * */
    checkboxCallback: PropTypes.func,
    /**
     * 表格边框设置
     * */
    allBorder: PropTypes.bool,
    /**
     * 表格斑马线设置
     * */
    stripe: PropTypes.bool,
    /**
     * 是否设定hover
     * */
    // isHover: PropTypes.oneOfType([PropTypes.object, PropTypes.bool]),
    /**
     * 表格左侧固定栏
     * */
    leftFixed: PropTypes.bool,
    /**
     * 表格右侧固定栏
     * */
    rightFixed: PropTypes.bool,
    /**
     * 是否隐藏表头
     * */
    hideTableTitle: PropTypes.bool,
    /**
     * 自定义样式设定
     * */
    styles: PropTypes.object,
    /**
     * 类名前缀设定
     * */
    prefixCls: PropTypes.string,
    /**
     * 最外层loading层类名设定
     * */
    loadingCls: PropTypes.string,
    /**
     * 显示分页，参数同 Pagination 组件
     * 传 false 不显示分页
     * */
    pagination: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
    /**
     * 排序回调函数
     * */
    onSort: PropTypes.func,

    /**
     * 排序回调函数
     * */
    warpBorder: PropTypes.bool,
    /**
     * 表头固定和列固定滚动距离
     * */
    scroll: PropTypes.object,
    /**
     * 展开栏的配置项
     * expandOpt = {
     *      display: true,
     *      icon: <Icon type="xx" />,
     *      render: (data) => {
     *          // data 为当前行数据
     *          return (
     *              <div>展开栏目</div>
     *          )
     *      }
     * }
     * */
    expandOpt: PropTypes.object,
    /**
     * 当表格为空的时候渲染的函数
     * */
    noDataRender: PropTypes.oneOfType([PropTypes.func, PropTypes.string, PropTypes.element]),
    /**
     * 设置表格的宽度
     * */
    width: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
};
Table.defaultProps = {
    onClickTh: function onClickTh() {},
    // width: '100%',
    className: '',
    checkbox: false,
    checkboxCallback: function checkboxCallback(selectDatas) {
        return console.log(selectDatas);
    },
    allBorder: false,
    stripe: false,
    textCenter: false,
    styles: {},
    prefixCls: 'ne-table',
    leftFixed: false,
    rightFixed: false,
    columns: [],
    dataSource: [],
    hideTableTitle: false,
    loading: false,
    pagination: false,
    scroll: {},
    scrollBarWidth: measureScrollbar(),
    noDataRender: '暂无数据'
};

var _initialiseProps = function _initialiseProps() {
    var _this4 = this;

    this.activeMouse = function (position) {
        _this4.activeMouseType = position;
    };

    this.expandColumnsFunc = function (expandOpt, dataSource) {
        console.log(!!expandOpt);
        if (!!expandOpt) {
            return dataSource.map(function (item, index) {
                var dataSourceItem = _extends({}, item);
                if (item._tableExpandRow) {
                    dataSourceItem._tableExpandRow = '展开栏字段与保留字段_tableExpandRow相冲突，请重新定义该字段';
                } else {
                    dataSourceItem._tableExpandRow = function () {
                        return expandOpt.render(item, index);
                    };
                }
                return dataSourceItem;
            });
        } else {
            return dataSource;
        }
    };

    this.initItemTableWidthHeight = function () {
        var _props4 = _this4.props,
            leftFixed = _props4.leftFixed,
            rightFixed = _props4.rightFixed;

        if (leftFixed || rightFixed) {
            var tdWidthArray = {};
            var rowHeightArray = {};
            var getElementChildrenArray = function getElementChildrenArray(elm, tag) {
                return [].slice.call(elm.getElementsByTagName(tag));
            };
            var tbodyChildren = getElementChildrenArray(_this4.mainTbody, 'tr');
            var theadChildren = getElementChildrenArray(_this4.mainThead, 'th');
            var leftTbodyChildren = void 0;
            var leftTheadChildren = void 0;
            var rightTbodyChildren = void 0;
            var rightTheadChildren = void 0;
            if (leftFixed) {
                leftTbodyChildren = getElementChildrenArray(_this4.leftFixColumnTbody, 'tr');
                leftTheadChildren = getElementChildrenArray(_this4.leftFixColumnThead, 'th');
            }
            if (rightFixed) {
                rightTbodyChildren = getElementChildrenArray(_this4.rightFixColumnTbody, 'tr');
                rightTheadChildren = getElementChildrenArray(_this4.rightFixColumnThead, 'th');
            }

            // 设置均等高度
            tbodyChildren.forEach(function (item, id) {
                var _item$getBoundingClie = item.getBoundingClientRect(),
                    height = _item$getBoundingClie.height;

                rowHeightArray[id] = height;
                if (leftFixed && leftTbodyChildren[id]) {
                    leftTbodyChildren[id].style.height = height + 'px';
                }
                if (rightFixed && rightTbodyChildren[id]) {
                    rightTbodyChildren[id].style.height = height + 'px';
                }
            });
            // 设置均等宽度
            theadChildren.forEach(function (item, id) {
                var _item$getBoundingClie2 = item.getBoundingClientRect(),
                    width = _item$getBoundingClie2.width;

                tdWidthArray[id] = width;
                if (leftFixed && leftTheadChildren[id]) {
                    leftTheadChildren[id].style.width = width;
                }
                if (rightFixed && rightTheadChildren[id]) {
                    rightTheadChildren[id].style.width = width;
                }
            });
            listenCssRender(_this4.setState({
                baseHeaderHeight: _this4.mainThead.getBoundingClientRect().height
            }));
            _this4.setState({
                tdWidthArray: tdWidthArray,
                rowHeightArray: rowHeightArray
            });
        }
    };

    this.handleResizeEvent = debounce(function () {
        _this4.initItemTableWidthHeight();
        if (_this4.innerTable) {
            pubsub.publish('handleResizeEvent');

            var _innerTable$getBoundi2 = _this4.innerTable.getBoundingClientRect(),
                width = _innerTable$getBoundi2.width;

            _this4.setState({
                tableConatinerWidth: width
            });
        }
    }, 300);

    this.initFixedColumns = function () {
        var _props5 = _this4.props,
            columns = _props5.columns,
            leftFixed = _props5.leftFixed,
            rightFixed = _props5.rightFixed,
            checkbox = _props5.checkbox,
            expandOpt = _props5.expandOpt;
        var dataSource = _this4.state.dataSource;

        var fixedProps = function fixedProps(position) {
            return {
                position: position,
                columns: [],
                dataSource: [],
                width: '0px',
                columnsId: []
            };
        };
        var leftFixedProps = fixedProps('left');
        var rightFixedProps = fixedProps('right');
        var mainProps = {
            columns: merge(columns),
            dataSource: merge(dataSource)
        };
        /**
         * 初始化左侧固定栏和右侧固定栏
         * */
        var initFixedProps = function initFixedProps(itemColumns, id) {
            var type = itemColumns.fixed;
            var renderItemData = function renderItemData(originalData) {
                var columnId = id;
                mainProps.columns[id].title = '';
                originalData.columns.push(itemColumns);
                originalData.width = parseInt(originalData.width.replace('px', ''), 10) + itemColumns.width + 'px';
                mainProps.dataSource.forEach(function (itemData, index) {
                    originalData.dataSource[index] = originalData.dataSource[index] || {};
                    if (expandOpt) {
                        originalData.dataSource[index]._tableExpandRow = dataSource[index]._tableExpandRow;
                    }
                    Object.assign(originalData.dataSource[index], _defineProperty({}, itemColumns.key, itemData[itemColumns.key]));
                });
                if (checkbox) {
                    columnId += 1;
                }
                if (expandOpt && expandOpt.display) {
                    columnId += 1;
                }
                originalData.columnsId.push(columnId);
            };
            if (type === 'left' && leftFixed) {
                renderItemData(leftFixedProps);
            } else if (type === 'right' && rightFixed) {
                renderItemData(rightFixedProps);
            }
        };
        columns.forEach(function (item, index) {
            initFixedProps(item, index);
        });
        return { leftFixedProps: leftFixedProps, rightFixedProps: rightFixedProps, mainProps: mainProps };
    };

    this.getScrollTableWidth = function () {
        var _props6 = _this4.props,
            columns = _props6.columns,
            checkbox = _props6.checkbox,
            expandOpt = _props6.expandOpt;

        var tableInnerWidth = 0;
        columns.forEach(function (item) {
            tableInnerWidth += item.width;
        });
        if (checkbox) {
            tableInnerWidth += 50;
        }
        if (expandOpt && expandOpt.display) {
            tableInnerWidth += 50;
        }
        return tableInnerWidth;
    };

    this.handlePassScrollPosition = function (scrollTop) {
        _this4.setState({
            scrollTop: scrollTop
        });
    };

    this.handleBodyScrollVertical = function (elm, type) {
        var _props7 = _this4.props,
            leftFixed = _props7.leftFixed,
            rightFixed = _props7.rightFixed;

        var target = elm.target;
        var scrollTop = target.scrollTop;

        if (_this4.activeMouseType === type) {
            if (type !== 'main') {
                _this4.mainTbody.scrollTop = scrollTop;
            }
            if (leftFixed && type !== 'left') {
                _this4.leftFixColumnTbody.scrollTop = scrollTop;
            }
            if (rightFixed && type !== 'right') {
                _this4.rightFixColumnTbody.scrollTop = scrollTop;
            }
        }
    };
};

export default Table;