Kaynağa Gözat

增加预览pdf

空白格 2 yıl önce
ebeveyn
işleme
878a5382ec

+ 1 - 0
package.json

@@ -18,6 +18,7 @@
     "quill": "^1.3.7",
     "register-service-worker": "^1.7.2",
     "vue": "^2.6.14",
+    "vue-pdf": "^4.3.0",
     "vue-router": "^3.5.1",
     "vuex": "^3.6.2"
   },

+ 333 - 0
src/components/ViewPdf/index.vue

@@ -0,0 +1,333 @@
+<!--
+ * @Description:
+ * @Author: 空白格
+ * @Date: 2022-08-25 16:39:06
+ * @LastEditors: 空白格
+ * @LastEditTime: 2022-08-25 17:10:46
+ * @FilePath: \veterans_client_web\src\components\ViewPdf\index.vue
+ * @Copyright: Copyright (c) 2016~2022 by 空白格, All Rights Reserved.
+-->
+<template>
+  <div>
+    <el-dialog
+      title="PDF 预览"
+      :visible.sync="dialogVisible"
+      :close-on-click-modal="false"
+      width="500"
+      top="10vh"
+    >
+      <div class="tools">
+        <el-button type="text" @click="FirstPage()">
+          <el-tooltip
+            class="item"
+            effect="light"
+            content="第一页"
+            placement="top"
+            ><i class="el-icon-d-arrow-left"></i>
+          </el-tooltip>
+        </el-button>
+        <el-button type="text" @click="changePdfPage(0)">
+          <el-tooltip
+            class="item"
+            effect="light"
+            content="上一页"
+            placement="top"
+            ><i class="el-icon-arrow-left"></i>
+          </el-tooltip>
+        </el-button>
+        <el-button type="text" @click="changePdfPage(1)">
+          <el-tooltip
+            class="item"
+            effect="light"
+            content="下一页"
+            placement="top"
+            ><i class="el-icon-arrow-right"></i>
+          </el-tooltip>
+        </el-button>
+        <el-button type="text" @click="lastPage()">
+          <el-tooltip
+            class="item"
+            effect="light"
+            content="最后一页"
+            placement="top"
+            ><i class="el-icon-d-arrow-right"></i>
+          </el-tooltip>
+        </el-button>
+
+        <el-button
+          type="text"
+          @click="setIsExit()"
+          v-show="!isExit"
+          style="margin-right: 10px"
+        >
+          <el-tooltip
+            class="item"
+            effect="light"
+            content="页码选择"
+            placement="top"
+            ><i class="el-icon-setting"></i>
+          </el-tooltip>
+        </el-button>
+
+        <el-tooltip
+          class="item"
+          effect="light"
+          content="页码选择"
+          placement="top"
+          v-show="isExit"
+        >
+          <el-select
+            v-model="value"
+            placeholder="请选择"
+            @change="pageSelect"
+            size="mini"
+          >
+            <el-option
+              v-for="item in pageCount"
+              :key="item"
+              :label="'第 ' + item + ' 页'"
+              :value="item"
+            >
+            </el-option>
+          </el-select>
+        </el-tooltip>
+        <el-button type="text" @click="scaleD()">
+          <el-tooltip class="item" effect="light" content="放大" placement="top"
+            ><i class="el-icon-zoom-in"></i>
+          </el-tooltip>
+        </el-button>
+        <el-button type="text" @click="scaleX()">
+          <el-tooltip class="item" effect="light" content="缩小" placement="top"
+            ><i class="el-icon-zoom-out"></i>
+          </el-tooltip>
+        </el-button>
+        <el-button type="text" @click="clock()">
+          <el-tooltip
+            class="item"
+            effect="light"
+            content="顺时针旋转"
+            placement="top"
+            ><i class="el-icon-refresh-right"></i>
+          </el-tooltip>
+        </el-button>
+        <el-button type="text" @click="counterClock()">
+          <el-tooltip
+            class="item"
+            effect="light"
+            content="逆时针旋转"
+            placement="top"
+            ><i class="el-icon-refresh-left"></i>
+          </el-tooltip>
+        </el-button>
+        <el-button type="text" @click="downPDF">
+          <el-tooltip class="item" effect="light" content="下载" placement="top"
+            ><i class="el-icon-download"></i>
+          </el-tooltip>
+        </el-button>
+        <el-button type="text" @click="printPDF">
+          <el-tooltip class="item" effect="light" content="打印" placement="top"
+            ><i class="el-icon-printer"></i>
+          </el-tooltip>
+        </el-button>
+        <p class="total">
+          <el-tooltip
+            class="item"
+            effect="light"
+            content="当前页"
+            placement="top"
+            ><b style="color: #f56c6c; cursor: pointer">{{
+              currentPage
+            }}</b></el-tooltip
+          >&nbsp;/&nbsp;
+          <el-tooltip
+            class="item"
+            effect="light"
+            content="总页数"
+            placement="top"
+            ><b style="color: #67c23a; cursor: pointer">{{
+              pageCount
+            }}</b></el-tooltip
+          >
+        </p>
+      </div>
+      <div class="main">
+        <pdf
+          ref="pdf"
+          id="pdf"
+          :src="src"
+          :page="currentPage"
+          :rotate="pageRotate"
+          @num-pages="pageCount = $event"
+          @page-loaded="currentPage = $event"
+          @loaded="loadPdfHandler"
+        ></pdf>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+// pdf预览
+import pdf from "vue-pdf";
+export default {
+  name: "ViewPdf",
+  components: {
+    pdf,
+  },
+  data() {
+    return {
+      value: 1,
+      dialogVisible: false,
+      src: "",
+      currentPage: 0, // pdf文件页码
+      pageCount: 0, // pdf文件总页数
+      scale: 100,
+      pageRotate: 0,
+      isExit: false,
+    };
+  },
+  methods: {
+    /**
+     * 打开弹框
+     * @date 2022-08-25
+     * @param {any} url
+     * @returns {any}
+     */
+    openDialog(url) {
+      this.src = url;
+      this.dialogVisible = true;
+    },
+    // pdf加载时
+    loadPdfHandler() {
+      this.value = this.currentPage = 1; // 加载的时候先加载第一页
+    },
+    // 第一页
+    FirstPage() {
+      this.value = this.currentPage = 1;
+      this.isExit = false;
+    },
+    // 最后一页
+    lastPage() {
+      this.value = this.currentPage = this.pageCount;
+      this.isExit = false;
+    },
+    // 改变PDF页码,val传过来区分上一页下一页的值,0上一页,1下一页
+    changePdfPage(val) {
+      if (val === 0 && this.currentPage > 1) {
+        this.currentPage--;
+      }
+      if (val === 1 && this.currentPage < this.pageCount) {
+        this.currentPage++;
+      }
+      this.value = this.currentPage;
+      this.isExit = false;
+    },
+    // 页码选择
+    pageSelect() {
+      this.currentPage = this.value;
+      this.isExit = false;
+    },
+    setIsExit() {
+      this.isExit = true;
+    },
+    //放大
+    scaleD() {
+      this.scale += 5;
+      this.$refs.pdf.$el.style.width = parseInt(this.scale) + "%";
+    },
+    //缩小
+    scaleX() {
+      if (this.scale === 100) {
+        return;
+      }
+      this.scale += -5;
+      this.$refs.pdf.$el.style.width = parseInt(this.scale) + "%";
+    },
+    // 顺时针
+    clock() {
+      this.pageRotate += 90;
+    },
+    // 逆时针
+    counterClock() {
+      this.pageRotate -= 90;
+    },
+    downPDF() {
+      var url = this.src;
+      var tempLink = document.createElement("a");
+      tempLink.style.display = "none";
+      tempLink.href = url;
+      tempLink.setAttribute("download", this.src);
+      if (typeof tempLink.download === "undefined") {
+        tempLink.setAttribute("target", "_blank");
+      }
+      document.body.appendChild(tempLink);
+      tempLink.click();
+      document.body.removeChild(tempLink);
+    },
+    printPDF() {
+      this.$refs.pdf.print();
+    },
+  },
+};
+</script>
+
+<style scoped>
+.btn {
+  margin: 20px 0px;
+}
+.main {
+  border: 2px solid #dcdfe6;
+  height: 65vh;
+  overflow: auto;
+}
+.tools {
+  display: flex;
+  justify-content: center;
+}
+.total {
+  width: 80px;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}
+.main::-webkit-scrollbar {
+  width: 6px;
+}
+/* 修改 滚动条的 下面 的 样式 */
+.main::-webkit-scrollbar-track {
+  background-color: white;
+  -webkit-border-radius: 2em;
+  -moz-border-radius: 2em;
+  border-radius: 2em;
+}
+/* 修改 滑块 */
+.main::-webkit-scrollbar-thumb {
+  background-color: #dcdfe6;
+  -webkit-border-radius: 2em;
+  -moz-border-radius: 2em;
+  border-radius: 2em;
+}
+:deep(.el-dialog) {
+  font-family: "楷体";
+}
+:deep(.el-dialog__header) {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  background: #303133;
+}
+:deep(.el-dialog__title) {
+  color: white;
+}
+:deep(.el-dialog__headerbtn .el-dialog__close) {
+  color: white;
+}
+:deep(.el-dialog__body) {
+  padding: 20px;
+}
+:deep(.el-select ){
+  width: 95px;
+  height: 28px;
+  margin: 5px 20px 0px 20px;
+}
+</style>

+ 4 - 4
src/views/CooperativeEnterprise/EnterpriseDetails/EnterpriseDetailsIndex.vue

@@ -2,8 +2,8 @@
  * @Description: 企业详情
  * @Author: 空白格
  * @Date: 2022-08-15 14:54:50
- * @LastEditors: gcz
- * @LastEditTime: 2022-08-23 16:14:35
+ * @LastEditors: 空白格
+ * @LastEditTime: 2022-08-25 16:26:15
  * @FilePath: \veterans_client_web\src\views\CooperativeEnterprise\EnterpriseDetails\EnterpriseDetailsIndex.vue
  * @Copyright: Copyright (c) 2016~2022 by 空白格, All Rights Reserved.
 -->
@@ -44,7 +44,7 @@
     </div>
     <div class="app-main-box enterprise-details-main">
       <!-- 热招职位 -->
-      <div class="enterprise-details-main-hot">
+      <!-- <div class="enterprise-details-main-hot">
         <div class="edmh-header">
           <h4>热招职位</h4>
           <div class="edmh-header-view">查看全部职位></div>
@@ -86,7 +86,7 @@
           </el-row>
           <el-empty v-else :image-size="80" description="无热招职位数据"></el-empty>
         </div>
-      </div>
+      </div> -->
       <!-- 公司信息 -->
       <div class="app-main-box-content enterprise-details-main-info">
         <!-- 公司介绍 -->

+ 6 - 6
src/views/PersonalCenter/PersonalCenterIndex.vue

@@ -3,7 +3,7 @@
  * @Author: 空白格
  * @Date: 2022-08-15 10:09:03
  * @LastEditors: 空白格
- * @LastEditTime: 2022-08-25 15:19:05
+ * @LastEditTime: 2022-08-25 16:19:50
  * @FilePath: \veterans_client_web\src\views\PersonalCenter\PersonalCenterIndex.vue
  * @Copyright: Copyright (c) 2016~2022 by 空白格, All Rights Reserved.
 -->
@@ -221,11 +221,11 @@ export default {
           label: "我的面试",
           path: "/personalcenter/interview",
         },
-        {
-          icon: require("@/assets/images/personal-center-icon/_jiuyechuangye.svg"),
-          label: "我的创业计划",
-          path: "",
-        },
+        // {
+        //   icon: require("@/assets/images/personal-center-icon/_jiuyechuangye.svg"),
+        //   label: "我的创业计划",
+        //   path: "",
+        // },
         {
           icon: require("@/assets/images/personal-center-icon/jinengx.svg"),
           label: "我的技能培训",

+ 8 - 4
src/views/WorkGuide/WorkGuideDetails/WorkGuideDetailsIndex.vue

@@ -3,7 +3,7 @@
  * @Author: 空白格
  * @Date: 2022-08-25 13:30:07
  * @LastEditors: 空白格
- * @LastEditTime: 2022-08-25 16:04:15
+ * @LastEditTime: 2022-08-25 17:01:01
  * @FilePath: \veterans_client_web\src\views\WorkGuide\WorkGuideDetails\WorkGuideDetailsIndex.vue
  * @Copyright: Copyright (c) 2016~2022 by 空白格, All Rights Reserved.
 -->
@@ -27,7 +27,8 @@
           <div class="dbcd-content" v-html="detainsInfo.description"></div>
         </div>
         <div class="details-box-content-pdf" v-if="detainsInfo.planBookName">
-          <div @click="previewPdf(detainsInfo.planBookUrl)">{{ detainsInfo.planBookName }}</div>
+          <div class="btn" @click="previewPdf(detainsInfo.planBookUrl)">{{ detainsInfo.planBookName }}</div>
+          <view-pdf ref="viewPdf"/>
         </div>
         <div
           class="details-box-content-reply"
@@ -43,11 +44,13 @@
 
 <script>
 import BannerBreadcrumb from "@/components/BannerBreadcrumb";
+import ViewPdf from '@/components/ViewPdf'
 import { getWorkGuideDetails } from "@/api/WorkGuide";
 export default {
   name: "WorkGuideDetailsIndex",
   components: {
     BannerBreadcrumb,
+    ViewPdf
   },
   data() {
     return {
@@ -83,7 +86,8 @@ export default {
      */
     previewPdf(pdfUrl) {
       if (pdfUrl) {
-        window.open('http://www.gjtool.cn/pdfh5/pdf.html?file=' + pdfUrl)
+        // window.open('http://www.gjtool.cn/pdfh5/pdf.html?file=' + pdfUrl)
+        this.$refs['viewPdf'].openDialog(pdfUrl)
       }
     }
   },
@@ -134,7 +138,7 @@ export default {
       &-pdf {
         text-align: center;
         margin: 20px auto 30px;
-        div {
+        .btn {
           display: inline-block;
           padding: 0 100px;
           max-width: 700px;

+ 54 - 3
yarn.lock

@@ -1844,7 +1844,7 @@ ajv-formats@^2.1.1:
   dependencies:
     ajv "^8.0.0"
 
-ajv-keywords@^3.5.2:
+ajv-keywords@^3.1.0, ajv-keywords@^3.5.2:
   version "3.5.2"
   resolved "https://registry.npmmirror.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d"
   integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==
@@ -1856,7 +1856,7 @@ ajv-keywords@^5.0.0:
   dependencies:
     fast-deep-equal "^3.1.3"
 
-ajv@^6.10.0, ajv@^6.12.4, ajv@^6.12.5:
+ajv@^6.1.0, ajv@^6.10.0, ajv@^6.12.4, ajv@^6.12.5:
   version "6.12.6"
   resolved "https://registry.npmmirror.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4"
   integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==
@@ -2081,6 +2081,11 @@ babel-plugin-polyfill-regenerator@^0.4.0:
   dependencies:
     "@babel/helper-define-polyfill-provider" "^0.3.2"
 
+babel-plugin-syntax-dynamic-import@^6.18.0:
+  version "6.18.0"
+  resolved "https://registry.npmmirror.com/babel-plugin-syntax-dynamic-import/-/babel-plugin-syntax-dynamic-import-6.18.0.tgz#8d6a26229c83745a9982a441051572caa179b1da"
+  integrity sha512-MioUE+LfjCEz65Wf7Z/Rm4XCP5k2c+TbMd2Z2JKc7U9uwjBhAfNPE48KC4GTGKhppMeYVepwDBNO/nGY6NYHBA==
+
 babel-runtime@6.x:
   version "6.26.0"
   resolved "https://registry.npmmirror.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe"
@@ -4484,7 +4489,7 @@ loader-runner@^4.1.0, loader-runner@^4.2.0:
   resolved "https://registry.npmmirror.com/loader-runner/-/loader-runner-4.3.0.tgz#c1b4a163b99f614830353b16755e7149ac2314e1"
   integrity sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==
 
-loader-utils@^1.0.2, loader-utils@^1.1.0:
+loader-utils@^1.0.0, loader-utils@^1.0.2, loader-utils@^1.1.0, loader-utils@^1.4.0:
   version "1.4.0"
   resolved "https://registry.npmmirror.com/loader-utils/-/loader-utils-1.4.0.tgz#c579b5e34cb34b1a74edc6c1fb36bfa371d5a613"
   integrity sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA==
@@ -5174,6 +5179,11 @@ path-type@^4.0.0:
   resolved "https://registry.npmmirror.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
   integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==
 
+pdfjs-dist@2.6.347:
+  version "2.6.347"
+  resolved "https://registry.npmmirror.com/pdfjs-dist/-/pdfjs-dist-2.6.347.tgz#f257ed66e83be900cd0fd28524a2187fb9e25cd5"
+  integrity sha512-QC+h7hG2su9v/nU1wEI3SnpPIrqJODL7GTDFvR74ANKGq1AFJW16PH8VWnhpiTi9YcLSFV9xLeWSgq+ckHLdVQ==
+
 picocolors@^0.2.1:
   version "0.2.1"
   resolved "https://registry.npmmirror.com/picocolors/-/picocolors-0.2.1.tgz#570670f793646851d1ba135996962abad587859f"
@@ -5592,6 +5602,14 @@ raw-body@2.5.1:
     iconv-lite "0.4.24"
     unpipe "1.0.0"
 
+raw-loader@^4.0.2:
+  version "4.0.2"
+  resolved "https://registry.npmmirror.com/raw-loader/-/raw-loader-4.0.2.tgz#1aac6b7d1ad1501e66efdac1522c73e59a584eb6"
+  integrity sha512-ZnScIV3ag9A4wPX/ZayxL/jZH+euYb6FcUinPcgiQW0+UBtEv0O6Q3lGd3cqJ+GHH+rksEv3Pj99oxJ3u3VIKA==
+  dependencies:
+    loader-utils "^2.0.0"
+    schema-utils "^3.0.0"
+
 read-pkg-up@^7.0.1:
   version "7.0.1"
   resolved "https://registry.npmmirror.com/read-pkg-up/-/read-pkg-up-7.0.1.tgz#f3a6135758459733ae2b95638056e1854e7ef507"
@@ -5851,6 +5869,14 @@ sass@^1.32.7:
     immutable "^4.0.0"
     source-map-js ">=0.6.2 <2.0.0"
 
+schema-utils@^0.4.0:
+  version "0.4.7"
+  resolved "https://registry.npmmirror.com/schema-utils/-/schema-utils-0.4.7.tgz#ba74f597d2be2ea880131746ee17d0a093c68187"
+  integrity sha512-v/iwU6wvwGK8HbU9yi3/nhGzP0yGSuhQMzL6ySiec1FSrZZDkhm4noOSWzrNFo/jEc+SJY6jRTwuwbSXJPDUnQ==
+  dependencies:
+    ajv "^6.1.0"
+    ajv-keywords "^3.1.0"
+
 schema-utils@^2.6.5:
   version "2.7.1"
   resolved "https://registry.npmmirror.com/schema-utils/-/schema-utils-2.7.1.tgz#1ca4f32d1b24c590c203b8e7a50bf0ea4cd394d7"
@@ -6661,6 +6687,23 @@ vue-loader@^17.0.0:
     hash-sum "^2.0.0"
     loader-utils "^2.0.0"
 
+vue-pdf@^4.3.0:
+  version "4.3.0"
+  resolved "https://registry.npmmirror.com/vue-pdf/-/vue-pdf-4.3.0.tgz#d5f790ee7967e7b7aa9089b97b11ab168e19dbd0"
+  integrity sha512-zd3lJj6CbtrawgaaDDciTDjkJMUKiLWtbEmBg5CvFn9Noe9oAO/GNy/fc5c59qGuFCJ14ibIV1baw4S07e5bSQ==
+  dependencies:
+    babel-plugin-syntax-dynamic-import "^6.18.0"
+    loader-utils "^1.4.0"
+    pdfjs-dist "2.6.347"
+    raw-loader "^4.0.2"
+    vue-resize-sensor "^2.0.0"
+    worker-loader "^2.0.0"
+
+vue-resize-sensor@^2.0.0:
+  version "2.0.0"
+  resolved "https://registry.npmmirror.com/vue-resize-sensor/-/vue-resize-sensor-2.0.0.tgz#3a587fd6802e1688709cf2c5aadae7a0075952bf"
+  integrity sha512-W+y2EAI/BxS4Vlcca9scQv8ifeBFck56DRtSwWJ2H4Cw1GLNUYxiZxUHHkuzuI5JPW/cYtL1bPO5xPyEXx4LmQ==
+
 vue-router@^3.5.1:
   version "3.5.4"
   resolved "https://registry.npmmirror.com/vue-router/-/vue-router-3.5.4.tgz#c453c0b36bc75554de066fefc3f2a9c3212aca70"
@@ -7097,6 +7140,14 @@ workbox-window@6.5.4:
     "@types/trusted-types" "^2.0.2"
     workbox-core "6.5.4"
 
+worker-loader@^2.0.0:
+  version "2.0.0"
+  resolved "https://registry.npmmirror.com/worker-loader/-/worker-loader-2.0.0.tgz#45fda3ef76aca815771a89107399ee4119b430ac"
+  integrity sha512-tnvNp4K3KQOpfRnD20m8xltE3eWh89Ye+5oj7wXEEHKac1P4oZ6p9oTj8/8ExqoSBnk9nu5Pr4nKfQ1hn2APJw==
+  dependencies:
+    loader-utils "^1.0.0"
+    schema-utils "^0.4.0"
+
 wrap-ansi@^3.0.1:
   version "3.0.1"
   resolved "https://registry.npmmirror.com/wrap-ansi/-/wrap-ansi-3.0.1.tgz#288a04d87eda5c286e060dfe8f135ce8d007f8ba"