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();
              }
          });
      })();
    }];
  • 相关阅读:
    (转载)SAPI 包含sphelper.h编译错误解决方案
    C++11标准的智能指针、野指针、内存泄露的理解(日后还会补充,先浅谈自己的理解)
    504. Base 7(LeetCode)
    242. Valid Anagram(LeetCode)
    169. Majority Element(LeetCode)
    100. Same Tree(LeetCode)
    171. Excel Sheet Column Number(LeetCode)
    168. Excel Sheet Column Title(LeetCode)
    122.Best Time to Buy and Sell Stock II(LeetCode)
    404. Sum of Left Leaves(LeetCode)
  • 原文地址:https://www.cnblogs.com/ms-grf/p/7597192.html
Copyright © 2011-2022 走看看