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

export const getTableListApi = (params: any) => {
  //return request.post({ url: '/export/spi/export/format/ExportFormatConfigQueryPage', params })
  const data: any = [
    {
      author: 'admin',
      reportName: '授信明细表',
      dataDate: '20220303',
      createTime: '20230904',
      startTime: '20230904 09:08:03',
      endTime: '20230904 09:08:03',
      state: '成功'
    },
    {
      author: 'admin',
      reportName: '单笔非授信',
      dataDate: '20220303',
      createTime: '20230904',
      startTime: '20230904 09:08:03',
      endTime: '20230904 09:08:03',
      state: '成功'
    },
    {
      author: 'admin',
      reportName: '用信明细表',
      dataDate: '20220303',
      createTime: '20230904',
      startTime: '20230904 09:08:03',
      endTime: '20230904 09:08:03',
      state: '成功'
    },
    {
      author: 'admin',
      reportName: '关联交易余额表',
      dataDate: '20220303',
      createTime: '20230904',
      startTime: '20230904 09:08:03',
      endTime: '20230904 09:08:03',
      state: '成功'
    },
    {
      author: 'admin',
      reportName: '金融产品表',
      dataDate: '20220303',
      createTime: '20230904',
      startTime: '20230904 09:08:03',
      endTime: '20230904 09:08:03',
      state: '成功'
    },
    {
      author: 'admin',
      reportName: '非受信明细',
      dataDate: '20220303',
      createTime: '20230904',
      startTime: '20230904 09:08:03',
      endTime: '20230904 09:08:03',
      state: '失败'
    },
    {
      author: 'admin',
      reportName: '单笔受限',
      dataDate: '20220303',
      createTime: '20230904',
      startTime: '20230904 09:08:03',
      endTime: '20230904 09:08:03',
      state: '失败'
    },
    {
      author: 'admin',
      reportName: '关联关系',
      dataDate: '20220303',
      createTime: '20230904',
      startTime: '20230904 09:08:03',
      endTime: '20230904 09:08:03',
      state: '失败'
    },
    {
      author: 'admin',
      reportName: '关联方自然人',
      dataDate: '20220303',
      createTime: '20230904',
      startTime: '20230904 09:08:03',
      endTime: '20230904 09:08:03',
      state: '成功'
    },
    {
      author: 'admin',
      reportName: '关联方法人',
      dataDate: '20220303',
      createTime: '20230904',
      startTime: '20230904 09:08:03',
      endTime: '20230904 09:08:03',
      state: '成功'
    }
  ]
  const data1: any = [
    {
      author: 'admin',
      reportName: '存量单位贷款信息',
      dataDate: '20220303',
      createTime: '20230904',
      startTime: '20230904 09:08:03',
      endTime: '20230904 09:08:03',
      state: '成功'
    },
    {
      author: 'admin',
      reportName: '个人客户基础信息',
      dataDate: '20220303',
      createTime: '20230904',
      startTime: '20230904 09:08:03',
      endTime: '20230904 09:08:03',
      state: '成功'
    },
    {
      author: 'admin',
      reportName: '贷款发生额',
      dataDate: '20220303',
      createTime: '20230904',
      startTime: '20230904 09:08:03',
      endTime: '20230904 09:08:03',
      state: '成功'
    },
    {
      author: 'admin',
      reportName: '信贷企业基础信息',
      dataDate: '20220303',
      createTime: '20230904',
      startTime: '20230904 09:08:03',
      endTime: '20230904 09:08:03',
      state: '失败'
    }
  ]
  return {
    data: {
      list: params.pageNum === 1 ? data : data1,
      total: 14
    }
  }
}
/**
 *
 * @param params 模版管理
 * @returns
 */
export const TempSubmitManage = (params: any) => {
  //return request.post({ url: '/export/spi/export/format/ExportFormatConfigQueryPage', params })
  const data: any = [
    {
      pkid: '123',
      formatId: '310',
      formatName: '关联关系',
      systemCode: 'portal',
      format: '<11111111>'
    },
    {
      pkid: '124',
      formatId: '311',
      formatName: '单笔授信',
      systemCode: 'portal',
      format: '<11111111>'
    },
    {
      pkid: '125',
      formatId: '312',
      formatName: '授信明细表',
      systemCode: 'portal',
      format: '<11111111>'
    },
    {
      pkid: '126',
      formatId: '313',
      formatName: '单笔非授信',
      systemCode: 'portal',
      format: 'RESULT_PBSD_LOAF'
    },
    {
      pkid: '127',
      formatId: '314',
      formatName: '贷款发生额',
      systemCode: 'portal',
      format: ''
    }
  ]
  const data1: any = [
    {
      pkid: '123',
      formatId: '310',
      formatName: '贷款发生额',
      systemCode: 'portal',
      format: '<11111111>'
    },
    {
      pkid: '123',
      formatId: '310',
      formatName: '贷款发生额',
      systemCode: 'portal',
      format: '<11111111>'
    },
    {
      pkid: '123',
      formatId: '310',
      reportName: '贷款发生额',
      systemCode: 'portal',
      format: '<11111111>'
    },
    {
      pkid: '123',
      formatId: '310',
      formatName: '贷款发生额',
      systemCode: 'portal',
      format: '<11111111>'
    },
    {
      pkid: '123',
      formatId: '310',
      formatName: '贷款发生额',
      systemCode: 'portal',
      format: '<11111111>'
    }
  ]
  return {
    data: {
      list: params.pageNum === 1 ? data : data1,
      total: 5
    }
  }
}

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

export const saveTableApi = (data: Partial<Template>): Promise<IResponse> => {
  return request.post({ url: '/export/spi/format/ExportFormatConfigSave', data })
}

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

export const delTableListApi = (pkid: string[] | number[]): Promise<IResponse> => {
  return request.post({ url: '/export/spi/format/ExportFormatConfigDelete', data: { pkid } })
}
