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="width: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(); } }); })(); }];

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM