App.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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. import { setupAutoLogoutOnClose } from "@/utils/auto-logout-on-close";
  26. const progressBarStore = useProgressBarStore();
  27. const systemStore = useSystemStore();
  28. useChangeToken();
  29. progressBarStore.initialize({
  30. title: "数据上传",
  31. isOpen: false,
  32. abnormalClosing: false,
  33. });
  34. function avatarNotification(data) {
  35. const message = (
  36. <div>
  37. <div>科室: {data.deptName}</div>
  38. <div>{data.msg}</div>
  39. </div>
  40. );
  41. ElNotification({
  42. icon: (
  43. <img
  44. src={data.avatar}
  45. style={{ width: "32px", height: "32px", borderRadius: "16px" }}
  46. alt=""
  47. />
  48. ),
  49. title: data.title,
  50. message: message,
  51. dangerouslyUseHTMLString: true,
  52. duration: 0,
  53. });
  54. }
  55. function checkTheCallbacks({ data, isAdd }) {
  56. const message = (
  57. <table style="width: 100%">
  58. <tbody>
  59. <tr>
  60. <td style="padding-right: 8px">患者:</td>
  61. <td>{data.patientName}</td>
  62. </tr>
  63. <tr>
  64. <td style="padding-right: 8px">检查名称:</td>
  65. <td>{data.reqName}</td>
  66. </tr>
  67. <tr>
  68. <td style="padding-right: 8px"> 报告时间:</td>
  69. <td>{formatDateToStr(data.reportTime)}</td>
  70. </tr>
  71. <tr>
  72. <td colspan="2" style="text-ali">
  73. <ElLink
  74. type="primary"
  75. target="_blank"
  76. href={`http://172.16.32.122:8099/mReport?REQUISITIONID=${data.reqNo}`}
  77. >
  78. 查看图像
  79. </ElLink>
  80. </td>
  81. </tr>
  82. </tbody>
  83. </table>
  84. );
  85. ElNotification({
  86. title: isAdd ? "检查结果返回" : "修改检查结果",
  87. message: message,
  88. dangerouslyUseHTMLString: true,
  89. type: "success",
  90. position: "bottom-right",
  91. duration: 0,
  92. });
  93. }
  94. // function systemNotification(data) {
  95. // if (data.count) {
  96. // systemStore.addUnreadMessageCount(data.count);
  97. // }
  98. //
  99. // if (data.refreshDelay) {
  100. // sleep(data.refreshDelay).then(() => {
  101. // location.reload();
  102. // });
  103. // }
  104. //
  105. // if (data?.donTDisplay) {
  106. // return;
  107. // }
  108. //
  109. // ElNotification({
  110. // title: data.title ?? "新消息",
  111. // message: h(
  112. // "pre",
  113. // {
  114. // class: "message_pre",
  115. // },
  116. // data.message
  117. // ),
  118. // dangerouslyUseHTMLString: true,
  119. // type: data.type ?? "warning",
  120. // duration: 0,
  121. // position: 'bottom - right',
  122. // });
  123. // }
  124. let currentNotification;
  125. function systemNotification(data) {
  126. if (data.count) {
  127. systemStore.addUnreadMessageCount(data.count);
  128. }
  129. if (data.refreshDelay) {
  130. sleep(data.refreshDelay).then(() => {
  131. location.reload();
  132. });
  133. }
  134. if (data?.donTDisplay) {
  135. return;
  136. }
  137. if (currentNotification) {
  138. currentNotification.close();
  139. }
  140. currentNotification = ElNotification({
  141. title: data.title?? "新消息",
  142. message: h(
  143. "pre",
  144. {
  145. class: "message_pre",
  146. },
  147. data.message
  148. ),
  149. dangerouslyUseHTMLString: true,
  150. type: data.type?? "warning",
  151. duration: 0,
  152. position: 'bottom - right'
  153. });
  154. }
  155. onMounted(() => {
  156. useYfGroupStore().init();
  157. setCallback("refreshToken", data => {
  158. useUserStore().setToken(data.token);
  159. });
  160. setCallback("sidSingle", async () => {
  161. localStorage.clear();
  162. await router.push("/login");
  163. await ElMessageBox.alert(
  164. "您的账号已在其他地方登陆,如需修改密码请在个人中心中修改。",
  165. "提示",
  166. {
  167. type: "warning",
  168. }
  169. );
  170. });
  171. setCallback("criticalValue", data => {
  172. CyMessageBox.confirm({
  173. title: "患者危急值",
  174. message: data.message,
  175. type: "error",
  176. confirmButtonText: "前往处理",
  177. cancelButtonText: "关闭",
  178. })
  179. .then(() => {
  180. router.push(`/inpatient/zhuYuanYiSheng/criticalValue?id=${data.id}`);
  181. })
  182. .catch(() => {});
  183. });
  184. setCallback("systemNotification", systemNotification);
  185. setCallback("checkTheCallbacks", checkTheCallbacks);
  186. setCallback("avatarNotification", avatarNotification);
  187. // 设置浏览器关闭时自动退出账号
  188. const cleanupAutoLogout = setupAutoLogoutOnClose();
  189. // 组件卸载时清理事件监听器
  190. onUnmounted(cleanupAutoLogout);
  191. });
  192. </script>
  193. <style lang="scss">
  194. .message_pre {
  195. font-weight: normal;
  196. margin: 0;
  197. font-size: 14px;
  198. line-height: 1;
  199. white-space: pre-wrap;
  200. }
  201. </style>