浏览代码

后台任务

xiaochan 4 月之前
父节点
当前提交
b9a6b829f7

+ 1 - 7
src/layout/HeaderV2/BackgroundTask.vue

@@ -12,13 +12,7 @@ type TaskValue = {
 
 const store: {
   [key: string]: TaskValue;
-} = reactive({
-  test: {
-    name: "TaskValue",
-    id: "test",
-    percentage: 10,
-  },
-});
+} = reactive({});
 
 function handleClose(data: TaskValue) {
   const key = data.id || data.name;

+ 31 - 36
src/layout/HeaderV2/ScrollNotifications.vue

@@ -30,14 +30,11 @@ import { ref, onMounted, Ref, nextTick, watch } from "vue";
 import { setCallback } from "@/utils/websocket";
 import { getSystemAnnouncement } from "@/api/public-api";
 
-const props = defineProps({
-  data: Object,
-});
 const adRef: Ref<HTMLElement> = ref(null);
 
-const scrollStyle: object = ref({
-  "--xc-translateX": 0,
-  "--xc-width": 40,
+const scrollStyle = ref({
+  "--xc-translateX": 0 as number | string,
+  "--xc-width": 40 as number | string,
 });
 let marginRight = 40;
 
@@ -46,46 +43,44 @@ const data = ref({
   scrollingMessages: "",
 });
 
-watch(
-  () => data.value,
-  async () => {
-    await nextTick();
-    if (data.value.systemUpdatesMessage || data.value.scrollingMessages) {
-      adRef.value.style.display = null;
-      scrollStyle.value["--xc-width"] = "max-content";
-    } else {
-      adRef.value.style.display = "none";
-      scrollStyle.value["--xc-width"] = "30px";
-    }
-    adRef.value.innerHTML = null;
-    let div1 = document.createElement("div");
-    let html = `
+const handleScroll = async () => {
+  await nextTick();
+  if (data.value.systemUpdatesMessage || data.value.scrollingMessages) {
+    adRef.value.style.display = null;
+    scrollStyle.value["--xc-width"] = "max-content";
+  } else {
+    adRef.value.style.display = "none";
+    scrollStyle.value["--xc-width"] = "30px";
+  }
+  adRef.value.innerHTML = null;
+  let div1 = document.createElement("div");
+  let html = `
     <span style="color: red">${data.value.systemUpdatesMessage ? data.value.systemUpdatesMessage : ""}</span>
     <span style="color: #0a84fd">${data.value.scrollingMessages ? data.value.scrollingMessages : ""}</span>
   `;
-    div1.innerHTML = html;
-    adRef.value.append(div1);
-    let width = div1.clientWidth;
-    if (width >= 220) {
-      div1.style.marginRight = "40px";
-      div1.className = "scroll_system_message";
-      await nextTick();
-      scrollStyle.value["--xc-translateX"] = -(width + marginRight) + "px";
-      let div2 = document.createElement("div");
-      div2.innerHTML = html;
-      div2.className = "scroll_system_message";
-      adRef.value.append(div2);
-    }
-  },
-  { immediate: true }
-);
+  div1.innerHTML = html;
+  adRef.value.append(div1);
+  let width = div1.clientWidth;
+  if (width >= 220) {
+    div1.style.marginRight = "40px";
+    div1.className = "scroll_system_message";
+    await nextTick();
+    scrollStyle.value["--xc-translateX"] = -(width + marginRight) + "px";
+    let div2 = document.createElement("div");
+    div2.innerHTML = html;
+    div2.className = "scroll_system_message";
+    adRef.value.append(div2);
+  }
+};
 
 onMounted(() => {
   setCallback("systemAnnouncement", async ({ data: res }) => {
     data.value = res;
+    handleScroll();
   });
   getSystemAnnouncement().then(res => {
     data.value = res;
+    handleScroll();
   });
 });
 </script>

+ 41 - 42
src/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/components/out-component/EmrKickedB.vue

@@ -1,12 +1,11 @@
 <script setup lang="ts">
 import {
   emrRootContextKey,
-  EmrStore
+  EmrStore,
 } from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-func/useEmrStore";
-import * as socketFun
-  from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/socket/useEmrSocket";
+import * as socketFun from "@/views/hospitalization/zhu-yuan-yi-sheng/electronic-medical-record/emr-editor/socket/useEmrSocket";
 import warning from "@/assets/warning.png";
-import {useIntervalFn} from "@vueuse/core";
+import { useIntervalFn } from "@vueuse/core";
 
 const root = inject(emrRootContextKey) as EmrStore;
 const showButton = ref(true);
@@ -19,7 +18,7 @@ function handleOpen() {
   root.kicked.b.message = [];
   root.kicked.b.wsSend({
     code: socketFun.KickedType.openDialog,
-    data: null
+    data: null,
   });
   const link = document.querySelector("link[rel~='icon']") as HTMLLinkElement;
   oldHighlightConfig.title = document.title;
@@ -29,22 +28,22 @@ function handleOpen() {
 }
 
 const saveTimesOut = useIntervalFn(
-    () => {
-      frequency.value--;
-      if (frequency.value === 1) {
-        saveTimesOut.pause();
-        agree();
-        return;
-      }
-      root.kicked.b.wsSend({
-        code: socketFun.KickedType.countDown,
-        data: frequency.value,
-      });
-    },
-    1000,
-    {
-      immediate: false,
+  () => {
+    frequency.value--;
+    if (frequency.value === 1) {
+      saveTimesOut.pause();
+      agree();
+      return;
     }
+    root.kicked.b.wsSend({
+      code: socketFun.KickedType.countDown,
+      data: frequency.value,
+    });
+  },
+  1000,
+  {
+    immediate: false,
+  }
 );
 
 const oldHighlightConfig = {
@@ -55,17 +54,17 @@ const oldHighlightConfig = {
   link: document.querySelector("link[rel~='icon']") as HTMLLinkElement,
 };
 
-const {pause, resume} = useIntervalFn(
-    () => {
-      // @ts-ignore
-      oldHighlightConfig.link.href = warning;
-      oldHighlightConfig.toggleTitle = !oldHighlightConfig.toggleTitle;
-      document.title = oldHighlightConfig.toggleTitle
-          ? "有人需要编辑当前病历"
-          : "\u200E\u200E";
-    },
-    1000,
-    {immediate: false}
+const { pause, resume } = useIntervalFn(
+  () => {
+    // @ts-ignore
+    oldHighlightConfig.link.href = warning;
+    oldHighlightConfig.toggleTitle = !oldHighlightConfig.toggleTitle;
+    document.title = oldHighlightConfig.toggleTitle
+      ? "有人需要编辑当前病历"
+      : "\u200E\u200E";
+  },
+  1000,
+  { immediate: false }
 );
 
 function closed() {
@@ -92,13 +91,13 @@ function agree() {
 
 <template>
   <el-dialog
-      v-model="root.kicked.b.dialog"
-      :title="root.kicked.b.title"
-      :close-on-click-modal="false"
-      :close-on-press-escape="false"
-      :show-close="false"
-      @open="handleOpen"
-      @closed="closed"
+    v-model="root.kicked.b.dialog"
+    :title="root.kicked.b.title"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    :show-close="false"
+    @open="handleOpen"
+    @closed="closed"
   >
     <div class="refresh_countdown">
       倒计时结束未响应,强制同意,剩余【{{ frequency }}】 秒
@@ -107,10 +106,10 @@ function agree() {
     <div>
       <ul class="refresh_infinite-list" style="overflow: auto">
         <li
-            v-for="i in root.kicked.b.message"
-            :key="i"
-            class="refresh_infinite-list-item"
-            :class="`type-${i.type}`"
+          v-for="i in root.kicked.b.message"
+          :key="i"
+          class="refresh_infinite-list-item"
+          :class="`type-${i.type}`"
         >
           {{ i.message }}
         </li>