import request from '@/router/axios';
import { getToken } from '@/util/auth'
/*获取列表*/
export const getList =
  (current, size, params) => {
    return request({
      url: '/api/jobslink-api/tenant/insure/tenant/list',
      method: 'get',
      params: {
        ...params,
        current,
        size,
      }
    })
  }

/*新增*/
export const add =
  (insureName, stime) => {
    return request({
      url: '/api/jobslink-api/tenant/insure/save',
      method: 'post',
      data: { insureName, stime }
    })
  }

/*查看保单详情列表*/
export const getDetailList =
  (current, size, params, insureId) => {
    return request({
      url: '/api/jobslink-api/tenant/insure/item/list',
      method: 'get',
      params: { ...params, current, size, insureId }
    })
  }

/*删除*/
export const remove =
  (id) => {
    return request({
      url: '/api/jobslink-api/tenant/insure/remove',
      method: 'post',
      params: { id }
    })
  }

/*删除*/
export const itemRemove =
  (ids, insureId) => {
    return request({
      url: '/api/jobslink-api/tenant/insure/item/remove',
      method: 'post',
      params: { ids, insureId }
    })
  }

/*选择人员列表*/
export const tenantList =
  (current, size, params, insureId) => {
    return request({
      url: '/api/jobslink-api/tenant/talents/tenant/list',
      method: 'get',
      params: { current, size, ...params, insureId }
    })
  }

/*确认人员*/
export const saveInsureUsers =
  (ids, insureId) => {
    return request({
      url: '/api/jobslink-api/tenant/insure/item/saveInsureUsers',
      method: 'post',
      params: { ids, insureId }
    })
  }

/*提交保单*/
export const submit =
  (insureId) => {
    return request({
      url: '/api/jobslink-api/tenant/insure/commit/submit',
      method: 'post',
      params: { insureId }
    })
  }

/*上传参保人员名单*/
// export const uploadTalents =
//   () => {
//     return `/api/jobslink-api/tenant/talents/tenant/import-insures?isCovered=1`
//   }
export const uploadTalents =
(file) => {
  return `/api/jobslink-api/tenant/insure/item/importInsureItem?file=${
    file}`
  }

/*下载参保单明细*/
export const download = (auth, insureId) => {
  return `/api/jobslink-api/tenant/insure/item/tenant/export-insureItem?Jobslink-Auth=${
    auth}&insureId=${insureId}`
}
/*下载凭证*/
export const downloadVoucher = (companyId) => {
  return `/api/jobslink-api/tenant/insure/generateInsurePDF/${companyId}?&Jobslink-Auth=${getToken()}`
}
/*导出商保明细*/
export const exportInsure = (query) => {
  return `/api/jobslink-api/tenant/insure/export-insure/?${query}&Jobslink-Auth=${getToken()}`
}
//商保管理接口
export const getInsureItemList =
    (current, size, params) => {
      return request({
        url: '/api/jobslink-api/tenant/insure/item/getInsureItemList',
        method: 'get',
        params: {
          ...params,
          current,
          size,
        }
      })
    }
/*选择投保人员*/
export const insurePerson =
  (current, size,name,talentName) => {
    return request({
      url: '/api/jobslink-api/tenant/insure/item/insurePerson',
      method: 'get',
      params: { name,talentName,current,size,}
    })
  }
// 参保单提交接口
export const importInsureItem =
  (fpAddressId,fpTitleId, data) => {
    return request({
      url: '/api/jobslink-api/tenant/insure/commit/submitNew',
      method: 'post',
      data: { fpAddressId,fpTitleId, data }
    })
  }
  //在商保列表中通过missionNo获取岗位名称
  export const getDetail =
    (missionNo) => {
      return request({
        url: '/api/jobslink-api/missions/mission/detail',
        method: 'get',
        params: {missionNo}
      })
    }
  //
  export const uploadTemplate =
  () => {
    return `http://jlfiles-test.oss-cn-zhangjiakou.aliyuncs.com/contract/20210408/投保人员信息模板-企业.xlsx`
    }
