/**
 * 设备类型管理接口
 */
import request from '@/utils/request'
// import qs from 'qs'

// 设备类型查询
export function getDeviceTypeList(params) {
  return request({
    url: 'deviceType/pageList',
    method: 'get',
    params
  })
}

// 获取批产负责人
export function getPrincipalList(str) {
  return request({
    url: 'deviceType/getUser',
    method: 'get',
    params: {
      tips: str
    }
  })
}
// 获取组织机构
export function getDeptList() {
  return request({
    url: 'deviceType/getDept',
    method: 'get'
  })
}
// 查看参数
export function getDeviceTypeKpi(id) {
  return request({
    url: 'deviceType/kpiDetail',
    method: 'get',
    params: {
      id: id
    }
  })
}

// 批量导入专题库人员
export function batchImportPersonSpecial(specialId, fileobj) {
  const param = new FormData()
  param.append('specialId', specialId)
  param.append('file', fileobj)
  return request({
    url: '/irisPersonspecial/batchImport',
    method: 'post',
    headers: { 'Content-Type': 'multipart/form-data' },
    data: param
  })
}

// 添加设备类型
export function addDeviceType(productName, productModel, machineVersion, hardwareVersion, softwareVersion,
  designArchive, batchFiling, status, principal, kpi, quotaSummary, quotaSummaryFile, communicationVersion, productType) {
  var param = new FormData()
  param.append('productName', productName)
  param.append('productModel', productModel)
  param.append('machineVersion', machineVersion)
  param.append('hardwareVersion', hardwareVersion)
  param.append('softwareVersion', softwareVersion)
  param.append('designArchive', designArchive)
  param.append('batchFiling', batchFiling)
  param.append('status', status)
  param.append('principal', principal)
  param.append('kpi', kpi)
  param.append('quotaSummary', quotaSummary)
  param.append('quotaSummaryFile', quotaSummaryFile)
  param.append('communicationVersion', communicationVersion)
  param.append('productType', productType)
  return request({
    url: 'deviceType/add',
    method: 'post',
    headers: { 'Content-Type': 'multipart/form-data' },
    data: param
  })
}
// 修改设备
export function updateDeviceType(id, productName, productModel, machineVersion, hardwareVersion, softwareVersion,
  designArchive, batchFiling, status, principal, kpi, quotaSummary, quotaSummaryFile, communicationVersion, productType) {
  var param = new FormData()
  param.append('id', id)
  param.append('productName', productName)
  param.append('productModel', productModel)
  param.append('machineVersion', machineVersion)
  param.append('hardwareVersion', hardwareVersion)
  param.append('softwareVersion', softwareVersion)
  param.append('designArchive', designArchive)
  param.append('batchFiling', batchFiling)
  param.append('status', status)
  param.append('principal', principal)
  param.append('kpi', kpi)
  param.append('quotaSummary', quotaSummary)
  param.append('quotaSummaryFile', quotaSummaryFile)
  param.append('communicationVersion', communicationVersion)
  param.append('productType', productType)
  return request({
    url: 'deviceType/mod',
    method: 'post',
    data: param
  })
}
// 定额汇表导入
export function batchImportSummary(fileobj) {
  const param = new FormData()
  param.append('fs', fileobj)
  return request({
    url: 'deviceType/summaryImp',
    method: 'post',
    headers: { 'Content-Type': 'multipart/form-data' },
    data: param
  })
}
// 定额汇总表下载
export function batchExportSummary(quotaSummary) {
  return request({
    url: 'deviceType/summaryDownload',
    withCredentials: false,
    method: 'get',
    params: {
      quotaSummary: quotaSummary
    },
    timeout: 120000,
    responseType: 'blob'// 这一步也很关键，一定要加上 responseType 值为 blob
  })
}
// 批量导入
export function batchImportDeviceType(fileobj) {
  const param = new FormData()
  param.append('fs', fileobj)
  return request({
    url: 'deviceType/imp',
    method: 'post',
    headers: { 'Content-Type': 'multipart/form-data' },
    data: param
  })
}
// 批量导出
export function batchExportDeviceType(params) {
  return request({
    url: 'deviceType/listExp',
    method: 'post',
    timeout: 120000,
    params,
    responseType: 'blob' // 这一步也很关键，一定要加上 responseType 值为 blob
  })
}

