|
@@ -18,11 +18,11 @@
|
|
|
{{ item.papername }}
|
|
|
</div>
|
|
|
<div class="center_opera">
|
|
|
- <div class="view" @click="toPreView(item.id, item.papername)">
|
|
|
+ <div class="view" @click="toPreView(item)">
|
|
|
<img src="@/assets/images/icon_view.png" alt=""/>
|
|
|
<span>预览</span>
|
|
|
</div>
|
|
|
- <div class="download" @click="paperDownLoad(item.id)">
|
|
|
+ <div class="download" @click="paperDownLoad(item)">
|
|
|
<span>下载</span>
|
|
|
</div>
|
|
|
<div class="shoucan">
|
|
@@ -59,6 +59,8 @@ import { downloadRealPaper, paperGrade, papersCancelCollect, papersCollect, pape
|
|
|
import { mapGetters } from 'vuex'
|
|
|
import MxCondition from '@/components/MxCondition/mx-condition'
|
|
|
import MxSearchGroup from '@/components/MxSearch/mx-search-group'
|
|
|
+import MxConst from "@/common/MxConst";
|
|
|
+import {downloadOssFile} from "@/utils/download-helper";
|
|
|
|
|
|
export default {
|
|
|
name: 'famous-paper',
|
|
@@ -91,11 +93,38 @@ export default {
|
|
|
...mapGetters(['period', 'isFrontTeacher'])
|
|
|
},
|
|
|
methods: {
|
|
|
- paperDownLoad(paperId) {
|
|
|
+ _combineOssPath(item) {
|
|
|
+ const {osspath, filename} = item
|
|
|
+ return `${this.$ossBase}/${osspath}/${filename}`
|
|
|
+ },
|
|
|
+ _ossPreview(url) {
|
|
|
+ const pdfSuffixes = ['.pdf']
|
|
|
+ const msSuffixes = ['.doc','.ppt','.xls','.docx', 'pptx', '.xlsx']
|
|
|
+ if (pdfSuffixes.some(s => url.endsWith(s))) {
|
|
|
+ window.open('/pdfView/index.html?src=' + url)
|
|
|
+ } else if (msSuffixes.some(s => url.endsWith(s))) {
|
|
|
+ window.open('https://view.officeapps.live.com/op/view.aspx?src=' + url)
|
|
|
+ } else {
|
|
|
+ this.$message.error('格式错误,无法预览该格式文件!');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ paperDownLoad(item) {
|
|
|
+ const {id: paperId, paperSource, filename} = item
|
|
|
+ if (paperSource == MxConst.enum.paper.paperSource.oss) {
|
|
|
+ const ossFullPath = this._combineOssPath(item)
|
|
|
+ downloadOssFile(ossFullPath, filename)
|
|
|
+ return
|
|
|
+ }
|
|
|
downloadRealPaper(paperId, this.period)
|
|
|
},
|
|
|
// 跳转到预览页面
|
|
|
- toPreView(paperId, paperName) {
|
|
|
+ toPreView(item) {
|
|
|
+ const {id: paperId, papername: paperName, paperSource} = item
|
|
|
+ if (paperSource == MxConst.enum.paper.paperSource.oss) {
|
|
|
+ const ossFullPath = this._combineOssPath(item)
|
|
|
+ this._ossPreview(ossFullPath)
|
|
|
+ return
|
|
|
+ }
|
|
|
this.$router.push({
|
|
|
path: '/question-center/bestPaper/preview',
|
|
|
query: { paperId, paperName }
|