This commit is contained in:
parent
9fab544136
commit
724653b5fa
|
@ -2,7 +2,7 @@ import axios from "axios";
|
|||
import { ElMessage } from "element-plus";
|
||||
import tools from "@/utils/tools";
|
||||
import router from "../router";
|
||||
axios.defaults.baseURL = 'https://jzzf.longyou.gov.cn:998/'
|
||||
// axios.defaults.baseURL = 'https://jzzf.longyou.gov.cn:998/'
|
||||
axios.defaults.timeout = 120000;
|
||||
|
||||
// HTTP request 拦截器
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
import axios from "axios";
|
||||
import { useLoadingStore } from "@/stores/loading.js";
|
||||
import { ElMessage } from "element-plus";
|
||||
|
||||
var tool = {}
|
||||
var tool = {};
|
||||
|
||||
/* localStorage */
|
||||
tool.data = {
|
||||
set(table, settings) {
|
||||
var _set = JSON.stringify(settings)
|
||||
var _set = JSON.stringify(settings);
|
||||
return localStorage.setItem(table, _set);
|
||||
},
|
||||
get(table) {
|
||||
var data = localStorage.getItem(table);
|
||||
try {
|
||||
data = JSON.parse(data)
|
||||
data = JSON.parse(data);
|
||||
} catch (err) {
|
||||
return null
|
||||
return null;
|
||||
}
|
||||
return data;
|
||||
},
|
||||
|
@ -23,17 +24,17 @@ tool.data = {
|
|||
},
|
||||
clear() {
|
||||
return localStorage.clear();
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
tool.url = function (url, params) {
|
||||
var hasParams = url.indexOf("?") > 0;
|
||||
for (var key in params) {
|
||||
url = url + (hasParams ? '&' : '?') + key + '=' + params[key];
|
||||
url = url + (hasParams ? "&" : "?") + key + "=" + params[key];
|
||||
hasParams = true;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
};
|
||||
|
||||
// 文件下载(token放请求头中)
|
||||
tool.downloadFile = (url, params) => {
|
||||
|
@ -43,10 +44,11 @@ tool.downloadFile = (url,params) => {
|
|||
axios
|
||||
.get(url, {
|
||||
headers: { token: JSON.parse(localStorage.getItem("token")) },
|
||||
responseType: "blob",
|
||||
params
|
||||
// responseType: "blob",
|
||||
params,
|
||||
})
|
||||
.then((response) => {
|
||||
if (!response.data.code) {
|
||||
let blob = new Blob([response.data], {
|
||||
//这里的type要和后端一致
|
||||
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
|
@ -63,6 +65,13 @@ tool.downloadFile = (url,params) => {
|
|||
a.click();
|
||||
window.URL.revokeObjectURL(Url);
|
||||
store.isLoading = false;
|
||||
} else {
|
||||
console.log(response.data);
|
||||
store.isLoading = false;
|
||||
ElMessage.warning({
|
||||
message: response.data.message,
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err, "err");
|
||||
|
@ -70,6 +79,4 @@ tool.downloadFile = (url,params) => {
|
|||
});
|
||||
};
|
||||
|
||||
|
||||
export default tool
|
||||
|
||||
export default tool;
|
||||
|
|
|
@ -206,7 +206,7 @@
|
|||
@current-change="handlePagination"
|
||||
/>
|
||||
</div>
|
||||
<el-popconfirm title="是否确定导出Excel?" @confirm="toExcel(1)">
|
||||
<el-popconfirm title="是否确定导出Excel?" @confirm="toExcel()">
|
||||
<template #reference>
|
||||
<el-button type="info" plain style="margin-left: 24px"
|
||||
>导出Excel</el-button
|
||||
|
|
Loading…
Reference in New Issue