import { axios } from '@/utils/request'
import qs from 'qs'

const baseUrl = '/api/oms-std-maindata'
const businessUrl = '/api/oms-std-business'
// 证件列表
export const certificateRemoteUrl = {
  url: baseUrl + '/pubCertificate/pubCertificateQuery/v1.0',
  method: 'post',
  headers: {
    'Content-Type': 'application/JSON'
  }
}
// 证件资料新增
export const add = data => {
  return axios.post(baseUrl + '/pubCertificate/pubCertificateAdd/v1.0', data)
}
// 证件资料编辑
export const update = data => {
  return axios.post(baseUrl + '/pubCertificate/pubCertificateUpdate/v1.0', data)
}
// 证件资料删除
export const del = data => {
  return axios.post(baseUrl + '/pubCertificate/pubCertificateDelete/v1.0', data)
}
/**
 * 文件处理
 * */
// 查询图片
export const getPicture = data => {
  return axios.post(baseUrl + '/sysFile/querySysPicture', data)
}
// 上传文件
export const uploadFile = data => {
  return axios.post(businessUrl + '/biz-file/upload', data)
}
// 删除文件
export const delFile = ids => {
  return axios.post(businessUrl + `/biz-file/del?ids=${ids}`)
}
// 下载文件
export const downloadFile = url => {
  return axios.get(businessUrl + '/biz-file/download/url', { timeout: 6e5, params: { url }, responseType: 'arraybuffer' })
}
// 批量打包下载
export const batchDownloadFile = ids => {
  return axios.get(businessUrl + '/biz-file/download2', { timeout: 6e5, params: { ids }, responseType: 'arraybuffer' })
}
// 查询文件列表
export const getFileList = data => {
  return axios.post(businessUrl + '/biz-file/list', qs.stringify(data), {
    headers: {
      'content-type': 'application/x-www-form-urlencoded'
    }
  })
}