// 业户管理接口
import request from '@/utils/request'

//导出不可认领名单
export function exportNoClaimExcel(data) {
  // const formData = new FormData()
  // formData.append('noClaimList', data)
  return request({
    url: '/bizOwnerAssign/exportNoClaimExcel',
    method: 'post',
    data,
    responseType: 'blob'
  })
}

//通过文件指派主体片区
export function assignByFile(data) {
  return request({
    headers: {
      ContentType: 'multipart/form-data'
    },
    url: '/bizOwnerAssign/assignByFile',
    method: 'post',
    data
  })
}


//智慧认领统计
export function assignExcel(data) {
  return request({
    url: '/bizOwnerAssign/assignExcel',
    method: 'post',
    data,
    responseType: 'blob'
  })
}

//智慧认领统计
export function countAssign(data) {
  return request({
    url: '/bizOwnerAssign/countAssign',
    method: 'post',
    data
  })
}

/**
 * 主体分页
 * @param {object} data 主体分页
 * @returns 分页结果
 * @author lroyia
 * @since 2021年5月6日 10:02:05
 */
export function entPage(data) {
  return request({
    url: '/bizOwnerAssign/entOwnerPage',
    method: 'post',
    data
  })
}

/**
 * 导出业户主体数据
 * @param {object} data 导出业户主体数据
 * @author ymc
 * @since 2022年5月23日 17:12
 */
export function exportEntOwner(data) {
  return request({
    url: '/bizOwnerAssign/exportEntOwner',
    method: 'post',
    data,
    responseType: 'blob'
  })
}

/**
 * 业户认领
 * @param {string} sliceId 片区id
 * @param {string} pripid 主体id
 * @returns 认领结果
 * @author lroyia
 * @since 2021年5月6日 10:02:05
 */
export function assignOwner(sliceId, pripid) {
  const data = new FormData()
  data.append('sliceId', sliceId)
  data.append('pripid', pripid)
  return request({
    url: '/bizOwnerAssign/assignOwner',
    method: 'post',
    data
  })
}

export function BatchAssignOwner(sliceId, pripids) {
  const data = new FormData()
  data.append('sliceId', sliceId)
  data.append('pripids', pripids)
  return request({
    url: '/bizOwnerAssign/BatchAssignOwner',
    method: 'post',
    data
  })
}


export function assignOwner1(orgCode, pripid) {
  const data = new FormData()
  data.append('orgCode', orgCode)
  data.append('pripid', pripid)
  return request({
    url: '/bizOwnerAssign/assignOwner1',
    method: 'post',
    data
  })
}

export function BatchAssignOwner1(orgCode, pripids) {
  const data = new FormData()
  data.append('orgCode', orgCode)
  data.append('pripids', pripids)
  return request({
    url: '/bizOwnerAssign/BatchAssignOwner1',
    method: 'post',
    data
  })
}

/**
 * 业户片区调整
 * @param {string} sliceId 片区id
 * @param {string} assignId 业户记录id
 * @returns 调整结果
 * @author lroyia
 * @since 2021年5月6日 10:02:05
 */
export function changeOwner(sliceId, assignId) {
  const data = new FormData()
  data.append('sliceId', sliceId)
  data.append('assignId', assignId)
  return request({
    url: '/bizOwnerAssign/changeOwner',
    method: 'post',
    data
  })
}

export function changeOwnerBatch(data) {
  return request({
    url: '/bizOwnerAssign/changeOwnerBatch',
    method: 'post',
    data
  })
}

/**
 * 业户退还
 * @param {assignId} assignId 认领记录id
 * @returns 分页结果
 * @author lroyia
 * @since 2021年5月6日 10:02:05
 */
export function removeOwner(data) {
  // const data = new FormData()
  // data.append('assignId', submitData.assignId)
  // data.append('pripid', submitData.pripid)
  // data.append('remReason', submitData.remReason)
  // data.append('phone', submitData.phone)
  return request({
    url: '/bizOwnerAssign/removeOwner',
    method: 'post',
    data
  })
}

export function repairAssignOwner() {
  return request({
    url: '/market/init/repairAssignOwner',
    method: 'get'
  })
}

export function BatchRemoveOwner(data) {
  return request({
    url: '/bizOwnerAssign/BatchRemoveOwner',
    method: 'post',
    data
  })
}

export function sueInspectSave(data) {
  return request({
    url: '/market/sueInspect/save',
    method: 'post',
    data
  })
}

export function sueInspectList(data) {
  return request({
    url: '/market/sueInspect/list',
    method: 'post',
    data
  })
}

export function sueInspectListFile(params) {
  return request({
    url: '/market/sueInspect/listFile',
    method: 'get',
    params
  })
}

export function sueInspectGet(params) {
  return request({
    url: '/market/sueInspect/get',
    method: 'get',
    params
  })
}

export function sueInspectUpload(data) {
  const formData = new FormData()
  formData.append('attachType', data.attachType)
  formData.append('id', data.id)
  for (const file of data.files) {
    formData.append('files', file)
  }
  return request({
    url: '/market/sueInspect/upload',
    method: 'post',
    data: formData
  })
}

export function sueInspectDelete(params) {
  return request({
    url: '/market/sueInspect/delete',
    method: 'post',
    params
  })
}

export function sueInspectDelFile(params) {
  return request({
    url: '/market/sueInspect/delFile',
    method: 'post',
    params
  })
}

export function sueInspectUpdate(data) {
  return request({
    url: '/market/sueInspect/update',
    method: 'post',
    data
  })
}

/**
 * 主体认领记录查询
 * @param {string} pripid 主体pripid
 * @returns 查询结果
 * @author lroyia
 * @since 2021年12月29日 13:55:11
 */
export function getAssignLogList(pripid) {
  return request({
    url: `/bizOwnerAssign/record/${pripid}`,
    method: 'get'
  })
}

/**
 * 获取当前用户对该主体的可认领片区
 * @returns 获取结果
 * @author lroyia
 * @since 2021年12月29日 14:26:56
 */
export function getAssignableSliceList(sliceType) {
  return request({
    url: '/areaSlice/getAssignableSliceListNew',
    method: 'get',
    params: {
      sliceType: sliceType
    }
  })
}

// 获取认领记录
export function getAssignInfo(params) {
  return request({
    url: `/bizOwnerAssign/info`,
    method: 'get',
    params
  })
}

// 标记虚假地址主体
export function inDraftRevoke(params) {
  return request({
    url: `/bizOwnerAssign/inDraftRevoke`,
    method: 'get',
    params
  })
}

// 移出标记虚假地址主体
export function removeDraftRevoke(params) {
  return request({
    url: `/bizOwnerAssign/removeDraftRevoke`,
    method: 'get',
    params
  })
}
