Bläddra i källkod

task-282 添加 his 通信方式

cc12458 3 månader sedan
förälder
incheckning
16ff5e6abc

+ 43 - 0
src/utils/url.js

@@ -0,0 +1,43 @@
+export function getURLSearchParams(value) {
+  if (!value) value = `${location.search}&${location.hash.split('?')[1] || ''}`;
+  return new URLSearchParams(value);
+}
+
+export function setSessionModalId(tag = 'modalId') {
+  const params = getURLSearchParams();
+  const modalId = params.get(tag);
+  if (modalId) sessionStorage.setItem(tag, modalId);
+
+  console.group(tag);
+  console.log('search: ', location.search);
+  console.log('hash: ', location.hash);
+  console.log('modalId: ', modalId);
+  console.groupEnd();
+
+  return modalId;
+}
+
+export function getSessionModalId(tag = 'modalId') {
+  const modalId = sessionStorage.getItem(tag);
+  return modalId ? modalId : setSessionModalId(tag);
+}
+
+export function inform(data = {}, tag = 'modalId') {
+  try {
+    const message = JSON.stringify(data);
+    window.parent.postMessage(message, '*');
+  } catch (e) { console.log(`通信失败:`, data); }
+  const modalId = getSessionModalId(tag);
+  if (modalId) {
+    sessionStorage.removeItem(tag);
+    const message = {
+      type: 'closeAnchorModal',
+      data: {...data, modalId},
+    }
+    window.parent.postMessage(message);
+    console.group(tag);
+    console.log('modalId: ', modalId);
+    console.log('message: ', message);
+    console.groupEnd();
+  }
+}

+ 4 - 3
src/views/diagnosis/Emr.vue

@@ -76,6 +76,7 @@ import PriviewEdit from "../business/components/PriviewEdit.vue";
 
 import {formatPicture, toPicture} from "@/utils/picture";
 import SoundRecorder from '@/components/SoundRecorder.vue';
+import {inform} from '@/utils/url';
 
 export default {
   components: {
@@ -363,7 +364,7 @@ export default {
         origin: "EMR",
         msg: "刷新数据"
       };
-      window.parent.postMessage(JSON.stringify(msg), "*");
+      inform(msg);
       console.log(window.parent, "打印父级页面");
       console.log("---执行了发送消息的代码----");
     },
@@ -774,7 +775,7 @@ export default {
               origin: "EMR",
               msg: "刷新数据"
             };
-            window.parent.postMessage(JSON.stringify(msg), "*");
+            inform(msg);
             return;
           }
           next();
@@ -920,7 +921,7 @@ export default {
               origin: "EMR",
               msg: "刷新数据"
             };
-            window.parent.postMessage(JSON.stringify(msg), "*");
+            inform(msg);
             return;
           }
           next();

+ 3 - 2
src/views/diagnosis/components/submitRecipe.vue

@@ -327,6 +327,7 @@ import chineseMadePad from "@/components/ui/chineseMadePad.vue";
 import suitMadePad from "@/components/ui/suitMadePad.vue";
 
 import { formatPicture } from "@/utils/picture";
+import {inform} from '@/utils/url';
 
 export default {
   components: {
@@ -628,7 +629,7 @@ export default {
           origin: "Recipe",
           msg: "刷新数据"
         };
-        window.parent.postMessage(JSON.stringify(msg), "*");
+        inform(msg);
         if (this.$route.query.from && this.$route.query.from == "validation") {
           setTimeout(() => {
             loading.close();
@@ -673,7 +674,7 @@ export default {
           origin: "Recipe",
           msg: "刷新数据"
         };
-        window.parent.postMessage(JSON.stringify(msg), "*");
+        inform(msg);
         this.$message.success("修改成功");
         setTimeout(() => {
           loading.close();

+ 3 - 0
src/views/hisEnter.vue

@@ -6,6 +6,7 @@ import { seeDoctor } from "@/api/patients.js";
 import { getPatiiensMsg } from "@/api/diagnosis.js";
 import { mapState, mapGetters, mapActions, mapMutations } from "vuex";
 import { getDataByKey } from "@/api/system.js";
+import { setSessionModalId } from '@/utils/url';
 export default {
   data() {
     return {
@@ -20,6 +21,8 @@ export default {
       let pid = this.$route.query.token;
       let token = this.$route.query.Authorization;
 
+      setSessionModalId();
+
       if (token) {
         localStorage.setItem("token", token);
         if (this.getuserinfo) this.getDataByKey();