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;
    rowStyle?: Object | Function;
    rowRenderer?: Function;
    bordered?: boolean;
    height?: number;
    width?: number;
    emitChangeCell?: Function;
    sortConfig?: any;
    paginationConfig?: any;
    showIndex?: boolean;
    emptyPlaceholder?: string;
    cellEditable?: boolean;
    rowHeight?: number;
    headerHeight?: number;
    columnWidth?: number;
    loading?: boolean;
    rowSelection?: any;
    noDataPlaceholder?: any;
    contentMenu?: any;
    loadComp?: any;
}
export interface TableState {
    columns: ColumnProps[];
    dataSource: RowProps[];
    tableHeight?: number;
    tableWidth?: number;
    selectedCell?: any;
    showWidthHandle: boolean;
    widthHandleLeft: number;
}
export interface CommonProps extends TableProps {
    operateConfig?: OperateConfigProps;
    tableOperateConfig?: OperateConfigProps;
    paginationConfig?: any;
    locale?: any;
}

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;
    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;
}
