|
|
|
@ -13,7 +13,7 @@ |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
import { practiceByStudentDetail } from '@/apis/modules/course.js' |
|
|
|
|
import { practiceByStudentDetail, exportExamPaperReport } from '@/apis/modules/course.js' |
|
|
|
|
export default { |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
@ -66,9 +66,107 @@ |
|
|
|
|
this.status = noMore ? 'noMore' : 'more' // 加载完了则设置为noMore |
|
|
|
|
this.reachBottom = noMore ? -1 : 0 // 加载完了则设置为-1 |
|
|
|
|
}, |
|
|
|
|
saveFile(fileData) { |
|
|
|
|
const fs = uni.getFileSystemManager(); |
|
|
|
|
|
|
|
|
|
// 创建临时文件路径 |
|
|
|
|
const tempFilePath = `${uni.env.USER_DATA_PATH}/tempFile`; |
|
|
|
|
console.log('临时文件路径:', uni.env, tempFilePath, fileData) |
|
|
|
|
// 写入文件 |
|
|
|
|
fs.writeFile({ |
|
|
|
|
filePath: tempFilePath, |
|
|
|
|
data: fileData, |
|
|
|
|
encoding: 'binary', // 使用 binary 编码 |
|
|
|
|
success: (res) => { |
|
|
|
|
console.log('文件写入成功', res); |
|
|
|
|
|
|
|
|
|
// 保存文件到本地 |
|
|
|
|
uni.saveFile({ |
|
|
|
|
tempFilePath: tempFilePath, |
|
|
|
|
success: (res) => { |
|
|
|
|
console.log('文件保存成功', res.savedFilePath); |
|
|
|
|
|
|
|
|
|
uni.downloadFile({ |
|
|
|
|
// url: 'https://eduvessel.com/images/occupationlab/ac校赛试卷四.docx', |
|
|
|
|
url: res.savedFilePath, |
|
|
|
|
success: function(res) { |
|
|
|
|
console.log(11, res) |
|
|
|
|
uni.hideLoading(); |
|
|
|
|
uni.showLoading({ |
|
|
|
|
title: '正在打开', |
|
|
|
|
mask: true |
|
|
|
|
}) |
|
|
|
|
// 新开页面打开文档,支持格式:doc, xls, ppt, pdf, docx, xlsx, pptx。 |
|
|
|
|
uni.openDocument({ |
|
|
|
|
filePath: res.tempFilePath, |
|
|
|
|
fileType: 'docx', // 文件类型,指定文件类型打开文件,有效值 doc, xls, ppt, pdf, docx, xlsx, pptx |
|
|
|
|
showMenu: true, // 允许出现分享功能 |
|
|
|
|
success: res => { |
|
|
|
|
uni.hideLoading() |
|
|
|
|
}, |
|
|
|
|
fail: openError => { |
|
|
|
|
uni.hideLoading() |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
fail: function(err) { |
|
|
|
|
uni.hideLoading() |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
fail: (err) => { |
|
|
|
|
console.error('文件保存失败', err); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
fail: (err) => { |
|
|
|
|
console.error('文件写入失败', err); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
// 跳转 |
|
|
|
|
toDetail(row) { |
|
|
|
|
// this.$util.to(path) |
|
|
|
|
async toDetail(row) { |
|
|
|
|
uni.showLoading({ |
|
|
|
|
title: '加载中', |
|
|
|
|
mask: true |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
const res = await exportExamPaperReport({ |
|
|
|
|
reportId: row.reportId |
|
|
|
|
}) |
|
|
|
|
this.saveFile(res) |
|
|
|
|
|
|
|
|
|
return |
|
|
|
|
// 下载文件资源到本地 |
|
|
|
|
uni.downloadFile({ |
|
|
|
|
url: 'https://eduvessel.com/images/occupationlab/ac校赛试卷四.docx', |
|
|
|
|
success: function(res) { |
|
|
|
|
console.log(11, res) |
|
|
|
|
uni.hideLoading(); |
|
|
|
|
uni.showLoading({ |
|
|
|
|
title: '正在打开', |
|
|
|
|
mask: true |
|
|
|
|
}) |
|
|
|
|
// 新开页面打开文档,支持格式:doc, xls, ppt, pdf, docx, xlsx, pptx。 |
|
|
|
|
uni.openDocument({ |
|
|
|
|
filePath: res.tempFilePath, |
|
|
|
|
fileType: 'docx', // 文件类型,指定文件类型打开文件,有效值 doc, xls, ppt, pdf, docx, xlsx, pptx |
|
|
|
|
showMenu: true, // 允许出现分享功能 |
|
|
|
|
success: res => { |
|
|
|
|
uni.hideLoading() |
|
|
|
|
}, |
|
|
|
|
fail: openError => { |
|
|
|
|
uni.hideLoading() |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
fail: function(err) { |
|
|
|
|
uni.hideLoading() |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -83,7 +181,9 @@ |
|
|
|
|
.item { |
|
|
|
|
position: relative; |
|
|
|
|
padding: 20rpx 0; |
|
|
|
|
border-bottom: 1px solid #e6e6e6; |
|
|
|
|
&:not(:last-child) { |
|
|
|
|
border-bottom: 1px solid #e6e6e6; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.c-name { |
|
|
|
|
font-size: 32rpx; |
|
|
|
|