字典新增批量查询

This commit is contained in:
不做码农
2021-12-12 21:03:28 +08:00
parent 4d373da260
commit ac22a0e922
12 changed files with 145 additions and 23 deletions

View File

@@ -1,13 +1,10 @@
import axios from 'axios'
import {
MessageBox,
Message
} from 'element-ui'
import { MessageBox, Message } from 'element-ui'
import store from '@/store'
import {
getToken
} from '@/utils/auth'
import { getToken } from '@/utils/auth'
// import { blobValidate } from "@/utils/ruoyi";
// import errorCode from '@/utils/errorCode'
// import { saveAs } from 'file-saver'
// 解决后端跨域获取不到cookie问题
axios.defaults.withCredentials = true
@@ -44,7 +41,10 @@ service.interceptors.response.use(res => {
}
// 未设置状态码则默认成功状态
const { code, msg } = res.data;
// 二进制数据则直接返回
if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') {
return res.data
}
if (code == 401) {
MessageBox.confirm('登录状态已过期,请重新登录', '系统提示', {
confirmButtonText: '重新登录',
@@ -138,4 +138,32 @@ export function postForm(url, data, config) {
})
})
}
// 通用下载方法
// export function download(url, params, filename) {
// //downloadLoadingInstance = Loading.service({ text: "正在下载数据,请稍候", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", })
// return service.post(url, params, {
// //transformRequest: [(params) => { return tansParams(params) }],
// headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
// responseType: 'blob'
// }).then(async (data) => {
// const isLogin = await blobValidate(data);
// if (isLogin) {
// const blob = new Blob([data])
// saveAs(blob, filename)
// } else {
// const resText = await data.text();
// const rspObj = JSON.parse(resText);
// const errMsg = "出錯了";// errorCode[rspObj.code] || rspObj.msg || errorCode['default']
// Message.error(errMsg);
// }
// // downloadLoadingInstance.close();
// }).catch((r) => {
// console.error(r)
// Message.error('下载文件出现错误,请联系管理员!')
// // downloadLoadingInstance.close();
// })
// }
export default service