import request from '@/config/axios'
import type { TableData } from './types'

export const getTableListApi = (params: any) => {
  //return request.get({ url: '/datadetail/list', params })
  const data: any = [
    {
      reportName: '1001-汇率信息表',
      frequency: '月报'
    },
    {
      reportName: '1002-金融工具信息表',
      frequency: '月报'
    },
    {
      reportName: '1003-自营资金交易信息表',
      frequency: '月报'
    },
    {
      reportName: '1004-自营资金业务余额表',
      frequency: '月报'
    },
    {
      reportName: '1005-即期及衍生品交易信息表',
      frequency: '月报'
    },
    {
      reportName: '101-机构信息表',
      frequency: '月报'
    },
    {
      reportName: '102-员工表',
      frequency: '月报'
    },
    {
      reportName: '103-柜员表',
      frequency: '月报'
    },
    {
      reportName: '104-岗位信息表',
      frequency: '月报'
    },
    {
      reportName: '105-机构关系表',
      frequency: '月报'
    }
  ]
  const data1 = [
    {
      reportName: '106-股东及关联方信息表',
      frequency: '月报'
    },
    {
      reportName: '201-个人基础信息表',
      frequency: '月报'
    }
  ]
  return {
    data: {
      list: params.pageNum === 1 ? data : data1,
      total: 12
    }
  }
}

/**
 * 报文配置
 * @param params
 * @returns
 */

export const getTableTempConfigListApi = (params: any) => {
  //return request.get({ url: '/datadetail/list', params })
  const data = [
    {
      reportCode: 'IN_SAFE_9052',
      reportName: '授信明细表',
      createTime: '20230910 08:08:04',
      updateTime: '20231010 09:08:04',
      formatName: '授信明细表',
      datasetId: '2',
      systemCode: 'portal',
      charSet: 'UTF-8',
      serviceType: 'com',
      format: '<11111111111>'
    },
    {
      reportCode: 'IN_SAFE_9052',
      reportName: '单笔非授信',
      createTime: '20230910 08:08:04',
      updateTime: '20231010 09:08:04',
      formatName: '单笔非授信',
      datasetId: '2',
      systemCode: 'portal',
      charSet: 'UTF-8',
      serviceType: 'com',
      format: '<11111111111>'
    },
    {
      reportCode: 'IN_SAFE_9052',
      reportName: '用信明细表',
      createTime: '20230910 08:08:04',
      updateTime: '20231010 09:08:04',
      formatName: '用信明细表',
      datasetId: '2',
      systemCode: 'portal',
      charSet: 'UTF-8',
      serviceType: 'com',
      format: '<11111111111>'
    },
    {
      reportCode: 'IN_SAFE_9052',
      reportName: '关联交易余额表',
      createTime: '20230910 08:08:04',
      updateTime: '20231010 09:08:04',
      formatName: '关联交易余额表',
      datasetId: '2',
      systemCode: 'portal',
      charSet: 'UTF-8',
      serviceType: 'com',
      format: '<11111111111>'
    },
    {
      reportCode: 'IN_SAFE_9052',
      reportName: '金融产品',
      createTime: '20230910 08:08:04',
      updateTime: '20231010 09:08:04',
      formatName: '金融产品',
      datasetId: '2',
      systemCode: 'portal',
      charSet: 'UTF-8',
      serviceType: 'com',
      format: '<11111111111>'
    },
    {
      reportCode: 'IN_SAFE_9052',
      reportName: '非授信明细表',
      createTime: '20230910 08:08:04',
      updateTime: '20231010 09:08:04',
      formatName: '非授信明细表',
      datasetId: '2',
      systemCode: 'portal',
      charSet: 'UTF-8',
      serviceType: 'com',
      format: '<11111111111>'
    },
    {
      reportCode: 'IN_SAFE_9052',
      reportName: '单笔授信表',
      createTime: '20230910 08:08:04',
      updateTime: '20231010 09:08:04',
      formatName: '单笔授信表',
      datasetId: '2',
      systemCode: 'portal',
      charSet: 'UTF-8',
      serviceType: 'com',
      format: '<11111111111>'
    },
    {
      reportCode: 'IN_SAFE_9052',
      reportName: '关联关系',
      createTime: '20230910 08:08:04',
      updateTime: '20231010 09:08:04',
      formatName: '关联关系',
      datasetId: '2',
      systemCode: 'portal',
      charSet: 'UTF-8',
      serviceType: 'com',
      format: '<11111111111>'
    },
    {
      reportCode: 'IN_SAFE_9052',
      reportName: '境外交易表',
      createTime: '20230910 08:08:04',
      updateTime: '20231010 09:08:04',
      formatName: '境外交易表',
      datasetId: '2',
      systemCode: 'portal',
      charSet: 'UTF-8',
      serviceType: 'com',
      format: ''
    },
    {
      reportCode: 'IN_SAFE_9052',
      reportName: '关联方自然人',
      createTime: '20230910 08:08:04',
      updateTime: '20231010 09:08:04',
      formatName: '关联方自然人',
      datasetId: '2',
      systemCode: 'portal',
      charSet: 'UTF-8',
      serviceType: 'com',
      format: '<11111111111>'
    }
  ]
  const data1 = [
    {
      reportCode: 'IN_SAFE_9052',
      reportName: '关联方法人',
      createTime: '20230910 08:08:04',
      updateTime: '20231010 09:08:04',
      formatName: '关联方法人',
      datasetId: '2',
      systemCode: 'portal',
      charSet: 'UTF-8',
      serviceType: 'com',
      format: '<11111111111>'
    }
  ]
  return {
    data: {
      list: params.pageNum === 1 ? data : data1,
      total: 11
    }
  }
}

export const getTreeTableListApi = (params: any) => {
  return request.get({ url: '/example/treeList', params })
}

export const saveTableApi = (data: Partial<TableData>): Promise<IResponse> => {
  return request.post({ url: '/example/save', data })
}

export const getTableDetApi = (id: string): Promise<IResponse<TableData>> => {
  return request.get({ url: '/example/detail', params: { id } })
}

export const delTableListApi = (ids: string[] | number[]): Promise<IResponse> => {
  return request.post({ url: '/example/delete', data: { ids } })
}
