((typeof self !== 'undefined' ? self : this)["webpackJsonpportal_homepage_nanhai"] = (typeof self !== 'undefined' ? self : this)["webpackJsonpportal_homepage_nanhai"] || []).push([[46],{

/***/ 3:
/***/ (function(module, exports) {

/* (ignored) */

/***/ }),

/***/ "3df7":
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);

// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"628455f4-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./node_modules/windicss-webpack-plugin/dist/loaders/windicss-template.cjs!./src/modules/portal-homepage/views/AttachmentsView.vue?vue&type=template&id=307c38d7&scoped=true
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"h-full overflow-y-auto portal-container overflow-x-hidden homepage-index bg-no-repeat"},[(_vm.type === 'application/pdf')?_c('iframe',{ref:"pdfView",staticClass:"w-full h-0px",attrs:{"src":("/lib/pdfjs/web/viewer.html?file=" + _vm.pdfUrl),"frameborder":"0"},on:{"load":_vm.pdfViewOnload}}):_vm._e(),(_vm.type === 'image/png' || _vm.type === 'image/jpeg')?_c('div',{staticClass:"w-full h-full flex justify-center items-center"},[_c('el-image',{attrs:{"src":(_vm.fileUrl + "image/" + _vm.attachmentsId)}},[_c('div',{staticClass:"image-slot",attrs:{"slot":"error"},slot:"error"},[_c('i',{staticClass:"el-icon-picture-outline"})])])],1):_vm._e(),(_vm.type === 'video/mp4')?_c('div',{staticClass:"w-full h-full flex justify-center items-center"},[_c('video',{staticClass:"mx-auto",staticStyle:{"width":"80%","height":"500px"},attrs:{"src":_vm.videoSrc,"controls":""}})]):_vm._e()])}
var staticRenderFns = []


// CONCATENATED MODULE: ./src/modules/portal-homepage/views/AttachmentsView.vue?vue&type=template&id=307c38d7&scoped=true

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js
var regeneratorRuntime = __webpack_require__("c7eb");

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 3 modules
var slicedToArray = __webpack_require__("3835");

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js
var asyncToGenerator = __webpack_require__("1da1");

// EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.concat.js
var es_array_concat = __webpack_require__("99af");

// EXTERNAL MODULE: ./node_modules/core-js/modules/es.object.to-string.js
var es_object_to_string = __webpack_require__("d3b7");

// EXTERNAL MODULE: ./node_modules/core-js/modules/web.dom-collections.for-each.js
var web_dom_collections_for_each = __webpack_require__("159b");

// EXTERNAL MODULE: ./node_modules/@wiz-api/eaf-tenant-management/lib/eaf-tenant-management.umd.js
var eaf_tenant_management_umd = __webpack_require__("c944");

// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-babel/node_modules/thread-loader/dist/cjs.js!./node_modules/@vue/cli-plugin-babel/node_modules/babel-loader/lib??ref--12-1!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./node_modules/windicss-webpack-plugin/dist/loaders/windicss-template.cjs!./src/modules/portal-homepage/views/AttachmentsView.vue?vue&type=script&lang=js






//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//


var eafTenantApi = new eaf_tenant_management_umd["EafTenantApi"]();
/* harmony default export */ var AttachmentsViewvue_type_script_lang_js = ({
  computed: {
    type: function type() {
      return this.$route.query.contentType;
    },
    attachmentsId: function attachmentsId() {
      return this.$route.query.fileId;
    },
    fileName: function fileName() {
      return this.$route.query.fileName;
    },
    videoUrl: function videoUrl() {
      var fileServer = Wiz.GetModuleServer('file-management');
      return "".concat(fileServer, "/api/file-management/files/");
    },
    fileUrl: function fileUrl() {
      var fileServer = Wiz.GetModuleServer('file-management');
      return "".concat(fileServer, "/api/file-management/files/public/");
    },
    pdfUrl: function pdfUrl() {
      return encodeURIComponent("".concat(this.fileUrl, "preview/").concat(this.attachmentsId, "?contentType=application/pdf"));
    }
  },
  watch: {
    type: {
      immediate: true,
      handler: function handler(val) {
        if (val) {
          switch (this.type) {
            case 'video/mp4':
              this.handleVideo(this.$route.query.fileId);
              break;
            default:
              break;
          }
        }
      }
    },
    fileName: {
      immediate: true,
      handler: function handler(val) {
        var _this = this;
        return Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/Object(regeneratorRuntime["a" /* default */])().mark(function _callee() {
          var config, tenantName, _yield$eafTenantApi$g, _yield$eafTenantApi$g2, err, res;
          return Object(regeneratorRuntime["a" /* default */])().wrap(function _callee$(_context) {
            while (1) switch (_context.prev = _context.next) {
              case 0:
                if (!val) {
                  _context.next = 13;
                  break;
                }
                config = Wiz.globalSettings.dynamicModules.modules['portal-homepage-nanhai'].config;
                document.title = "".concat(_this.$route.query.fileName, " - ").concat(config.title);
                tenantName = Wiz.globalSettings.globalConfig.tenantName;
                if (tenantName) {
                  _context.next = 6;
                  break;
                }
                return _context.abrupt("return");
              case 6:
                _context.next = 8;
                return eafTenantApi.getPublishByTenantName({
                  name: tenantName
                });
              case 8:
                _yield$eafTenantApi$g = _context.sent;
                _yield$eafTenantApi$g2 = Object(slicedToArray["a" /* default */])(_yield$eafTenantApi$g, 2);
                err = _yield$eafTenantApi$g2[0];
                res = _yield$eafTenantApi$g2[1];
                if (!err && res.detail) {
                  // 未登录状态下没有缓存企业信息，需手动设置icon
                  document.querySelector("link[rel='icon']").href = "".concat(_this.fileUrl).concat(res.detail.icon);
                }
              case 13:
              case "end":
                return _context.stop();
            }
          }, _callee);
        }))();
      }
    }
  },
  data: function data() {
    return {
      imgSrc: '',
      videoSrc: ''
    };
  },
  methods: {
    pdfViewOnload: function pdfViewOnload() {
      var _this2 = this;
      var contentWindow = this.$refs.pdfView.contentWindow;
      var contentDocument = contentWindow.document;
      setTimeout(function () {
        var resetFunction = function resetFunction(e) {
          if (e.pageNumber === contentWindow.PDFViewerApplication.pagesCount) {
            var maxWidth = contentDocument.body.offsetWidth;
            _.forEach(contentDocument.getElementsByClassName('page'), function (item) {
              var actualWidth = item.offsetWidth / contentWindow.PDFViewerApplication.toolbar.pageScale;
              if (actualWidth > maxWidth) {
                maxWidth = actualWidth;
              }
            });
            contentWindow.PDFViewerApplication.eventBus.dispatch('scalechanged', {
              source: contentWindow.PDFViewerApplication.toolbar,
              value: _.round(contentDocument.body.offsetWidth / maxWidth, 2)
            });
            _this2.$refs.pdfView.style.height = "".concat(contentDocument.getElementById('viewer').offsetHeight + 100, "px");
            contentWindow.PDFViewerApplication.eventBus.off('textlayerrendered', resetFunction);
          }
        };
        contentWindow.PDFViewerApplication.eventBus.on('textlayerrendered', resetFunction);
      }, 100);
      // 调整pdf预览样式颜色与主题色一致
      contentDocument.body.style.backgroundColor = 'unset';
      contentDocument.getElementById('toolbarContainer').style.backgroundImage = 'unset';
      contentDocument.getElementById('toolbarContainer').style.backgroundColor = '#c11920';
      contentDocument.getElementById('toolbarSidebar').style.backgroundColor = '#c11920';
      contentDocument.getElementById('toolbarSidebar').style.backgroundImage = 'unset';
      contentDocument.getElementById('findbar').style.backgroundColor = '#c11920';
      contentDocument.getElementById('findbar').style.backgroundImage = 'unset';
      contentDocument.getElementById('secondaryToolbar').style.backgroundColor = '#c11920';
      contentDocument.getElementById('secondaryToolbar').style.backgroundImage = 'unset';
      var selectOptions = contentDocument.querySelectorAll('.dropdownToolbarButton > select > option');
      if (selectOptions) {
        selectOptions.forEach(function (item) {
          item.style.backgroundColor = '#c11920';
        });
      }
      var timer = setInterval(function () {
        if (contentWindow.PDFViewerApplication.pdfDocument) {
          clearInterval(timer);
          _this2.$refs.pdfView.style.height = "".concat(contentDocument.getElementById('viewer').offsetHeight + 100, "px");
          setTimeout(function () {
            _this2.$refs.pdfView.style.height = "".concat(contentDocument.getElementById('viewer').offsetHeight + 100, "px");
          }, 500);
          // 缩小
          contentDocument.getElementById('zoomIn').onclick = function () {
            _this2.$refs.pdfView.style.height = "".concat(contentDocument.getElementById('viewer').offsetHeight + 100, "px");
          };
          // 放大
          contentDocument.getElementById('zoomOut').onclick = function () {
            _this2.$refs.pdfView.style.height = "".concat(contentDocument.getElementById('viewer').offsetHeight + 100, "px");
          };
          // 缩放下拉切换
          contentDocument.getElementById('scaleSelect').onchange = function () {
            _this2.$refs.pdfView.style.height = "".concat(contentDocument.getElementById('viewer').offsetHeight + 100, "px");
          };
        }
      }, 500);
      // if (!this.detailInfo.isAllowDownload) {
      //   contentDocument.querySelector('.toolbarButton.download').style.display = 'none'
      //   contentDocument.querySelector('.toolbarButton.print').style.display = 'none'
      // }
    },
    handleVideo: function handleVideo(videoFileId) {
      this.videoSrc = "".concat(this.videoUrl).concat(videoFileId, "/play-video");
    }
  }
});
// CONCATENATED MODULE: ./src/modules/portal-homepage/views/AttachmentsView.vue?vue&type=script&lang=js
 /* harmony default export */ var views_AttachmentsViewvue_type_script_lang_js = (AttachmentsViewvue_type_script_lang_js); 
// EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
var componentNormalizer = __webpack_require__("2877");

// CONCATENATED MODULE: ./src/modules/portal-homepage/views/AttachmentsView.vue





/* normalize component */

var component = Object(componentNormalizer["a" /* default */])(
  views_AttachmentsViewvue_type_script_lang_js,
  render,
  staticRenderFns,
  false,
  null,
  "307c38d7",
  null
  
)

/* harmony default export */ var AttachmentsView = __webpack_exports__["default"] = (component.exports);

/***/ })

}]);
//# sourceMappingURL=portal-homepage-nanhai.umd.46.js.map