App.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <router-view />
  3. <SocketDialog v-if="socketErrDialog" />
  4. <progress-bar />
  5. <CyDialogV2 />
  6. <BackgroundTask />
  7. </template>
  8. <script setup lang="jsx">
  9. import { setCallback, socketErrDialog } from "@/utils/websocket";
  10. import { ElMessageBox, ElNotification } from "element-plus";
  11. import sleep from "@/utils/sleep";
  12. import SocketDialog from "@/components/xiao-chan/websocket/SocketDialog.vue";
  13. import router from "@/router";
  14. import ProgressBar from "@/components/xiao-chan/progress-bar/ProgressBar.vue";
  15. import { formatDateToStr } from "@/utils/moment-utils";
  16. import { ElLink } from "element-plus";
  17. import { CyMessageBox } from "@/utils/cy-message-box";
  18. import { useProgressBarStore } from "@/pinia/progress-bar-store";
  19. import { useUserStore } from "@/pinia/user-store";
  20. import { useSystemStore } from "@/pinia/system-store";
  21. import useChangeToken from "@/utils/cy-use/useChangeToken";
  22. import CyDialogV2 from "@/components/cy/CyDialog/index.vue";
  23. import BackgroundTask from "@/layout/HeaderV2/BackgroundTask.vue";
  24. import { useYfGroupStore } from "@/pinia/use-yf-group";
  25. const progressBarStore = useProgressBarStore();
  26. const systemStore = useSystemStore();
  27. useChangeToken();
  28. progressBarStore.initialize({
  29. title: "数据上传",
  30. isOpen: false,
  31. abnormalClosing: false,
  32. });
  33. function avatarNotification(data) {
  34. const message = (
  35. <div>
  36. <div>科室: {data.deptName}</div>
  37. <div>{data.msg}</div>
  38. </div>
  39. );
  40. ElNotification({
  41. icon: (
  42. <img
  43. src={data.avatar}
  44. style={{ width: "32px", height: "32px", borderRadius: "16px" }}
  45. alt=""
  46. />
  47. ),
  48. title: data.title,
  49. message: message,
  50. dangerouslyUseHTMLString: true,
  51. duration: 0,
  52. });
  53. }
  54. function checkTheCallbacks({ data, isAdd }) {
  55. const message = (
  56. <table style="width: 100%">
  57. <tbody>
  58. <tr>
  59. <td style="padding-right: 8px">患者:</td>
  60. <td>{data.patientName}</td>
  61. </tr>
  62. <tr>
  63. <td style="padding-right: 8px">检查名称:</td>
  64. <td>{data.reqName}</td>
  65. </tr>
  66. <tr>
  67. <td style="padding-right: 8px"> 报告时间:</td>
  68. <td>{formatDateToStr(data.reportTime)}</td>
  69. </tr>
  70. <tr>
  71. <td colspan="2" style="text-ali">
  72. <ElLink
  73. type="primary"
  74. target="_blank"
  75. href={`http://172.16.32.122:8099/mReport?REQUISITIONID=${data.reqNo}`}
  76. >
  77. 查看图像
  78. </ElLink>
  79. </td>
  80. </tr>
  81. </tbody>
  82. </table>
  83. );
  84. ElNotification({
  85. title: isAdd ? "检查结果返回" : "修改检查结果",
  86. message: message,
  87. dangerouslyUseHTMLString: true,
  88. type: "success",
  89. position: "bottom-right",
  90. duration: 0,
  91. });
  92. }
  93. function systemNotification(data) {
  94. if (data.count) {
  95. systemStore.addUnreadMessageCount(data.count);
  96. }
  97. if (data.refreshDelay) {
  98. sleep(data.refreshDelay).then(() => {
  99. location.reload();
  100. });
  101. }
  102. if (data?.donTDisplay) {
  103. return;
  104. }
  105. ElNotification({
  106. title: data.title ?? "新消息",
  107. message: h(
  108. "pre",
  109. {
  110. class: "message_pre",
  111. },
  112. data.message
  113. ),
  114. dangerouslyUseHTMLString: true,
  115. type: data.type ?? "warning",
  116. duration: 0,
  117. });
  118. }
  119. onMounted(() => {
  120. useYfGroupStore().init();
  121. setCallback("refreshToken", data => {
  122. useUserStore().setToken(data.token);
  123. });
  124. setCallback("sidSingle", async () => {
  125. localStorage.clear();
  126. await router.push("/login");
  127. await ElMessageBox.alert(
  128. "您的账号已在其他地方登陆,如需修改密码请在个人中心中修改。",
  129. "提示",
  130. {
  131. type: "warning",
  132. }
  133. );
  134. });
  135. setCallback("criticalValue", data => {
  136. CyMessageBox.confirm({
  137. title: "患者危急值",
  138. message: data.message,
  139. type: "error",
  140. confirmButtonText: "前往处理",
  141. cancelButtonText: "关闭",
  142. })
  143. .then(() => {
  144. router.push(`/inpatient/zhuYuanYiSheng/criticalValue?id=${data.id}`);
  145. })
  146. .catch(() => {});
  147. });
  148. setCallback("systemNotification", systemNotification);
  149. setCallback("checkTheCallbacks", checkTheCallbacks);
  150. setCallback("avatarNotification", avatarNotification);
  151. });
  152. </script>
  153. <style lang="scss">
  154. .message_pre {
  155. font-weight: normal;
  156. margin: 0;
  157. font-size: 14px;
  158. line-height: 1;
  159. white-space: pre-wrap;
  160. }
  161. </style>