Jelajahi Sumber

word预览改为office在线预览

我还能继续跑 4 bulan lalu
induk
melakukan
0d36b1c7b9

+ 9 - 0
src/views/work/score/index.vue

@@ -169,7 +169,12 @@
                     <el-divider />
                     <el-scrollbar v-if="file.manuscriptAndMaterial!==''"
                                   style="max-width: 850px;max-height: 1000px;overflow-y: auto;">
+                      <div v-if="file.manuscriptAndMaterial.substring(file.manuscriptAndMaterial.lastIndexOf('.') + 1, file.manuscriptAndMaterial.length)==='pdf'">
                       <VueOfficePdf :src="file.manuscriptAndMaterial" style="height: 670px"/>
+                      </div>
+                      <div v-if="file.manuscriptAndMaterial.substring(file.manuscriptAndMaterial.lastIndexOf('.') + 1, file.manuscriptAndMaterial.length)==='doc' ||file.manuscriptAndMaterial.substring(file.manuscriptAndMaterial.lastIndexOf('.') + 1, file.manuscriptAndMaterial.length)==='docx'">
+                        <iframe :src="yulanData.yulandz+file.manuscriptAndMaterial" width="100%" height="670px"></iframe>
+                      </div>
                     </el-scrollbar>
                   </el-card>
                   <br/>
@@ -472,6 +477,10 @@ const formLoading = ref(false) // 表单的加载中:1)修改时的数据加
 const formData = ref({
   score: ''
 })
+//定义一个word预览地址
+const yulanData = ref({
+  yulandz: 'https://view.officeapps.live.com/op/view.aspx?src='
+})
 const formRules = reactive({})
 
 /** 返回开始评分界面 */

+ 7 - 10
src/views/work/work/index.vue

@@ -240,12 +240,11 @@
         <VueOfficePddf :src="video.url" class="docx-class"/>
       </div>
         <div v-if="video.format==='docx'" style="width:90%;height: 80%;margin: auto">
-        <VueOfficeDocx :src="video.url"/>
-      </div>
-      <div v-if="video.format==='doc'" style="width:90%;height: 800px;margin: auto">
-        <VueOfficeDoc :src="video.url" class="docx-class"/>
+<!--        <VueOfficeDocx :src="video.url"/>-->
+        <iframe :src="video.url" width="100%" height="500px"></iframe>
+        </div>
+      <div v-if="video.format==='doc'" style="width:90%;height:80%;margin: auto">
         <iframe :src="video.url" width="100%" height="500px"></iframe>
-        <doc-viewer :src="video.url"/>
       </div>
     </div>
 
@@ -264,8 +263,6 @@ import {ref} from 'vue'
 //引入VueOfficePdf组件
 import VueOfficePddf from '@vue-office/pdf'
 import VueOfficeDocx from '@vue-office/docx'
-// import DocViewer from 'vue-doc';
-// import * as DOC from 'doc';
 
 const opt = [
   {
@@ -394,9 +391,9 @@ const selectFile2 = (scope) => {
   video.value.url =scope.row.manuscriptAndMaterial;
   const index = video.value.url.lastIndexOf(".")
   video.value.format  = video.value.url.substring(index + 1, video.value.url.length)
-  video.value.url=`https://view.officeapps.live.com/op/embed.aspx?src=${encodeURIComponent(
-    video.value.url
-  )}`
+  if(video.value.format==='doc'||video.value.format==='docx'){
+    video.value.url="https://view.officeapps.live.com/op/view.aspx?src="+video.value.url
+  }
   // alert(video.value.format)
   // video.value.format = "docx"
 }

+ 1 - 1
src/views/work/work/workForm.vue

@@ -86,7 +86,7 @@
           <i class="el-icon-upload"></i>
           <div class="el-upload__text" style="width: 300px">
             {{
-              formData.manuscriptAndMaterial ? formData.manuscriptAndMaterial : '文稿材料(请上传pdf文件)'
+              formData.manuscriptAndMaterial ? formData.manuscriptAndMaterial : '文稿材料(请上传pdf、doc或docx文件)'
             }}
           </div>
         </el-upload>