import NewAxiosInstanceFunc from '../Service/NewAxiosInstance'
import { INewResponse } from '../Service/INewResponse'
import { IPaging } from 'Material/Material.service'
import { IMeetingreviewchaptItem } from 'Newest/Newest.service'

export interface IRecentDetailRes {
  Detail: {
    ArticleId: number //报告Id
    Title: string //标题
    Department: string //作者
    PublishDate: string //发布时间
    CreateTime: string //创建时间
    LastUpdatedTime: string //最后一次更新时间
    Periods: number //期数
    VideoUrl: string //链接
    VideoPlaySeconds: string //时长
    VideoName: string //音频名称
    ProductDescription: string //产品说明
    UpdateDescription: string //更新说明
    FocusOn: string //近期重点关注方向
    MarketStrategy: string //市场策略核心逻辑汇总
    ReportLink: string //报告链接
    CeLueArticleId: number //策略报告详情
    VisibleRange: number //设置可见范围1全部，0内部
    Disclaimers: string
  } //报告详情
  HasPermission: number //1:有该行业权限,正常展示，2：无该行业权限，不存在权益客户下，3:无该品类权限,已提交过申请，4：无该行业权限,未提交过申请，5：潜在客户，未提交过申请，6：潜在客户,已提交过申请"
  List: IListItem[]
  ListPermissionSubject: IListPermissionSubject[]
  IsShow: boolean //是否展示
}
export interface IListItem {
  ChartPermissionId: number
  PermissionName: string //权限名称
  IcoLink: string //图标链接
  List: {
    IndustrialManagementId: string //产业Id
    IndustrialSubjectId: number //标的ID
    SubjectName: string //标的名称
    IsNew: boolean //是否展示新标签
    IsShowApplyButton: boolean //是否展示申请按钮
    Body: string //行业核心逻辑汇总
    CompanyLabel: string[] //公司标签
    Label: string //公司标签
    OverviewArticleId: number //综述报告Id
    List: ISympleIndustry[]
  }[] //是否展示新标签
  BodyChartSummary: string //行业核心逻辑汇总
}
export interface ISympleIndustry {
  IndustrialManagementId: number //产业Id
  IndustryName: string //产业名称
}
export interface IListPermissionSubject {
  PermissionName: string //权限名称
  ListSubject: IListSubject[] //标的列表
}
export interface IListSubject {
  SubjectName: string //标的名称
  IndustrialSubjectId: number //标的ID
  IsNew: boolean //是否展示新标签
}
export interface IWeeklyList {
  ArticleId: number //文章ID
  Title: string //标题
  Department: string //作者
  PublishDate: string //发布时间
  CreateTime: string //创建时间
  Abstract: string //摘要/更新说明
  UpdateDescription: string //更新说明
  IsRed: boolean //是否标记红点
  ReadNum: number //阅读次数
}
export interface IWeeklyDetailRes {
  Detail: {
    ArticleId: number //报告Id
    Title: string //标题
    Department: string //作者
    PublishDate: string //发布时间
    VideoUrl: string //链接
    VideoPlaySeconds: string //时长
    VideoName: string //音频名称
    Abstract: string
    VisibleRange: number //设置可见范围1全部，0内部
  } //报告详情
  HasPermission: number //1:有该行业权限,正常展示，2：无该行业权限，不存在权益客户下，3:无该品类权限,已提交过申请，4：无该行业权限,未提交过申请，5：潜在客户，未提交过申请，6：潜在客户,已提交过申请"
  List: {
    ListName: string //列表名称
    IcoLink: string //图标链接
    Type: string //类型'SDBG深度报告片篇,’CYDYJY：产业调研纪要’,’SJDP事件点评,’BZCHJH：本周晨会精华
    List: {
      PermissionName: string //行业名称
      ChartPermissionId: number //行业ID
      IcoLink: string //图标链接
      List: {
        Body: string //内容
        ReportLink: string //报告链接
        VideoUrl: string //链接
        IsHaveVideo: boolean //是否含有音频文件
      }[]
    }[]
  }[]
  IsShow: boolean //是否展示
}
export interface IMorningMeetingList {
  Id: number //ID
  Title: string //标题
  IndustryName: string //产业
}
export interface IMorningMeetingDetailRes {
  HasPermission: number
  Detail: {
    Id: number //ID
    Title: string //标题
    PublishTime: string //发布时间
    Department: string //作者
    List: IMeetingreviewchaptItem[]
  }
}
export interface ICustomInfo {
  id: number
  title: string
  abstract?: string
  content?: ICustomContent[]
  // setting?: ISingleSetting[]
  create_time?: string
  delete_time?: string
  update_time?: string
  creator?: string
  is_delete?: number
  breakpoint?: string
}
export interface ICustomContent {
  id: string
  type: string
  grid?: IGridInfo
  ext?: IExt
}
export interface IGridInfo {
  i?: string // id标识什么的
  x?: number // x轴位置
  y?: number // y轴位置
  w?: number // 宽度占比
  h?: number // 高度占比
  isDraggable?: boolean // 是否可拖拽
}
export interface IExt {
  value?: string // 文本框内容
  pathSetting?: string // chart的选择项
  chartID?: string // chart的ID
}

export const CollectionsService = {
  getRecentReportDetail: (ArticleId: number, IsBestNew: boolean): INewResponse<IRecentDetailRes> =>
    NewAxiosInstanceFunc({
      url: `/report_selection/detail`,
      method: 'get',
      params: { ArticleId, IsBestNew }
    }),
  getWeeklyReportList: (
    CurrentIndex: number,
    PageSize: number,
    ReportType: number // 2本周研究汇总、3上周纪要汇总
  ): INewResponse<{ List: IWeeklyList[]; Paging: IPaging }> =>
    NewAxiosInstanceFunc({
      url: `/report/reportList/byType`,
      method: 'get',
      params: { CurrentIndex, PageSize, ReportType }
    }),
  getResearchReportDetail: (ArticleId: number): INewResponse<IWeeklyDetailRes> =>
    NewAxiosInstanceFunc({
      url: `/report/researchSummary/detail`,
      method: 'get',
      params: { ArticleId }
    }),
  getMinutesReportDetail: (ArticleId: number): INewResponse<IWeeklyDetailRes> =>
    NewAxiosInstanceFunc({
      url: `/report/minutesSummary/detail`,
      method: 'get',
      params: { ArticleId }
    }),
  getMorningMeetingList: (
    CurrentIndex: number,
    PageSize: number
  ): INewResponse<{ List: IMorningMeetingList[]; Paging: IPaging }> =>
    NewAxiosInstanceFunc({
      url: `morning_meeting/gather/list`,
      method: 'get',
      params: { CurrentIndex, PageSize }
    }),
  getMorningMeetingDetail: (Id: number): INewResponse<IMorningMeetingDetailRes> =>
    NewAxiosInstanceFunc({
      url: `morning_meeting/gather/detail`,
      method: 'get',
      params: { Id }
    }),
  postReportClickHistory: (ArticleId: number, IndustrialSubjectId: number): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/report_selection/click/history`,
      method: 'post',
      data: { ArticleId, IndustrialSubjectId }
    }),
  postRoadshowCollect: (ArticleId: number, PlaySeconds: number, ReportType: number): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/report/voiceHistory/add`,
      method: 'post',
      data: { ArticleId, PlaySeconds, ReportType } // ReportType-2本周研究汇总、3上周纪要汇总
    }),
  postApplyReportRoadShow: (ArticleId: number, SubjectName: string): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/report_selection/report_selection_log/apply`,
      method: 'post',
      data: { ArticleId, SubjectName } // SubjectName-标的（公司）名称
    })
}
