import request, { postBlob } from '@/utils/request'

/**
 * 保险合同
 */

export function insureList(data) {
  return request({
    url: `/policyManager/list?moduleId=${data.moduleId}`,
    method: 'post',
    data
  })
}

export function insureListExport(data, name) {
  return postBlob({
    url: '/policyManager/list/export',
    data,
    name
  })
}

export function insureDetail(params) {
  return request({
    url: `/policyManager/detail`,
    method: 'post',
    params
  })
}

export function insureAdd(data) {
  return request({
    url: `/policyManager/add`,
    method: 'post',
    data
  })
}

export function insureUpdate(data) {
  return request({
    url: `/policyManager/update`,
    method: 'post',
    data
  })
}

// export function insureOnOff(params) {
//   return request({
//     url: `/insure/on-off`,
//     method: 'post',
//     params
//   })
// }

export function insureDelete(params) {
  return request({
    url: `/policyManager/del`,
    method: 'post',
    params
  })
}

// --------------------------------------------------------

/**
 * 保险协议
 */

export function insureAgreeList(data) {
  return request({
    url: `/agreement/list?moduleId=${data.moduleId}`,
    method: 'post',
    data
  })
}

export function insureAgreeExport(data, name) {
  return postBlob({
    url: '/agreement/list/export',
    data,
    name
  })
}

export function insureAgreeDetail(params) {
  return request({
    url: `/agreement/detail`,
    method: 'post',
    params
  })
}

export function insureAgreeAdd(data) {
  return request({
    url: `/agreement/add`,
    method: 'post',
    data
  })
}

export function insureAgreeUpdate(data) {
  return request({
    url: `/agreement/update`,
    method: 'post',
    data
  })
}

// export function insureAgreeOnOff(params) {
//   return request({
//     url: `/insure/agree/on-off`,
//     method: 'post',
//     params
//   })
// }

export function insureAgreeDelete(params) {
  return request({
    url: `/agreement/del`,
    method: 'post',
    params
  })
}

// --------------------------------------------------------

/**
 * 邮箱配置
 */
export function insureEmailConfig(data) {
  return request({
    url: `/mailbox/add`,
    method: 'post',
    data
  })
}

export function insureEmailDetail(params) {
  return request({
    url: `/mailbox/detail`,
    method: 'post',
    params
  })
}

// --------------------------------------------------------

/**
 * 邮箱配置
 */
export function insureListemail(data) {
  return request({
    url: `/mailbox/list?moduleId=${data.moduleId}`,
    method: 'post',
    data
  })
}

export function insureListemailExport(data, name) {
  return postBlob({
    url: '/mailbox/list/export',
    data,
    name
  })
}

export function insureDetailemail(params) {
  return request({
    url: `/mailbox/detailRecord`,
    method: 'post',
    params
  })
}

export function insureResend(params) {
  return request({
    url: `/mailbox/resend`,
    method: 'post',
    params
  })
}

// --------------------------------------------------------

/**
 * 工程师保险
 */
export function insureWorkerList(data) {
  var { moduleId, ...p } = data
  return request({
    url: `/mailbox/listPolicy`,
    method: 'post',
    data: p
  })
}

export function insureWorkerLists(data) {
  return request({
    url: `/mailbox/listPolicy?moduleId=${data.moduleId}`,
    method: 'post',
    data
  })
}

export function insureWorkerExport(data, name) {
  return postBlob({
    url: '/mailbox/listPolicy/export',
    data,
    name
  })
}

// export function insureWorkerDetail(params) {
//   return request({
//     url: `/insure/worker/detail`,
//     method: 'post',
//     params
//   })
// }

// export function insureWorkerOnOff(params) {
//   return request({
//     url: `/insure/worker/on-off`,
//     method: 'post',
//     params
//   })
// }

// --------------------------------------------------------

/**
 * 商用工程师保险
 */
export function insureWorkerCommercialList(data) {
  return request({
    url: `/insure/worker/commercial/list?moduleId=${data.moduleId}`,
    method: 'post',
    data
  })
}

export function insureWorkerCommercialExport(data, name) {
  return postBlob({
    url: '/insure/worker/commercial/export',
    data,
    name
  })
}

export function insureWorkerCommercialDetail(params) {
  return request({
    url: `/insure/worker/commercial/detail`,
    method: 'post',
    params
  })
}

export function insureWorkerCommercialExamine(params) {
  return request({
    url: `/insure/worker/commercial/examine`,
    method: 'post',
    params
  })
}

export function insureWorkerCommercialOnOff(params) {
  return request({
    url: `/insure/worker/commercial/onOff`,
    method: 'post',
    params
  })
}

// --------------------------------------------------------

// 商用保险保存
export function insureWorkerCommercialSave(data) {
  return request({
    url: `/insure/worker/commercial/save`,
    method: 'post',
    data
  })
}

export function insureList2(params) {
  return request({
    url: `/worker/list2`,
    method: 'post',
    params
  })
}
