App.vue 4.2 KB

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