mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-07 09:56:45 +08:00
206 lines
4.5 KiB
JavaScript
206 lines
4.5 KiB
JavaScript
// 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;
|
|
|
|
|
|
/**
|
|
* 添加或者编辑
|
|
* @param 参数见设计文档
|
|
* */
|
|
const save=function (data){
|
|
return ajax.postJson(baseURL,'/xboe/subgroup/m/noteinfo/save',data);
|
|
}
|
|
|
|
/**
|
|
* 添加或者编辑
|
|
* @param 参数见设计文档
|
|
* */
|
|
const update=function (data){
|
|
return ajax.postJson(baseURL,'/xboe/subgroup/m/noteinfo/update',data);
|
|
}
|
|
|
|
/**
|
|
* 详情
|
|
* */
|
|
const detail=function (id){
|
|
return ajax.get(baseURL,'/xboe/subgroup/m/noteinfo/detail?id='+id);
|
|
}
|
|
|
|
/**
|
|
* 删除笔记
|
|
* */
|
|
const del=function (id){
|
|
return ajax.get(baseURL,'/xboe/subgroup/m/noteinfo/delete?id='+id);
|
|
}
|
|
|
|
/**
|
|
* 查询课程笔记
|
|
* @param{
|
|
* pageIndex
|
|
* pageSize
|
|
* courseId 课程id
|
|
* openType 公开类型
|
|
* }
|
|
* */
|
|
const coursePage=function (query){
|
|
return ajax.post(baseURL,'/xboe/subgroup/m/noteinfo/course-page',query);
|
|
}
|
|
|
|
/**
|
|
* 查询我的指定课程笔记
|
|
* */
|
|
const myCourse=function (courseId){
|
|
return ajax.get(baseURL,'/xboe/subgroup/m/noteinfo/mycourse?courseId='+courseId);
|
|
}
|
|
|
|
/**
|
|
* 查询笔记的修改历史
|
|
* */
|
|
const history=function (noteId){
|
|
return ajax.get(baseURL,'/xboe/subgroup/m/noteinfo/modify/history?noteId='+noteId);
|
|
}
|
|
|
|
|
|
/**
|
|
* 我的笔记
|
|
* type 我发布的是1 我导入的是2
|
|
* orderType 升序降序
|
|
* orderField排序字段
|
|
* courseId 课程id
|
|
* */
|
|
const query=function (data){
|
|
return ajax.post(baseURL,'/xboe/subgroup/m/noteinfo/query',data);
|
|
}
|
|
|
|
/**
|
|
* 课程列表 应该是当前用户记过笔记的课程
|
|
* */
|
|
const course=function (){
|
|
return ajax.get(baseURL,'/xboe/subgroup/m/noteinfo/course');
|
|
}
|
|
/**
|
|
* 还原
|
|
* 笔记id
|
|
* */
|
|
const restore=function (id){
|
|
return ajax.get(baseURL,'/xboe/subgroup/m/noteinfo/restore?id='+id);
|
|
}
|
|
|
|
/**
|
|
* 二次查询
|
|
* @param{
|
|
* ids
|
|
* }
|
|
* */
|
|
const ids=function (data){
|
|
return ajax.postJson(baseURL,'/xboe/subgroup/m/noteinfo/ids',data);
|
|
}
|
|
|
|
/**
|
|
* 导出excel
|
|
* @param {
|
|
* ids ["",""]
|
|
* }
|
|
* */
|
|
const exportExcel=function (data){
|
|
return ajax.postJsonToFile(baseURL,'/xboe/subgroup/m/noteinfo/exportExcel',data);
|
|
// return ajax.post(baseURL,'/xboe/subgroup/m/noteinfo/exportExcel',data);
|
|
}
|
|
|
|
/**
|
|
* 导出excel预览
|
|
* @param {
|
|
* ids ["",""]
|
|
* }
|
|
* */
|
|
const exportExcelPre=function (data){
|
|
return ajax.post(baseURL,'/xboe/subgroup/m/noteinfo/excel-detail',data);
|
|
}
|
|
|
|
/**
|
|
* 导出pdf预览
|
|
* @param {
|
|
* ids ["",""]
|
|
* }
|
|
* */
|
|
const exportPdfPre=function (data){
|
|
return ajax.post(baseURL,'/xboe/subgroup/m/noteinfo/pdf-detail',data);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
* 导出pdf
|
|
* @param{
|
|
*
|
|
* }
|
|
* */
|
|
const exportPdf=function (udata){
|
|
// return ajax.postJson(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,
|
|
data:udata,
|
|
responseType: 'blob',
|
|
headers: { 'XBOE-Access-Token':getToken(),'Content-Type':'application/pdf;charset=utf-8'}
|
|
}).then(res => {
|
|
//resolveBlob(res, mimeMap.zip);
|
|
console.log(res);
|
|
const aLink = document.createElement('a')
|
|
var blob = new Blob([res.request.response], { 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','我的笔记.pdf') // 设置下载文件名称
|
|
document.body.appendChild(aLink)
|
|
aLink.click()
|
|
document.body.removeChild(aLink)
|
|
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 我的笔记收藏和分享都是这一个,目前只有收藏
|
|
* @param{
|
|
* paegIndex
|
|
* pageSize
|
|
* dataType 1收藏 2分享
|
|
* orderType 排序顺序 顺序倒叙
|
|
* orderField 排序字段
|
|
* keyword 关键字查询
|
|
* }
|
|
* */
|
|
const pagelist=function (query){
|
|
return ajax.post(baseURL,'/xboe/subgroup/m/noteinfo/pagelist',query);
|
|
}
|
|
|
|
export default {
|
|
save,
|
|
detail,
|
|
del,
|
|
coursePage,
|
|
myCourse,
|
|
history,
|
|
pagelist,
|
|
query,
|
|
course,
|
|
update,
|
|
restore,
|
|
ids,
|
|
exportExcel,
|
|
exportPdf,
|
|
exportExcelPre,
|
|
exportPdfPre
|
|
}
|