Browse Source

隐藏pdf打印 存在问题

zaijin 2 years ago
parent
commit
9915e88f66
3 changed files with 618 additions and 609 deletions
  1. 1 1
      package.json
  2. 7 5
      src/components/ViewPdf/index.vue
  3. 610 603
      yarn.lock

+ 1 - 1
package.json

@@ -21,7 +21,7 @@
     "swiper": "5.x",
     "vue": "^2.6.14",
     "vue-awesome-swiper": "4.1.1",
-    "vue-pdf": "4.3.0",
+    "vue-pdf": "^4.3.0",
     "vue-quill-editor": "^3.0.6",
     "vue-router": "^3.5.1",
     "vuex": "^3.6.2"

+ 7 - 5
src/components/ViewPdf/index.vue

@@ -3,7 +3,7 @@
  * @Author: 空白格
  * @Date: 2022-08-25 16:39:06
  * @LastEditors: 空白格
- * @LastEditTime: 2022-08-30 11:27:01
+ * @LastEditTime: 2022-11-18 15:02:48
  * @FilePath: \veterans_client_web\src\components\ViewPdf\index.vue
  * @Copyright: Copyright (c) 2016~2022 by 空白格, All Rights Reserved.
 -->
@@ -121,11 +121,11 @@
             ><i class="el-icon-download"></i>
           </el-tooltip>
         </el-button>
-        <el-button type="text" @click="printPDF">
+        <!-- <el-button type="text" @click="$refs.pdf.print()">
           <el-tooltip class="item" effect="light" content="打印" placement="top"
             ><i class="el-icon-printer"></i>
           </el-tooltip>
-        </el-button>
+        </el-button> -->
         <p class="total">
           <el-tooltip
             class="item"
@@ -157,7 +157,7 @@
           @num-pages="pageCount = $event"
           @page-loaded="currentPage = $event"
           @loaded="loadPdfHandler"
-        ></pdf>
+        />
       </div>
     </el-dialog>
   </div>
@@ -195,7 +195,7 @@ export default {
       const loadingTask = pdf.createLoadingTask(url);
       loadingTask.promise
         .then((pdf) => {
-          this.src = loadingTask;
+          this.src = url;
         })
         .catch((err) => {
           this.$message.error("pdf文件加载失败!");
@@ -269,7 +269,9 @@ export default {
       document.body.removeChild(tempLink);
     },
     printPDF() {
+      console.log(this.$refs.pdf);
       this.$refs.pdf.print();
+      // document.getElementById('printIframe').contentWindow.print();
     },
   },
 };

File diff suppressed because it is too large
+ 610 - 603
yarn.lock