EmrDualScreen.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <div ref="dualScreenRef"
  3. class="dual-screen">
  4. <div class="close" @click="isOpenDualScreen = false">
  5. X
  6. </div>
  7. <iframe
  8. :src="dualScreenSrc"
  9. height="100%"
  10. width="100%"
  11. ref="emrRef"/>
  12. </div>
  13. </template>
  14. <script setup name='EmrDualScreen'>
  15. import {dualScreenSrc, isOpenDualScreen} from "@/views/hospitalization/zhu-yuan-yi-sheng/public-js/zhu-yuan-yi-sheng";
  16. import router from "@/router";
  17. import {watch} from "vue";
  18. const dualScreenRef = ref(null)
  19. const emrRef = ref(null)
  20. let iframeWindow = null; //iframe的window对象
  21. // 监听页面加载完成
  22. const handleMessage = (event) => {
  23. // 触发页面元素
  24. iframeWindow.dualScreenMode()
  25. }
  26. onMounted(async () => {
  27. const body = document.querySelector("body");
  28. if (body.append) {
  29. body.append(dualScreenRef.value);
  30. } else {
  31. body.appendChild(dualScreenRef.value);
  32. }
  33. await nextTick();
  34. window.addEventListener("message", handleMessage)
  35. iframeWindow = emrRef.value.contentWindow;
  36. })
  37. watch(() => router.currentRoute.value.path, () => {
  38. let path = router.currentRoute.value.path
  39. if (path === '/login') {
  40. isOpenDualScreen.value = false
  41. }
  42. }, {deep: true})
  43. </script>
  44. <style scoped lang="scss">
  45. .dual-screen {
  46. position: fixed;
  47. top: 0;
  48. right: 0;
  49. width: 50%;
  50. height: 100%;
  51. background-color: white;
  52. z-index: 99;
  53. .close {
  54. text-align: center;
  55. position: absolute;
  56. border-radius: 5px;
  57. height: 20px;
  58. width: 20px;
  59. right: 0;
  60. background-color: red;
  61. box-shadow: var(--el-box-shadow-light);
  62. cursor: pointer;
  63. color: white;
  64. }
  65. }
  66. </style>