import React from 'react';

// 列配置
export interface ColumnProps {
    columnType: string;
    columnChsName: string;
    columnName: string;
    width?: number;
    columnAttrObj?: any;
    sortFlag?: boolean;
    sortConfig?: any;
    isMobile?: boolean;
    columnIndex?: number;
    showIndex?: boolean;
    questionText?: string;
    [propName: string]: any;
}
// 单元格基本数据格式
export interface CellDataProps {
    text: string;
    value: any;
    extraData?: any;
    readonlyFlag?: boolean;
}
// 行数据格式
export interface RowDataProps {
    colChsName: string;
    colName: string;
    cellValueList: CellDataProps[];
    dynamicCellConfigDTO?: any;
    linkObjRowDateList?: any;
}
// 行记录格式
export interface RowProps {
    id: number;
    rowData: RowDataProps[];
    [propName: string]: any;
}

export interface OperateConfigProps {
    menusGroup?: Object[];
    buttonsGroup?: Object[];
    moreGroup?: Object[];
    renderCustomNode?: Function;
}

export interface LoadConfigProps {
    onScroll?: Function;
    distanceToLoad?: number;
}

export interface TableProps extends LoadConfigProps {
    columns: ColumnProps[];// 列配置
    dataSource: RowProps[];// 数据源
    rowClassName?: string | Function;// 行class
    rowStyle?: Object | Function;// 行style
    rowRenderer?: Function;
    bordered?: boolean;// 是否显示边框
    height?: number;// 表格高度
    width?: number;// 表格宽度
    emitChangeCell?: Function;// 单元格修改回调
    sortConfig?: any;
    paginationConfig?: any;// 分页配置
    showIndex?: boolean;// 是否显示序号
    showExpand?: any;// 是否显示展开详情图标
    emptyPlaceholder?: string;// 数据为空时默认显示
    cellEditable?: boolean;// 单元格是否可编辑
    rowHeight?: number;// 初始化行高
    headerHeight?: number;// 初始化表头高度
    columnWidth?: number;// 初始化单元格宽度
    loading?: boolean;// 是否加载中
    rowSelection?: any;// 复选配置
    noDataPlaceholder?: any;// 无数据时显示文案
    contentMenu?: any;// 右键菜单
    loadComp?: any;// 加载动画组件
    canFixed?: boolean;// 是否可以拖拽自定义固定列
    canSorted?: boolean;// 是否可以拖拽自定义列排序
    canResized?: boolean;// 是否可以拖拽自定义列伸缩
    onDragSorted?:Function;// 拖拽更改列排序回调
}
export interface TableState {
    columns: ColumnProps[];
    dataSource: RowProps[];
    tableHeight?: number;
    tableWidth?: number;
    selectedCell?: any;
}
export interface CommonProps extends TableProps {
    operateConfig?: OperateConfigProps;
    tableOperateConfig?: OperateConfigProps;
    paginationConfig?: any;
    locale?: any;
    className?: string;
    showCondition?: boolean;
    id?:string;
}

export interface CommonState extends TableState {}

export interface BaseComponentProps {
    value: CellDataProps[] | undefined;
    columnConfig: ColumnProps;
    formatter?: Function;
    onChange?: Function;
    onEmitChange?: Function;
}
export interface BaseComponentState {
    columnConfig: ColumnProps;
}
export interface CellProps {
    cellKey: string;
    rowIndex: number;
    columnIndex: number;
    columnConfig: ColumnProps;
    value: CellDataProps[];
    columnData: any;
    record: RowProps;
    columns: ColumnProps[];
    emitChangeCell?: Function;
    cellClassName?: string;
    cellStyle?: any;
    hasFixed?: boolean;
    paginationConfig?: any;
    showIndex?: boolean;
    showExpand?: any;
    emptyPlaceholder?: string;
    cellEditable?: boolean;
    rowSelection?: any;
    contentMenu?: any;
    selectedCell?: any;
    changeSelectedCell?: Function;
    position: string;
}

export interface EditCellProps {
    columns: ColumnProps[];
    columnConfig: ColumnProps;
    rowData: RowDataProps[];
    value: CellDataProps[];
    tableId: number;
    cellData: CellDataProps[];
    rowId: number;
    component: any;
    onChange: Function;
    componentAttr?: any;
    columnObj?: any;
    record: RowProps;
}
export interface EditCellState {
    prevProps: EditCellProps;
    columnConfig: ColumnProps;
}
