import request from '@/assets/js/utils/request'
import { createURL } from '@/assets/js/utils/index'
// 上传
export const upLoadFileUrl =
  '/bidprocurement/common-tools/tools/commonUpload/upLoadFile'

// 上传处理excel表格
export const saveFile4Excel =
  '/bidprocurement/common-tools/tools/commonUpload/saveFile4Excel'

// 上传图片
export const uploadImage =
  '/bidprocurement/common-tools/tools/commonUpload/uploadImage'

// 文件详情
export function getFileDetail(data) {
  return request({
    url:
      '/bidprocurement/common-tools/tools/commonUpload/getFileDetail' + createURL(data) + '&t=' + Date.now(),
    method: 'get'
  })
}

// 下载模版（目前只有专家库用了）
export function downloadTemplate(params) {
  return request({
    url:
      '/bidprocurement/common-tools/tools/commonUpload/downloadTools',
    method: 'get',
    params,
    responseType: 'blob'
  })
}
/* export function getFileDetail(bizId, fileType) {
  return request({
    url:
      '/bidprocurement/common-tools/tools/commonUpload/getFileDetail' + '?t=' + Date.now() + '&bizId=' + bizId + '&fileType=' + fileType,
    method: 'get'
  })
}*/

// 文件下载
export const downLoadFileUrl = '/bidprocurement/common-tools/tools/commonUpload/downLoadFile'
export const downLoadFileUrl2 = '/service-app/common-tools/tools/commonUpload/downLoadFile'
export function downLoadFile(data) {
  return request({
    url: '/bidprocurement/common-tools/tools/commonUpload/downLoadFile' + createURL(data),
    method: 'get',
    responseType: 'blob'
  })
}

// 归档文件下载
export function downLoadFileByPath(data) {
  return request({
    url: '/bidprocurement/common-tools/tools/commonUpload/downLoadFileByPath?' + 'realpath=' + data.realpath + '&attachmenttitle=' + data.attachmenttitle + '&extend=' + data.extend,
    method: 'get',
    responseType: 'blob'
  })
}

// 文件删除
export function delFile(data) {
  return request({
    url:
      '/bidprocurement/common-tools/tools/commonUpload/delFile' +
      createURL(data),
    method: 'post'
  })
}
// 文件预览下载//传绝对路径
export const readImage = '/bidprocurement/common-tools/tools/commonUpload/readImage?imagePath='

// 文件预览下载//根路径+路径
export const readImageRoot = '/bidprocurement/common-tools/tools/commonUpload/readImageRoot?imagePath='
export const readImageRoot2 = '/service-app/common-tools/tools/commonUpload/readImageRoot?imagePath='
