mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-13 04:46:44 +08:00
笔记导出功能
This commit is contained in:
@@ -22,7 +22,7 @@ VUE_APP_BOE_WEB_URL = 'http://192.168.0.11'
|
|||||||
VUE_APP_BOE_MOBILE_URL = 'http://192.168.0.11:8082/mobile'
|
VUE_APP_BOE_MOBILE_URL = 'http://192.168.0.11:8082/mobile'
|
||||||
|
|
||||||
# File路径的基础url
|
# File路径的基础url
|
||||||
VUE_APP_FILE_BASE_URL = 'http://192.168.0.11:9090/cdn/upload'
|
VUE_APP_FILE_BASE_URL = 'http://192.168.0.11:9080/cdn/upload'
|
||||||
|
|
||||||
# File路径的基础url的相对路径,加此项是为了不影响之前的路径配置
|
# File路径的基础url的相对路径,加此项是为了不影响之前的路径配置
|
||||||
VUE_APP_FILE_RELATIVE_PATH = '/upload'
|
VUE_APP_FILE_RELATIVE_PATH = '/upload'
|
||||||
|
|||||||
@@ -183,6 +183,7 @@ const putJson=function(baseURL,url,data){
|
|||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
tokenName:TokenName,
|
||||||
request,
|
request,
|
||||||
get,
|
get,
|
||||||
post,
|
post,
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
// import ajax from '@/utils/xajax.js'
|
// import ajax from '@/utils/xajax.js'
|
||||||
// import ajax from '../cesource/index.js';
|
// import ajax from '../cesource/index.js';
|
||||||
|
import axios from 'axios'
|
||||||
|
import { getToken } from '@/utils/token'
|
||||||
import ajax from '../ajax';
|
import ajax from '../ajax';
|
||||||
const baseURL = process.env.VUE_APP_CESOURCE_BASE_API;
|
const baseURL = process.env.VUE_APP_CESOURCE_BASE_API;
|
||||||
|
|
||||||
@@ -140,7 +142,29 @@ const exportPdfPre=function (data){
|
|||||||
* */
|
* */
|
||||||
const exportPdf=function (data){
|
const exportPdf=function (data){
|
||||||
// return ajax.postJson(baseURL,'/xboe/subgroup/m/noteinfo/exportPdf',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){
|
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 {
|
export default {
|
||||||
|
|||||||
@@ -153,7 +153,7 @@
|
|||||||
<div class="all-content">
|
<div class="all-content">
|
||||||
<span v-if="item.contentType != 3">{{ item.content }}</span>
|
<span v-if="item.contentType != 3">{{ item.content }}</span>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<template v-for="img in item.content">
|
<template v-for="img in item.imgList">
|
||||||
<img style="max-height:145px;max-width:140px" :src="fileBaseUrl + img" alt=""/>
|
<img style="max-height:145px;max-width:140px" :src="fileBaseUrl + img" alt=""/>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
@@ -227,7 +227,7 @@ export default {
|
|||||||
startTime:'',
|
startTime:'',
|
||||||
endTime:'',
|
endTime:'',
|
||||||
datalist:[ ],
|
datalist:[ ],
|
||||||
exportPreData:[ ],
|
exportPreData:[],
|
||||||
thu:true,
|
thu:true,
|
||||||
couresna:[],
|
couresna:[],
|
||||||
courseName:'',
|
courseName:'',
|
||||||
@@ -268,11 +268,19 @@ export default {
|
|||||||
this.$message.warning('未查询到满足条件的数据')
|
this.$message.warning('未查询到满足条件的数据')
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.exportPreData = res.result.data;
|
|
||||||
if(res.result.isImage && e == 2){
|
if(res.result.isImage && e == 2){
|
||||||
this.$message.warning('当前筛选条件下含图片类内容,无法导出Excel!')
|
this.$message.warning('当前筛选条件下含图片类内容,无法导出Excel!')
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
res.result.data.forEach((item)=>{
|
||||||
|
if(item.contentType==3){
|
||||||
|
item.imgList=item.content.split(',');
|
||||||
|
}else{
|
||||||
|
item.imgList=[];
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.exportPreData = res.result.data;
|
||||||
this.dialogVisible = true;
|
this.dialogVisible = true;
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -295,23 +303,24 @@ export default {
|
|||||||
author:this.userData.avatar,//this.userInfo.avatar,
|
author:this.userData.avatar,//this.userInfo.avatar,
|
||||||
}
|
}
|
||||||
if(this.exportType == '1') {
|
if(this.exportType == '1') {
|
||||||
apiNote.exportPdf(data).then(res=>{
|
apiNote.exportPdf(data);
|
||||||
if(res.status) {
|
// apiNote.exportPdf(data).then(res=>{
|
||||||
this.$message.error('导出失败');
|
// if(res.status) {
|
||||||
} else {
|
// this.$message.error('导出失败');
|
||||||
const link = document.createElement('a');// 创建a标签
|
// } else {
|
||||||
// let blob = new Blob([res],{type: 'application/vnd.ms-pdf;charset=UTF-8'}); // 设置文件类型
|
// const link = document.createElement('a');// 创建a标签
|
||||||
let blob = new Blob([res],{type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'}); // 设置文件类型
|
// // let blob = new Blob([res],{type: 'application/vnd.ms-pdf;charset=UTF-8'}); // 设置文件类型
|
||||||
link.style.display = "none";
|
// let blob = new Blob([res],{type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'}); // 设置文件类型
|
||||||
link.href = URL.createObjectURL(blob); // 创建URL
|
// link.style.display = "none";
|
||||||
link.setAttribute("download", "我的笔记.pdf");
|
// link.href = URL.createObjectURL(blob); // 创建URL
|
||||||
document.body.appendChild(link);
|
// link.setAttribute("download", "我的笔记.pdf");
|
||||||
link.click();
|
// document.body.appendChild(link);
|
||||||
document.body.removeChild(link);
|
// link.click();
|
||||||
this.dialogVisible = false;
|
// document.body.removeChild(link);
|
||||||
}
|
// this.dialogVisible = false;
|
||||||
|
// }
|
||||||
|
|
||||||
})
|
// })
|
||||||
} else {
|
} else {
|
||||||
let data = {
|
let data = {
|
||||||
orderType:this.orderType,
|
orderType:this.orderType,
|
||||||
|
|||||||
Reference in New Issue
Block a user