mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-12 12:26:44 +08:00
笔记导出功能
This commit is contained in:
@@ -183,6 +183,7 @@ const putJson=function(baseURL,url,data){
|
||||
|
||||
|
||||
export default {
|
||||
tokenName:TokenName,
|
||||
request,
|
||||
get,
|
||||
post,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// import ajax from '@/utils/xajax.js'
|
||||
// import ajax from '../cesource/index.js';
|
||||
import axios from 'axios'
|
||||
import { getToken } from '@/utils/token'
|
||||
import ajax from '../ajax';
|
||||
const baseURL = process.env.VUE_APP_CESOURCE_BASE_API;
|
||||
|
||||
@@ -140,7 +142,29 @@ const exportPdfPre=function (data){
|
||||
* */
|
||||
const exportPdf=function (data){
|
||||
// return ajax.postJson(baseURL,'/xboe/subgroup/m/noteinfo/exportPdf',data);
|
||||
return ajax.post(baseURL,'/xboe/subgroup/m/noteinfo/exportPdf',data);
|
||||
//return ajax.post(baseURL,'/xboe/subgroup/m/noteinfo/exportPdf',data);
|
||||
var url = baseURL + '/xboe/subgroup/m/noteinfo/exportPdf';
|
||||
axios({
|
||||
method: 'post',
|
||||
url: url,
|
||||
responseType: 'blob',
|
||||
headers: { 'XBOE-Access-Token':getToken() }
|
||||
}).then(res => {
|
||||
//resolveBlob(res, mimeMap.zip);
|
||||
const aLink = document.createElement('a')
|
||||
var blob = new Blob([res], { type: 'application/pdf' })
|
||||
// //从response的headers中获取filename, 后端response.setHeader("Content-disposition", "attachment; filename=xxxx.docx") 设置的文件名;
|
||||
var patt = new RegExp('filename=([^;]+\\.[^\\.;]+);*')
|
||||
var contentDisposition = decodeURI(res.headers['content-disposition'])
|
||||
var result = patt.exec(contentDisposition)
|
||||
var fileName = result[1]
|
||||
fileName = fileName.replace(/\"/g, '')
|
||||
aLink.href = URL.createObjectURL(blob)
|
||||
aLink.setAttribute('download',fileName) // 设置下载文件名称
|
||||
document.body.appendChild(aLink)
|
||||
aLink.click()
|
||||
document.body.appendChild(aLink)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,7 +179,7 @@ const exportPdf=function (data){
|
||||
* }
|
||||
* */
|
||||
const pagelist=function (query){
|
||||
return ajax.post('/xboe/subgroup/m/noteinfo/pagelist',query);
|
||||
return ajax.post(baseURL,'/xboe/subgroup/m/noteinfo/pagelist',query);
|
||||
}
|
||||
|
||||
export default {
|
||||
|
||||
Reference in New Issue
Block a user