qx
2025-03-26 155a30a172e4cf04838dcf7c8bb73ce6b200e574
src/utils/request.js
@@ -6,12 +6,14 @@
import { tansParams, blobValidate } from "@/utils/ruoyi";
import cache from '@/plugins/cache'
import { saveAs } from 'file-saver'
import Cookies from "js-cookie"
let downloadLoadingInstance;
// 是否显示重新登录
export let isRelogin = { show: false };
axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
// 创建axios实例
const service = axios.create({
  // axios中请求配置有baseURL选项,表示请求URL公共部分
@@ -26,6 +28,7 @@
  const isRepeatSubmit = (config.headers || {}).repeatSubmit === false
  if (getToken() && !isToken) {
    config.headers['Authorization'] = 'Bearer ' + getToken()
    config.headers['hospId'] = Cookies.get("hospId");
  }
  if (config.method === 'get' && config.params) {
    let url = config.url + '?' + tansParams(config.params);
@@ -59,6 +62,12 @@
  Promise.reject(error)
})
// 需要确认框的接口路径
const confirmDialogUrls = [
  '/hosp/order/addtTransition',
  '/hosp/customer/cusIdcard'
];
// 响应拦截器
service.interceptors.response.use(res => {
  const code = res.data.code || 200;
@@ -84,17 +93,13 @@
    }
    return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
  } else if (code === 500) {
    if (res.config.url === '/hosp/order/addtTransition') {
    if (confirmDialogUrls.includes(res.config.url)) {
      // 使用MessageBox和Message来替代this.$confirm和this.$message
      MessageBox.confirm(res.data.msg, '提示', {
      MessageBox.confirm(res.data.msg, {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        center: true
      }).then(() => {
      }).catch(() => {
        type: 'error',
        showCancelButton: false,
        closeOnClickModal: false
      });
      return Promise.reject('特定接口发生500错误');
    }