import request from '@/config/axios'
import { listToTree } from '@/utils/tree'

/** 获取报表类型 */
export const getReportTypeApi1 = () => {
  return request.post({ url: '/report/getReportTypeApi' })
}
export const getReportTypeApi = () => {
  // const data = [
  //   {
  //     moduleName: '',
  //     parentId: 'east',
  //     parentName: 'EAST5.0',
  //     pkid: '001',
  //     typeName: '公共信息类'
  //   },
  //   {
  //     moduleName: '',
  //     parentId: 'east111',
  //     parentName: 'EAST5.0111',
  //     pkid: '001111',
  //     typeName: '公共信息类111'
  //   }
  // ]
  const data = [
    {
      moduleName: null,
      parentId: '1104',
      parentName: '1104',
      pkid: '100',
      remarks: '',
      rowId: null,
      systemCode: null,
      typeName: '月报',
      typeOrder: 1,
      userDataScope: null
    },
    {
      moduleName: null,
      parentId: '1104',
      parentName: '1104',
      pkid: '200',
      remarks: '',
      rowId: null,
      systemCode: null,
      typeName: '季报',
      typeOrder: 2,
      userDataScope: null
    },
    {
      moduleName: null,
      parentId: '1104',
      parentName: '1104',
      pkid: '300',
      remarks: '',
      rowId: null,
      systemCode: null,
      typeName: '半年报',
      typeOrder: 3,
      userDataScope: null
    },
    {
      moduleName: null,
      parentId: '1104',
      parentName: '1104',
      pkid: '400',
      remarks: '',
      rowId: null,
      systemCode: null,
      typeName: '年报',
      typeOrder: 4,
      userDataScope: null
    },
    {
      moduleName: null,
      parentId: '1',
      parentName: '报表类型',
      pkid: '1104',
      remarks: '1',
      rowId: null,
      systemCode: null,
      typeName: '1104',
      typeOrder: null,
      userDataScope: null
    },
    {
      moduleName: null,
      parentId: '0',
      parentName: null,
      pkid: '1',
      remarks: '基本类型',
      rowId: null,
      systemCode: null,
      typeName: '报表类型',
      typeOrder: null,
      userDataScope: null
    }
  ]
  return listToTree(data, {
    id: 'pkid',
    children: 'children',
    pid: 'parentId'
  })
}

/** 获取报表树 */
export const getReporTreeApi1 = () => {
  return request.post({ url: '/report/getReporTreeApi1' })
}

export const getReporTreeApi = () => {
  const data = [
    {
      as: '',
      createtime: '',
      begindate: '',
      text: 'CBRC指标',
      updatetime: '',
      nodeid: '7',
      parentid: '1'
    },
    {
      as: '20310704',
      createtime: null,
      begindate: '20110704',
      text: '报表状态',
      updatetime: null,
      nodeid: 'K1',
      parentid: '3'
    },
    {
      as: '20310704',
      createtime: null,
      begindate: '20110704',
      text: '工作流数据集',
      updatetime: null,
      nodeid: 'K2',
      parentid: '3'
    },
    {
      as: '20310707',
      createtime: null,
      begindate: '20110707',
      text: '报表填报按钮',
      updatetime: null,
      nodeid: 'K3',
      parentid: '3'
    },
    {
      as: '20310724',
      createtime: null,
      begindate: '20110724',
      text: '系统按钮权限',
      updatetime: null,
      nodeid: 'K4',
      parentid: '3'
    },
    {
      as: '20310804',
      createtime: null,
      begindate: '20110804',
      text: '汇总状态模型',
      updatetime: null,
      nodeid: 'K5',
      parentid: '3'
    },
    {
      as: '20310929',
      createtime: null,
      begindate: '20110929',
      text: '省联社报表状态查询',
      updatetime: null,
      nodeid: 'K6',
      parentid: '3'
    },
    {
      as: '20311111',
      createtime: null,
      begindate: '20111111',
      text: '金数强校验是否通过',
      updatetime: null,
      nodeid: 'K9',
      parentid: '3'
    },
    {
      as: '20311210',
      createtime: null,
      begindate: '20111210',
      text: '报表校验结果',
      updatetime: null,
      nodeid: 'K7',
      parentid: '3'
    },
    {
      as: '20311216',
      createtime: null,
      begindate: '20111216',
      text: '数据集发布',
      updatetime: null,
      nodeid: 'K8',
      parentid: '3'
    },
    {
      as: '20240131',
      createtime: null,
      begindate: '20110519',
      text: '(月)G01资产负债项目统计表',
      updatetime: '2023-10-27 10:45:33',
      nodeid: 'G0100',
      parentid: '7'
    },
    {
      as: '',
      createtime: '',
      begindate: '',
      text: '指标体系',
      updatetime: '',
      nodeid: '1',
      parentid: null
    }
  ]
  const result = listToTree(data, {
    id: 'nodeid',
    children: 'children',
    pid: 'parentid'
  })
  return result
}
