import { TaxType, IGLJCol, FileType } from './project';
import { IFileRef, INumFileRef } from './base';
import { IBillOption } from './bill';

export interface ICptItem {
  ID: string;
  name: string;
  description: string;
}

export interface IProgramLib extends INumFileRef {
  displayName: string;
}

export interface ITaxGroup {
  programLib: IProgramLib;
  templateLib: IFileRef;
  colLib: IFileRef;
  feeLib: IFileRef;
  taxType: TaxType;
  normLib: string; // 指标分部
}

// 工程专业
export interface IEngineering {
  ID: string;
  name: string;
  feeName: string;
  engineering: number;
  projectEngineering: number;
  valuationID: string;
  // 显示设置
  isAreaIncrease?: boolean; // 显示面积增加费
  isItemIncrease?: boolean; // 显示子目增加费
  isInstall?: boolean; // 显示安装增加费
  gljCol?: IGLJCol;
  overHeightLib?: IFileRef[];
  economicLib?: IFileRef[];
  mainQuantityLib?: IFileRef[];
  materialLib?: IFileRef[];
  engineerFeatureLib?: IFileRef[];
  engineerInfoLib?: IFileRef[];
  infoLib?: IFileRef[];
  featureLib?: IFileRef[];
  artificialLib?: INumFileRef[];
  billLib?: IBillOption[];
  billsGuidanceLib?: IFileRef[];
  gljLib?: INumFileRef[];
  rationLib?: INumFileRef[];
  progressiveLib?: IFileRef[];
  taxGroup: ITaxGroup[];
  indexName?: string; // 指标专业名称
  visible?: boolean; // 是否显示
}

export interface IValuation {
  engineeringList: IEngineering[];
  enable: boolean;
  ID: string;
  name: string;
  fileTypes?: FileType[];
}

export enum versionType {
  FREE = 'free', // 免费版
  PRO = 'pro', // 专业版
}

export enum LockInfo {
  DEFAULT = 0, // 默认值
  BORROW = 1, // 借用
  BUY = 2, // 销售
}

export interface IConsumeAmt {
  region: string;
  taxModel: number;
  consumeAmt: {
    dataCode: string;
    dataName: string;
    refPrice: string;
  };
}

export interface ISubPrice {
  region: string;
  taxModel: number;
  price: {
    dataCode: string;
    dataName: string;
  };
}

interface ISubStructuralSegmentProperty {
  valuationID: string;
  normLib: string;
  taxType: number;
  fileType: number;
  calcProgramLib: {
    ID: string;
    name: string;
    displayName: string;
  };
  engineeringID: string;
}

export interface ISubStructuralSegment {
  dispName: string;
  key: string;
  type: string;
  subItems?: ISubStructuralSegment[];
  engineering?: string;
  feeType?: string;
  calcProgram?: string;
  IndicatorSegment?: string;
  property?: ISubStructuralSegmentProperty;
}

// 结构分布
export interface IStructuralSegmentData {
  monomerType: string;
  valuationName: string;
  items: ISubStructuralSegment[];
}

export interface IStructuralSegment {
  compilationID: string;
  ID: string;
  name: string;
  data: IStructuralSegmentData[];
}

// 单体模板
export interface ISubMonomerTemplate {
  dispName: string;
  key: string;
  monomerType: string;
  isHaveStructuralSegment: string;
}

export interface IMonomerTemplateData {
  dispName: string;
  key: string;
  items: ISubMonomerTemplate[];
}

export interface IConstructionTemplate {
  dispName: string;
  key: string;
}
export interface IMonomerTemplate {
  compilationID: string;
  data: any; // 兼容还没改结构之前的版本，写法，上线后修改回来 -- 不然部署报错
  /*  data: {
    constructionTemplate: IConstructionTemplate[];
    monomerTemplate: IMonomerTemplateData[];
  }; */
}

export interface ICompilation {
  ID: string;
  name: string;
  creator: string;
  createTime: number;
  releaseTime: number;
  rationValuations: any;
  billValuations: IValuation[];
  isRelease: boolean;
  description: string;
  overWriteUrl: string;
  categoryID: string;
  example: number[];
  adProjects: number[];
  consumeAmtProperties?: IConsumeAmt[]; // 多组成物时的消耗量属性来源
  priceProperties?: ISubPrice[]; // 多单价时的价格属性来源
  // 附加
  version: versionType; // 版本
  versionText: string; // 版本对应的显示文字：免费版，学习版，专业版
  lockInfo: LockInfo; // 锁信息
  monomerTemplate: IMonomerTemplateData[];
  constructionTemplate: IConstructionTemplate[];
  structuralSegment: IStructuralSegmentData[];
  edition: string; // 版本号（用于项目信息、项目特征等项目信息的升级）
}

export enum ValuationType {
  BILL = 'bill', // 清单计价
  RATION = 'ration', // 定额计价
}

// 专业版费用定额
export interface IProCptItem {
  // 编办 ID
  compilationID: string;
  // 开通时间
  upgradeTime: number;
  // 备注
  remark: string;
  // 截至时间，0 代表无限制
  deadline: number;
  // 锁信息
  lock: LockInfo;
}
