ZhangXianQiang
2024-05-24 2bddfa78e65f351d6cb81f670775e79620f684a6
src/utils/request.js
@@ -99,15 +99,57 @@
    withCredentials: true,
    timeout: 30000,
    data: params,
    headers: { 'Content-Type': 'multipart/form-data', 'request-ajax': true }
    responseType: 'blob', // 关键
    headers: { 'Content-Type': 'application/vnd.ms-excel' }// 类型修改为excel
  }
  return request(false, query)
}
const download = function (url, params) {
  const query = {
    baseURL: process.env.VUE_APP_URL,
    url: url,
    method: 'get',
    withCredentials: true,
    timeout: 300000,
    params: params,
    responseType: 'blob', // 关键
    headers: { 'Content-Type': 'application/vnd.ms-excel' }// 类型修改为excel
  }
  return request(false, query)
}
const downloadPost = function (url, params) {
  const query = {
    baseURL: process.env.VUE_APP_URL,
    url: url,
    method: 'post',
    withCredentials: true,
    timeout: 300000,
    data: params,
    responseType: 'blob' // 关键
  }
  return request(false, query)
}
export const down = function (url, params) {
  const query = {
    baseURL: process.env.VUE_APP_URL,
    url: url,
    method: 'get',
    withCredentials: true,
    timeout: 30000,
    data: params,
    headers: { responseType: 'blob', 'Content-Type': 'multipart/form-data', 'request-ajax': true }
  }
  return request(false, query)
}
export {
  post,
  postWithLoadTip,
  postWithOutLoadTip,
  get,
  form
  form,
  download,
  downloadPost
}