yuanyiming 2 роки тому
батько
коміт
1a69c07fcc
1 змінених файлів з 55 додано та 22 видалено
  1. 55 22
      src/views/firm.vue

+ 55 - 22
src/views/firm.vue

@@ -68,7 +68,7 @@
                 type="primary"
                 class="bt1"
                 size="mini"
-                @click="checkFile(scope.row.startFile.url)"
+                @click="checkFileType(scope.row.startFile.url)"
                 >查看信息</el-button
               >
               <el-button
@@ -122,10 +122,23 @@
       <div class="addDialogLogo">LOGO</div>
       <div class="showFileArea">
         <!-- <vpdf v-if="/^\s*$/g.test(showFileUrl)&&showFileUrl.split('.')[showFileUrl.split('.').length-1]=='pdf'" :pdfUrl="showFileUrl"></vpdf> -->
-        <vword v-if="showFileType == 0" :pdfUrl="showFileUrl"></vword>
+        <!-- <vword v-if="showFileType == 0" :pdfUrl="showFileUrl"></vword> -->
         <!-- <vpdf v-else :pdfUrl="showFileUrl"></vpdf> -->
-        <vpdf  v-if="showFileType == 1" :pdfUrl="showFileUrl"></vpdf>
-        <img v-if="showFileType == 2" :src="showFileUrl" style="width: auto;height: auto;max-width: 100%;max-height: 100%;" alt="">
+        <!-- <vpdf  v-if="showFileType == 1" :pdfUrl="showFileUrl"></vpdf> -->
+        <!-- <img v-if="showFileType == 2" :src="showFileUrl" style="width: auto;height: auto;max-width: 100%;max-height: 100%;" alt=""> -->
+        <vword
+            style="width: 100%; height: 100%; overflow: auto"
+            class="fullStyle"
+            v-if="Wordss['type']!='pdf' && Wordss['name']!='图片'"
+            :pdfUrl="'https://view.officeapps.live.com/op/view.aspx?src='+showFileUrl"
+        ></vword>
+        <vpdf
+            style="width: 100%; height: 100%; overflow: auto"
+            class="fullStyle"
+            :pdfUrl="showFileUrl"
+            v-if="Wordss['type']=='pdf'"
+        ></vpdf>
+        <img :src="showFileUrl" alt="图片哦" v-if="Wordss['name']=='图片'" style="width: auto;height: auto;max-width: 100%;max-height: 100%;">
       </div>
     </el-dialog>
     <!-- 展示文档结束 -->
@@ -157,31 +170,51 @@ export default {
       progress:{
         value:50,
         show:false
-      }
+      },
+      ProjectEndLookFile:{url:"",type:""},
+      Wordss:{type:"",name:""},
+      canonical:{
+          Image:/^https?:\/\/(.+\/)+.+(\.(gif|png|jpg|jpeg|webp|svg|psd|bmp|tif))$/i,
+          File:/^https?:\/\/(.+\/)+.+(\.(docx|xlsx|ppt|pdf))$/i
+      },
     };
   },
   methods: {
     //展示文件
-    checkFile(url) {
-    
-      if (url.split(".")[url.split(".").length - 1].toLocaleUpperCase() == "PDF") {
-          this.showFileUrl = url;
-          this.showFileType = 1;
-        }
-      // else {
-      //   this.showFileUrl =
-      //     "https://view.officeapps.live.com/op/view.aspx?src=" + url;
+    checkFileType(url) {
+    // console.log(url);
+      // if (url.split(".")[url.split(".").length - 1].toLocaleUpperCase() == "PDF") {
+    this.showFileUrl = url;
+      //     this.showFileType = 1;
+      //   }
+      // // else {
+      // //   this.showFileUrl =
+      // //     "https://view.officeapps.live.com/op/view.aspx?src=" + url;
+      // //     this.showFileType = 0;
+      // // }
+      // if (url.split(".")[url.split(".").length - 1].toLocaleUpperCase() == ('PNG' || 'JPG')) {
+      //   console.log(1111);
+      //     this.showFileUrl = url;
+      //     this.showFileType = 2;
+      // }else{
+      //     this.showFileUrl ="https://view.officeapps.live.com/op/view.aspx?src=" + url;
       //     this.showFileType = 0;
       // }
-      if (url.split(".")[url.split(".").length - 1].toLocaleUpperCase() == ('PNG' || 'JPG')) {
-        console.log(1111);
-          this.showFileUrl = url;
-          this.showFileType = 2;
-      }else{
-          this.showFileUrl ="https://view.officeapps.live.com/op/view.aspx?src=" + url;
-          this.showFileType = 0;
-      }
       this.showFile = true;
+
+      if(typeof url=='undefined')return {type:"",name:""};
+          let urlSplit = url.split(".");
+          const type = urlSplit[urlSplit.length-1]
+          if(this.canonical.Image.test(url)){
+           
+             this.Wordss={type:type,name:"图片"}
+             return console.log(this.Wordss);
+          }
+          if(this.canonical.File.test(url)){
+             this.Wordss={type:type,name:"文档"}
+             return console.log(this.Wordss);
+          }
+          else return this.Wordss={type:type,name:type}
     },
     del(Id) {
       this.delId = Id;