import request from '@/utils/request'

export function listEntInfo(data) {
  return request({
    url: '/market/tSUsualInspect/listEntInfo',
    method: 'post',
    data
  })
}

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

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

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

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

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

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

export function removeTSUsualInspectEntList(id) {
  return request({
    url: '/market/tSUsualInspectEntList/delete',
    method: 'post',
    params: {
      id: id
    }
  })
}

export function removeTSUsualInspect(id) {
  return request({
    url: '/market/tSUsualInspect/delete',
    method: 'post',
    params: {
      id: id
    }
  })
}

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

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

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

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

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

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

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

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

export function batchSave(data) {
  return request({
    headers: {
      ContentType: 'multipart/form-data'
    },
    url: '/market/tSUsualInspect/batchSave',
    method: 'post',
    data
  })
}

export function batchAddressSave(data) {
  return request({
    headers: {
      ContentType: 'multipart/form-data'
    },
    url: '/market/tSUsualInspect/batchAddressSave',
    method: 'post',
    data
  })
}

//导出不可导入名单
export function exportNoCanExcel(data) {
  const formData = new FormData()
  formData.append('ids', data)
  return request({
    url: '/market/tSUsualInspect/exportNoCanExcel',
    method: 'post',
    data: formData,
    responseType: 'blob'
  })
}

export function startManyTask(data) {
  return request({
    headers: {
      ContentType: 'multipart/form-data'
    },
    url: '/market/tSUsualInspect/startManyTask',
    method: 'post',
    data
  })
}

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

export function getDsmBySparentCode(params) {
  return request({
    url: '/market/areaDsm/getInfoBySparentCode',
    method: 'get',
    params
  })
}

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

export function getAllBySareaCode(params) {
  return request({
    url: '/market/areaDsm/getAllBySareaCode',
    method: 'get',
    params
  })
}
/**
 * 应诉检查获取主体检查记录
 */
export function getSueInspectList(pripid) {
  return request({
    url: `/market/sueInspect/getList?pripid=${pripid}`,
    method: 'get'
  })
}
/**
 * 动态监管获取主体检查记录
 */
export function getUsualInspectList(pripid) {
  return request({
    url: `/market/tSUsualInspect/getList?pripid=${pripid}`,
    method: 'get'
  })
}
/**
 * 动态监管获取主体检查记录
 */
export function getUsualInspectInfo(id) {
  return request({
    url: `/market/tSUsualInspect/get?id=${id}`,
    method: 'get'
  })
}
export function deleteAreaDsm(params) {
  return request({
    url: '/market/areaDsm/deleteAreaDsm',
    method: 'get',
    params
  })
}

export function saveAreaDsm(data) {
  return request({
    url: '/market/areaDsm/saveAreaDsm',
    method: 'post',
    data
  })
}

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

/**
 * 通过当前登录用户的组织架构，获取用户可视的片区数据
 * @param {string} isUnit 是否为单位（0否1是），传空查全部
 * @returns 查询结果
 * @author lroyia
 * @since 2021年12月11日 10:46:00
 */
export function getInfoByUserRegion(isUnit) {
  if (!isUnit) isUnit = ''
  return request({
    url: `/market/areaDsm/getInfoByUserRegion?isUnit=${isUnit}`,
    method: 'get'
  })
}

export function queryFileByHistory(params) {
  return request({
    url: '/attachment/queryFileByHistory',
    method: 'get',
    params
  })
}

// 修改API方法定义
export function addContactLogByEntNo(params) {
  return request({
    url: '/market/tSUsualInspect/addContactLogByEntNo',
    method: 'post',
    params: {
      pripid: params.pripid,
      originalValue: params.originalValue
    }
  })
}
