import React, { PureComponent } from 'react';
import { config } from './config';
import s from './Column.less';
import { ColumnProps } from './interface';
import IconFont from './base/extra/iconFont';

export default class TableColumn extends PureComponent<ColumnProps> {

    render() {
        let { type, title, width = 200, columnAttrObj = {} } = this.props;
        let icon = config[String(type)] && config[String(type)].icon;
        if (String(type) === '13' && !columnAttrObj.isMultiple) {
            icon = 'iconziduan-lianxiangdanxuan';
        }
        return (
            <div className={s.colContainer} style={{ width }}>
                <div className={s.colBrief}>
                    {icon && (typeof icon === 'string' ? <IconFont className={s.colIcon} type={icon} /> : icon)}
                    <span className={s.colTitle}>{title}</span>
                </div>
            </div>
        );
    }
}
