zoukankan      html  css  js  c++  java
  • angular iFrame加载资源问题

    index-oupt.html(主框架 doctorstation-outp-controller.js)等到加载完成患者列表的内容,然后加载就诊史的内容

    <!--就诊史outp-visit-history-->
    <section class="tab-pane active visit-history-index" ng-show="tabNavShow.visitHistory"
        id="clinicVisitHistory" ng-include src="'templates/visitHistory/visit-history-page.html'">
    </section>
    <!--患者列表开始-->
    <section ng-show="clinicTimeShow" class="pat-list-index hc-sidebar hc-float-above border-radius outp-pat-list-index"
        id="patientList" ng-include src="'templates/outp/outp-left.html'">
    </section>

    doctorstation-outp-controller.js

    $scope.waitIframeLoad = function() {
        console.log("invoke waitIframeLoad!");
        //var iframes = ["visitHistoryFrame", "outpAdmissionFrame", "outpClinicAppointFrame"];
        var iframes = ["visitHistoryFrame"];
        if ($scope.doctorstationParaValue.enableDaywardApply === '1') {
            iframes.push("outpOperationApplyFrame");
        }
        var loaded = iframes.every(function (id) {
            return document.getElementById(id).contentWindow.document.readyState === "complete";
        });
        if (loaded) {
            console.log("iframesLoaded!");
            $scope.waitIframeLoad = undefined;
            $scope.$broadcast($scope.updatePatientEvent);
        }else{
            setTimeout(function () {
                waitIframeLoad();
            }, 1000)
        }
    }

    visit-history-page.html (visit-history-page-controller.js)

    <div ng-controller="VisitHistoryPageController"  hr-self-height="$(window).height() - 99">
        <iframe style="100%;height:100%;"
            id="visitHistoryFrame"
            ng-src="{{visitHistoryView.url}}"
            scrolling=yes
            frameborder=0 marginheight=0 marginwidth=0 >
    
        </iframe>
    </div>

    visit-history-page-controller.js

    var VisitHistoryPageController = ["$scope", function ($scope) {
        $scope.visitHistoryView = {
            "url": Path.getUri("doctorstation/index-visit-history.html?" +
                "&departmentCode=" + $scope.doctorInfo.departmentCode +
                "&allowViewReportStatus=" + $scope.doctorstationParaValue.allowViewReportStatus +
                "&fromPage=doctorStation")
        };
      window.addEventListener('message', function (event) {
      if (event.data.type === "apply-for-admission-order") {
       hrDialog.dialog(hrDialog.typeEnum.WARN, {title: '提示!', message: "请开立院前医嘱!"})
       .close(function(){
      $scope.showAdmissionTabNav("admissionOrder");
      })
       }
      });<!--接收iframe加载页面的消息-->
        $scope.$on($scope.updatePatientEvent, function () {
            setTimeout(function () {
                document.getElementById("visitHistoryFrame").contentWindow.postMessage({
                    type: "update-patient-event",
                    body: {
                        patientId: $scope.patientInfo.patientId
                    }
                }, "*");
            }, 500);
        });
    }];

    index-visit-history.html(visit-history-app.js)

    <!DOCTYPE HTML>
    <html ng-app="VisitHistoryApp">
    <head>
        <meta charset="utf-8">
        <title>就诊史</title>
    </head>
    <body>
        <div ng-include src="'templates/visitHistory/visit-history.html'"></div>
    </body>
    </html>

    visit-history-app.js没有什么信息

    visit-history.html (visit-history-controller.js)

    <!--就诊史-->
    <div class="visit-history-index" hr-cloak ng-controller='VisitHistoryController'>
    <div>

    visit-history-controller.js

    var VisitHistoryController = ["$scope" ,function ($scope) {
      function getQueryString(queryString, name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = queryString.substr(1).match(reg);
        if (r != null) {
            return decodeURI(r[2])
        }
        return null;
        }
      
      //获取放iframe窗口那一级的页面元素
      var scope = parent.angular.element("#outpMrMain").scope();
      window.parent.postMessage({
      type: "apply-for-admission-order",
      body:""
      }, "*");<!--像父窗口发消息-->
      (function () {
          $scope.pageInfo.from = getQueryString($window.location.search, "fromPage");//获取上面绿色传过来的值
          window.addEventListener('message', function (event) {<-- iFrame之间通信 -->
              console.log("---------从iframe传来数据---------------");
              console.log(event.data.body);
              if (event.data.type === "update-patient-event") {
                  initParam();
                  $scope.outpMrSearchCondition.patientId = event.data.body.patientId;
                  initVistitHistoryContr();
              }
          });
      })();
    }];
  • 相关阅读:
    线程的实现方式
    实现一个拷贝文件的工具类,要使用字符流还是字节流
    String&&StringBuilder&&StringBuffer
    面向对象的特征
    索引的选择
    TCP之Nagle算法&&延迟ACK
    通用套接字选项和TCP套接字选项
    TCP之非阻塞connect和accept
    TCP之种种连接异常
    TCP之listen&backlog
  • 原文地址:https://www.cnblogs.com/ms-grf/p/7597192.html
Copyright © 2011-2022 走看看