update 适配 ruoyi 关于优化导出数据操作

This commit is contained in:
疯狂的狮子li
2021-11-17 19:42:14 +08:00
parent 64add90edd
commit 2781655b0a
12 changed files with 14 additions and 68 deletions

View File

@ -7,46 +7,6 @@ import { blobValidate } from "@/utils/ruoyi";
const baseURL = process.env.VUE_APP_BASE_API
export default {
excel(url, params) {
// get请求映射params参数
if (params) {
let urlparams = url + '?';
for (const propName of Object.keys(params)) {
const value = params[propName];
var part = encodeURIComponent(propName) + "=";
if (value !== null && typeof(value) !== "undefined") {
if (typeof value === 'object') {
for (const key of Object.keys(value)) {
if (value[key] !== null && typeof (value[key]) !== 'undefined') {
let params = propName + '[' + key + ']';
let subPart = encodeURIComponent(params) + '=';
urlparams += subPart + encodeURIComponent(value[key]) + '&';
}
}
} else {
urlparams += part + encodeURIComponent(value) + "&";
}
}
}
urlparams = urlparams.slice(0, -1);
url = urlparams;
}
url = baseURL + url
axios({
method: 'get',
url: url,
responseType: 'blob',
headers: { 'Authorization': 'Bearer ' + getToken() }
}).then(async (res) => {
const isLogin = await this.blobValidate(res.data);
if (isLogin) {
const blob = new Blob([res.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })
this.saveAs(blob, decodeURI(res.headers['download-filename']))
} else {
Message.error('无效的会话,或者会话已过期,请重新登录。');
}
})
},
oss(ossId) {
var url = baseURL + '/system/oss/download/' + ossId
axios({
@ -55,7 +15,7 @@ export default {
responseType: 'blob',
headers: { 'Authorization': 'Bearer ' + getToken() }
}).then(async (res) => {
const isLogin = await this.blobValidate(res.data);
const isLogin = await blobValidate(res.data);
if (isLogin) {
const blob = new Blob([res.data], { type: 'application/octet-stream' })
this.saveAs(blob, decodeURI(res.headers['download-filename']))

View File

@ -138,19 +138,6 @@ export const constantRoutes = [
}
]
},
{
path: '/monitor/job-log',
component: Layout,
hidden: true,
children: [
{
path: 'index',
component: (resolve) => require(['@/views/monitor/job/log'], resolve),
name: 'JobLog',
meta: { title: '调度日志', activeMenu: '/monitor/job'}
}
]
},
{
path: '/tool/gen-edit',
component: Layout,

View File

@ -77,7 +77,6 @@
plain
icon="el-icon-download"
size="mini"
:loading="exportLoading"
@click="handleExport"
v-hasPermi="['demo:demo:export']"
>导出</el-button>
@ -181,8 +180,6 @@ export default {
buttonLoading: false,
// 遮罩层
loading: true,
// 导出遮罩层
exportLoading: false,
// 选中数组
ids: [],
// 非单个禁用
@ -358,7 +355,9 @@ export default {
},
/** 导出按钮操作 */
handleExport() {
this.$download.excel('/demo/demo/export', this.queryParams);
this.download('demo/demo/export', {
...this.queryParams
}, `demo_${new Date().getTime()}.xlsx`)
}
}
};