Commit 3788401c authored by yf's avatar yf

修改通用下载方法,新增导出

parent 1a476940
......@@ -73,7 +73,7 @@ service.interceptors.response.use(res => {
const msg = errorCode[code] || res.data.msg || errorCode['default']
// 二进制数据则直接返回
if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') {
return res.data
return res
}
if (code === 401) {
if (!isRelogin.show) {
......@@ -100,7 +100,7 @@ service.interceptors.response.use(res => {
} else {
return res.data
}
},
},
error => {
console.log('err' + error)
let { message } = error;
......@@ -124,7 +124,12 @@ export function download(url, params, filename, config) {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
responseType: 'blob',
...config
}).then(async (data) => {
}).then(async (response) => {
var data = response.data;
if (!filename) {
filename = decodeURIComponent(response.headers["content-disposition"].split(';')[1].split('filename=')[1]);
console.log(filename);
}
const isBlob = blobValidate(data);
if (isBlob) {
const blob = new Blob([data])
......
......@@ -85,7 +85,11 @@
>
</el-form-item>
</el-form> -->
<el-button
style="margin-bottom: 10px"
@click="downList(InfoList.detailsDto.id)"
>导 出</el-button
>
<el-table v-loading="loading" :data="listList">
<!-- <el-table-column type="selection" width="55" align="center" /> -->
<el-table-column type="index" width="50" />
......@@ -173,7 +177,7 @@
<el-table-column label="所属建筑" align="center" prop="name" />
<el-table-column label="所属承租户" align="center" prop="type" />
<el-table-column label="操作" align="center" prop="describe">
<template slot-scope="scope">
<template>
<div>
<el-button size="mini" type="text" icon="el-icon-download"
>下载</el-button
......@@ -252,6 +256,9 @@ export default {
this.getRiskList(this.$route.params.id);
},
methods: {
downList(planId) {
this.download("/system/risk/plan/exportExcel/InherentList/" + planId, {});
},
showDrawCanvas(floorId) {
this.$router.push({
name: "drawCanvas",
......@@ -273,11 +280,7 @@ export default {
},
exportList(id) {
console.log(id, "kkkk");
this.download(
"system/risk/plan/exportWord/riskNotification/" + id,
{},
`风险告知卡.docx`
);
this.download("system/risk/plan/exportWord/riskNotification/" + id, {});
},
},
handleClick() {},
......
......@@ -35,7 +35,7 @@ module.exports = {
proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API]: {
target: `http://192.168.4.232:8080`, //服务器地址
target: `http://localhost:8080`, //服务器地址
// target: `http://192.168.15.230:8081`, //晓晋本地地址
changeOrigin: true,
pathRewrite: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment