From 7c55881bbdbbc6914a242693628c71faa06aa878 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期五, 17 五月 2024 15:02:20 +0800
Subject: [PATCH] 文件下载
---
src/utils/request.js | 3 ++-
/dev/null | 30 ------------------------------
src/views/onlineStudy/file.vue | 16 +++++++++++++---
src/router.js | 6 ------
4 files changed, 15 insertions(+), 40 deletions(-)
diff --git a/src/components/PDF.vue b/src/components/PDF.vue
deleted file mode 100644
index 48635fb..0000000
--- a/src/components/PDF.vue
+++ /dev/null
@@ -1,30 +0,0 @@
-<template>
- <div>
- <vue-office-pdf :src="pdfUrl" @rendered="rendered" />
- </div>
-</template>
-
-<script>
-import VueOfficePdf from '@vue-office/pdf';
-export default {
- name: "PDF",
- components: { VueOfficePdf },
- data() {
- return {
- pdfUrl: ''
- }
- },
- methods: {
- rendered() {
-
- },
- },
- mounted() {
- this.pdfUrl = this.$route.query.pdfUrl
- }
-}
-</script>
-
-<style scoped>
-
-</style>
diff --git a/src/router.js b/src/router.js
index dafb79e..23690a2 100644
--- a/src/router.js
+++ b/src/router.js
@@ -113,12 +113,6 @@
component: () => import('@/views/onlineStudy/file'),
name: 'File',
meta: { title: '瀛︿範鏂囦欢', noCache: true }
- },
- {
- path: 'pdf/view',
- component: () => import('@/components/PDF'),
- name: 'PDFView',
- meta: { title: 'PDF鏌ョ湅', noCache: true }
}
]
},
diff --git a/src/utils/request.js b/src/utils/request.js
index 9c397ae..eb58593 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -137,5 +137,6 @@
postWithOutLoadTip,
get,
form,
- download
+ download,
+ bestDownload
}
diff --git a/src/views/onlineStudy/file.vue b/src/views/onlineStudy/file.vue
index 609f826..ad90fdf 100644
--- a/src/views/onlineStudy/file.vue
+++ b/src/views/onlineStudy/file.vue
@@ -43,7 +43,7 @@
</el-table-column>
<el-table-column prop="attachment" label="闄勪欢">
<template slot-scope="scope">
- <el-link type="primary" v-for="item in scope.row.attachment">{{ item.name }}</el-link>
+ <el-link type="primary" :href="'/api/upload/download?url=' + item.url +'&fileName=' + item.name" v-for="item in scope.row.attachment" :key="item.url">{{ item.name }}</el-link>
</template>
</el-table-column>
<el-table-column fixed="right" label="鎿嶄綔" width="140">
@@ -94,6 +94,10 @@
<el-button type="primary" @click="handlerSubmit">淇� 瀛�</el-button>
</span>
</el-dialog>
+
+ <el-dialog title="PDF鏌ョ湅" :visible.sync="pdfDialog" width="80%" :before-close="closePdfDialog">
+ <vue-office-pdf :src="pdf" @rendered="rendered" />
+ </el-dialog>
</div>
</template>
@@ -103,9 +107,10 @@
import StudyTypeAPI from '@/api/study-type';
import Upload from '@/components/UploadC';
+import VueOfficePdf from '@vue-office/pdf';
export default {
name: 'type',
- components: { Upload, Pagination },
+ components: { Upload, Pagination, VueOfficePdf },
computed: {
fileContentUrl: () => {
return this.form ? this.form.contentUrl ? [this.form.contentUrl] : [] : [];
@@ -113,6 +118,7 @@
},
data() {
return {
+ pdf: '',
dialogTitle: '娣诲姞瀛︿範鍐呭',
ids: [],
typeList: [],
@@ -151,11 +157,15 @@
},
methods: {
checkPdf(url) {
- window.open('/#/online/study/pdf/view?pdfUrl=' + url, '_blank')
+ this.pdf = url;
+ this.pdfDialog = true;
},
closePdfDialog() {
this.pdfDialog = false;
},
+ rendered() {
+
+ },
fileChange() {
this.form.contentUrl = [];
},
--
Gitblit v1.8.0