import { axios } from '@/utils/request'
import { UPCLOUD_RDC_TMS_MAINDATA_SERVICE,SERVICES_FILE_MANAGEMENT } from '@/config/serviceSettings.js'
import qs from 'qs'
const baseUrl = UPCLOUD_RDC_TMS_MAINDATA_SERVICE



// 上传文件bizType枚举
export const fileEmun = {
  // 证件附件类型
  certificate: '11',
  // 打印模板-模板文件
  printTemplate: '12'
}



// 上传文件
export const uploadFile = data => {
  return axios({
    processData: false,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    url:SERVICES_FILE_MANAGEMENT +'/file/upload-file/v2',
    method: 'post',
    data
  })
  //return axios.post(baseUrl + '/biz-file/upload', data)
}
// 删除文件
export const delFile = ids => {
  return axios.post(baseUrl + `/biz-file/del?ids=${ids}`)
}
// 下载文件
export const downloadFile = url => {
  return axios.get(baseUrl + '/biz-file/download/url', { timeout: 6e5, params: { url }, responseType: 'arraybuffer' })
}
// 批量打包下载
export const batchDownloadFile = ids => {
  return axios.get(baseUrl + '/biz-file/download2', { timeout: 6e5, params: { ids }, responseType: 'arraybuffer' })
}
// 查询文件列表
export const getFileList = data => {
  return axios.post(baseUrl + '/biz-file/list', qs.stringify(data), {
    headers: {
      'content-type': 'application/x-www-form-urlencoded'
    }
  })
}