// import { IFlowTabClass, IBillTabClass, ICostTabClass } from './classType';
// eslint-disable-next-line camelcase
import { IDataObjProps, IEventType } from './enum';

export interface IArea {
    Left: number;
    Right: number;
    Top: number;
    Bottom: number;
    H_CalculationType?: {
        Left: string;
        Right: string;
        Top: string;
        Bottom: string;
    };
    V_CalculationType?: {
        Left: string;
        Right: string;
        Top: string;
        Bottom: string;
    };
}
export interface IControlSubCollection {
    ID: string;
    CloseOutput: string;
    Horizon: string;
    ShowZero: string;
    Shrink: string;
    ShrinkFirst: string;
    Vertical: string;
    VerticalForExcel: string;
    Wrap: string;
}
export interface Fields {
    area: IArea;
    control: string | IControlSubCollection;
    FieldID: number;
    font: string;
    isAutoHeight: boolean;
    style: string;
    Hidden?: boolean; // 暂定
    isSerial: boolean; // 暂定
    Format: string;
    SumKey: string;
    combineType?: string;
    isMerge?: boolean;
    Default_Value?: string;
    Label: string;
    Title: string;
    [key: string]: any; // 剩下的之后补充
}

export interface IFormula {
    expression: string;
    format: string;
    Name: string;
    run_type: string;
}

export interface BorderStyle {
    Position: string;
    LineWeight: number;
    DashStyle: string;
    Color: string;
}

export interface IStyles {
    ID: string;
    CfgDispName: string;
    border_style: BorderStyle[];
    [key: string]: any; // 剩下的之后补充
}

export interface IDefProperties {
    ctrls: IControlSubCollection[];
    fonts: IFontSubCollection[];
    styles: IStyles[];
}

export interface IControlCollection {
    [key: string]: IControlSubCollection;
}
export interface IFontSubCollection {
    CfgDispName: string
    FontAngle?: string;
    FontBold?: string;
    FontColor?: string;
    FontHeight: string;
    FontItalic: string;
    FontStrikeOut?: string;
    FontUnderline: string;
    Name: string;
    ID: string;
    [key: string]: string | number | undefined
}
export interface IFontCollection {
    [key: string]: IFontSubCollection;
}

export interface IPosition {
    Bottom: number;
    Left: number;
    Right: number;
    Top: number;
}

export interface IMergePos {
    Bottom: number[];
    Left: number[];
    Right: number[];
    Top: number[];
}

interface IPositionExtentDetail {
    Color: string;
    DashStyle: string;
    LineWeight: string;
}

export interface IPositionExtent {
    Bottom: IPositionExtentDetail;
    Left: IPositionExtentDetail;
    Right: IPositionExtentDetail;
    Top: IPositionExtentDetail;
}

export interface IPageAreaObj {
    cellsArr: ICell[];
    pageCellObj: IPageCellObj;
}

export interface IPageCellObj {
    [key: string]: {
        cellIdx: number;
        cell: ICell;
    }[];
}
export interface ICell {
    font: string | IFontSubCollection;
    control: IControlSubCollection | string;
    style: string;
    Value: number | string | null;
    area: IPosition;
    isAutoHeight?: boolean;
    Format?: any;
    Prefix?: string;
    Suffix?: any;
}
export interface IStyleCollection {
    BORDER_ALL_AROUND: IPositionExtent;
    Default: IPositionExtent;
    Default_None: IPositionExtent;
    Default_Normal: IPositionExtent;
    Label_Topline: IPositionExtent;
    Label_Underline: IPositionExtent;
    [key: string]: IPositionExtent;
}

export interface IPreviewPageItem {
    page_seq: number;
    cells: ICell[];
    page_merge_border: IPosition;
    page_merge_pos: {
        纸张宽高: number[]
    }
    position?:string;
    style?:IStyles;
}


export interface IPreviewPage {
    打印页面_信息: {
        报表名称: string;
        纸张宽高: number[];
        页边距: IPosition;
    };
    control_collection: IControlCollection;
    font_collection: IFontCollection;
    items: IPreviewPageItem[];
    MergeBand: IMergeBand;
    style_collection: IStyleCollection;
    pageBreaks?: any[];
}

interface ISimpleJSONPage {
    cells: ICell[];
    page_merge_border: IPosition;
    page_seq: number;
}

export interface IGroupField {
    Name: string;
    fixedPrecisionNum: number;
    ID: number;
    DataType: string;
    DataSeq: number;
    DataNodeName: IDataObjProps;
    data_field: number | any; // 暂定
    Precision?: {
        type?: string;
        flexibleRefFieldID?: number;
    };
    flexiblePrecisionRefObj?: { [key: string]: number }[];
    [key: string]: any;
}

export interface ITargetDataSet {
    [key: string]: IGroupField;
}

export interface ITargetFields {
    从数据指标_集合: ITargetDataSet;
    主数据指标_集合: ITargetDataSet;
    主数据指标_拓展集合: ITargetDataSet;
    从数据指标_拓展集合: ITargetDataSet;
    离散指标_集合: ITargetDataSet;
    无映射离散指标_集合: ITargetDataSet;
    [key: string]: ITargetDataSet;
}

interface IOutputAsPreviewPage {
    (rptTpl: IRptTpl, defProperties: IDefProperties): IPreviewPage;
}
interface IOutputAsSimpleJSONPageArray {
    (
        rptTpl: IRptTpl,
        dataObj: IDataObj,
        startPage: number,
        endPage: number,
        defProperties: IDefProperties,
        customizeCfg: ICustomizeCfg
    ): IPreviewPage;
}
interface IOutputAsSimpleJSONPage {
    (
        rptTpl: IRptTpl,
        dataObj: IDataObj,
        bands: IBands,
        page: number,
        controls: IControlCollection,
        customizeCfg: ICustomizeCfg
    ): ISimpleJSONPage;
}

export interface IFlowTab {
    dispValueIdxLst: number[][];
    group_lines_amt: number;
    group_node_info: number[][] | null;
    group_sum_fields: Fields[] | null;
    group_sum_values: { [key: string]: number }[] | null;
    isEx: boolean;
    multiCols: number;
    groupSumValLst: any[];
    group_check_fields: any[];
    auto_height_fields_idx: any[];
    auto_height_info: any[];
    disp_fields_ex_idx: any[];
    disp_fields_idx: any[];
    outputAsPreviewPage: IOutputAsPreviewPage;
    outputAsSimpleJSONPage: IOutputAsSimpleJSONPage;
    outputAsSimpleJSONPageArray: IOutputAsSimpleJSONPageArray;
    checkCombineEvent: (
        $RUN_TYPE: string,
        $VER_COMB_ARRAY: any[],
        $HOR_COMB_ARRAY: any[],
        $CURRENT_CELL_ITEMS: Fields,
        $CURRENT_RPT: ICurrent_RPT
    ) => void;
    checkGrpTxtOutEvent: (
        $RUN_TYPE: string,
        $TEXT: Fields,
        $TIMES: number,
        $CURRENT_RPT: ICurrent_RPT
    ) => void;
    combinePageCells: (
        rstPageCells: ICell[],
        verticalCombinePos: any[],
        horizonCombinePos: any[]
    ) => void;
    commonTabRestOutput: (
        dataObj: IDataObj,
        page: number,
        segIdx: number,
        bands: IBands,
        band: IBandDetail,
        unitFactor: number,
        tab: { BandName: string; text_s?: Fields[]; text?: string },
        multiColIdx: number
    ) => Fields[];
}
export interface IParam {
    DataSeq: number;
    DataType: string;
    ID: string;
    Name: string;
    Default_Value: string;
}
export interface IParams {
    [key: string]: IParam;
}
export interface ICurrent_RPT {
    exTotalPages: number;
    formulas: IFormula[];
    isFollowMode: boolean;
    totalPages: number;
    params: IParams;
    analyzeData: (
        rptTpl: IRptTpl,
        dataObj: IDataObj,
        defProperties: IDefProperties,
        option: string,
        outputType: string
    ) => void;
    executeFormulas: (
        runType: string,
        $CURRENT_TEMPLATE: any,
        $CURRENT_DATA: any,
        $CURRENT_RPT: ICurrent_RPT
    ) => void;
    initialize?: (rptTpl: IRptTpl) => void;
    outputAsPreviewPage: IOutputAsPreviewPage;
    outputAsSimpleJSONPage: IOutputAsSimpleJSONPage;
    outputAsSimpleJSONPageArray: IOutputAsSimpleJSONPageArray;
    paging: (
        rptTpl: IRptTpl,
        dataObj: IDataObj,
        defProperties: IDefProperties,
        option: string,
        outputType: string
    ) => void;
    fields: ITargetFields;
    // flowTab: IFlowTabClass;
    // flowTabEx: IFlowTabClass;
    // billTab: IBillTabClass;
    // crossTab: ICostTabClass;
    flowTab: any;
    flowTabEx: any;
    billTab: any;
    crossTab: any;
    runTimePageData: { currentPage?: number };
    formulasObject:Record<string,any>;
}

export interface ICurrent_DATA {
    discrete_data: any[];
    detail_data_ex: any[];
    detail_data: any[];
    DecimalObj: {
        prjDecimal: any;
        unitDecimal: {
            default_decimal: number;
        };
    };
    master_data: any[];
    master_data_ex: any[];
}
export interface ICustomizeCfg {
    fillZero: boolean;
    fonts: {
        CfgDispName: string;
        FontBold: string;
        FontHeight: string;
        FontItalic: string;
        FontUnderline: string;
        ID: string;
        Name: string;
    }[];
    isNarrow: boolean;
    margins: IPosition;
    showVerticalLine: boolean;
    userID?: string
}
export interface IOrgBandDetail {
    Alignment: string;
    DisplayType: string;
    Height: string;
    MergeBorder: string;
    Name: string;
    control: string;
    style: string;
    Width?: string;
    CalculationType: string;
    normalOnly?: boolean;
    exOnly?: boolean;
    band_s?: IOrgBandDetail[]
}

export interface IBandDetail {
    Alignment: number;
    Bottom: number;
    CalculationType: number;
    control: any;
    Width: number;
    Top: number;
    style: any;
    Right: number;
    MergeBorder: string;
    Left: number;
    Height: number;
    DisplayType: number;
    Name: string;
    exOnly?: boolean;
    normalOnly?: boolean;
    band_s?: any[];
    Le?: number;
}
export interface IBands {
    [key: string]: IBandDetail; // 剩下的之后补充
}
export interface IGrpLine {
    SumKey_S: Fields[];
    text_s: any[];
    discrete_field_s: any[];
    param_s: any;
    sum_field_s: any;
}
export interface ITab {
    text?: string;
    text_s: Fields[]; // 剩下的之后补充   textNode
    离散信息?: any;
}
export interface IGrpPageInfo {
    segGrpRecStartIdx: number;
    preAddPageGrpInfo: number[];
    insertedGrpRecAmt: number;
    group_lines_amt: number;
}

//模板信息
export interface IRptTpl {
    事件_集合: {
        type: IEventType;
    }[];
    布局框_集合: IOrgBandDetail[];
    计算式_集合: IFormula[];
    离散参数_集合: IOrgGroupField[];
    账单式表_信息: {
        离散信息: IDiscrete[];
        账单式表_数据: {
            BandName: string;
            bill_field_s: Fields[]; // 暂定
            text: string;
            text_s: string[]; // 暂定
            离散信息: IDiscrete[];
        };
    };
    交叉表_信息: {
        交叉列合计: ICrossTab;
        交叉行拓展: ICrossTab;
        交叉行拓展合计: ICrossTab;
        交叉数据: ICrossTab; // 暂定
        交叉行: ICrossTab;
        交叉列: ICrossTab;
        交叉行AD_HOC: ICrossTab; // 暂定
        离散信息: IDiscrete[];
        [key: string]: any; // 暂定tabNodeName     jpc_cross_tab   line270
    };
    流水式表_信息: {
        多列显示数量: number;
        离散信息: IDiscrete[];
        流水式表_段统计信息: IDiscrete;
        流水式表_分组信息: IFlowGroup;
        流水式表_列: IDiscrete;
        流水式表_数据: IFlowData;
        流水式表_页统计信息: IDiscrete;
    };
    流水式表_拓展信息: {
        多列显示数量: number;
        流水拓展显示模式: string;
        离散信息: IDiscrete[];
        流水式表_段统计信息: IDiscrete;
        流水式表_分组信息: IFlowGroup;
        流水式表_列: IDiscrete;
        流水式表_数据: IFlowData;
        流水式表_页统计信息: IDiscrete;
    };
    无映射离散指标_集合: IOrgGroupField[];
    映射数据预处理: {
        排序方式: string;
        排序键值集: any[];
        映射数据对象: string;
        预处理类型: string;
        过滤键值集: {
            compareObjKey: string
        }[];
        分组键值集: {
            seeking_parent: string
        }[];
        父子排序键: {
            父映射数据对象: string
        }[]
    }[];
    指标_数据_映射: {
        离散参数_集合: IOrgGroupField[];
        离散指标_集合: IOrgGroupField[];
        主数据指标_集合: IOrgGroupField[];
        从数据指标_集合: IOrgGroupField[];
        主数据指标_拓展集合: IOrgGroupField[];
        从数据指标_拓展集合: IOrgGroupField[];
        [key: string]: IOrgGroupField[];
    };
    主信息: {
        版本: {
            功能版本: string;
            主版本: string;
        };
        报表名称: string;
        打印页面_信息: {
            方向: string;
            页规格: string;
            cross_display_order: number;
        };
        单位: string;
        页边距: IPosition;
    };

    GROUP_KEY: string;
    ID: number;
    ID_KEY: string;
    style_collection?: any[];
    control_collection: any;
}
// 以后会跟 IGroupField合并
export interface IOrgGroupField {
    DataType: string;
    descr?: string;
    ID: number;
    mapExpression: string;
    Name: string;
    Title?: string;
    Precision?: {
        type?: string;
        flexibleRefFieldID?: number;
        fixedMapExpression?: string;
        flexibleMapExpression?: string;
    };
    fixedPrecisionNum?: number;
    flexiblePrecisionRefObj?: { [key: string]: number }[];
    Default_Value?: string;
    isID?: string;
    IDSeq: number;
}

export interface IDataObj {
    DecimalObj: {
        prjDecimal: number;
        unitDecimal: {
            default_decimal?: number;
            unitDecimal?: any
        };
    };
    detail_data: (number | string)[][];
    detail_data_ex: any[];
    discrete_data: string[][];
    master_data: any[];
    master_data_ex: any[];
    [key: string]: any;
}

// 离散信息
export interface IDiscrete {
    BandName: string;
    discrete_field_s: Fields[];
    text_s: Fields[];
    CommonHeight: number;
    text: string;
    sum_field_s: Fields[];
    CommonWidth: number;
}
// 交叉表
export interface ICrossTab {
    BandName: string;
    cross_field_s: Fields[];
    text_s: Fields[];
    CommonHeight: number;
    text: string;
    CommonWidth: number;
}
// 流水式表_数据
interface IFlowData {
    BandName: string;
    CommonHeight: number;
    flow_field_s: Fields[];
    CalculationType: string;
}
// 流水式表_分组信息:
interface IFlowGroup {
    group_field_s: { FieldID: number }[];
    group_lines: IGrpLine[];
    sum_field_s: Fields[];
}

export interface IRstPage {
    page_seq?: number;
    cells: ICell[];
    page_merge_border?: IMergeBand;
}

export interface IMergeBand {
    Bottom: number;
    Left: number;
    Right: number;
    Top: number;
    style?: any;
}
//丢失的interface
export interface IPretreatment {
    [key: string]: any;
}
export interface ISubFilters {
    [key: string]: any;
}



//报表用户信息的内容
// 报表显示设置参数
export interface IRptConfig{
    fillZero: boolean;
    fonts: {
        CfgDispName: string;
        FontBold: string;
        FontHeight: string;
        FontItalic: string;
        FontUnderline: string;
        ID: string;
        Name: string;
    }[];
    isNarrow: boolean;
    margins: IPosition;
    showVerticalLine: boolean;
}
export interface RptTreeNode {
    ID: string;
    name: string;
    icon: string;
    children?: RptTreeNode[];
    userId?: string;
    flags?: {
        constructSumType?: string | null;
        taxType?: string | null;
        auditType?: string | null;
        rptTplType?:string | null;
    };
    UID?:number;
    refId?:string;
  }
//   方案列表
export interface IRptSchemeList{
    ID: string;
    name: string;
    data?: string[];
    level?:string;//级别，用来区分是单位工程、单项工程和建设项目的
}
//方案数据
export interface IRptSchemeData {
    userID:string;
    data:IRptSchemeList
}

//报表设置参数
export interface IRptCustomizeCfg {
    userID?: string;
    rptConfig:IRptConfig,
    schemeData:IRptSchemeList[]
   
}

//方法的参数
export interface IFormulasObject{
    [key:string]:any
   
}