libushang 5 meses atrás
pai
commit
20b1bdf0e3

+ 9 - 0
src/api/InformationReception/InformationReception.ts

@@ -78,4 +78,13 @@ export function getPhoneList() {
       url: '/api/info_publish/addressbook/alldepts',
       method: 'get'
   });
+}
+
+// 消息中心
+export function getUnreadMsgCount(data) {
+  return request({
+    url: "/api/info_publish/msg_center/unread_msg_count",
+    method: 'post',
+    data: data
+});
 }

+ 35 - 11
src/views/leader/index.vue

@@ -87,6 +87,7 @@
 import { onClickOutside } from "@vueuse/core";
 import { ref, reactive, onMounted, onUnmounted } from "vue";
 import { getActiveEventList } from "@/api/event";
+import { getUnreadMsgCount } from "@/api/InformationReception/InformationReception";
 import noticeImg from "@/assets/images/notice.png";
 import searchImg from "@/assets/images/search.png";
 import { useRouter } from "vue-router";
@@ -226,21 +227,44 @@ const handleClickItem = item => {
   searchList.value = [];
 };
 
+// 设置定时器,刷新统计数
+const fetchInterval = process.env.NODE_ENV === 'development' ? 60000 : 3000; // 每60秒刷新一次(刷新太频繁影响调试)
+let intervalId: any | null = null;
+const startFetchingData = () => {
+  if (!intervalId) {
+    intervalId = setInterval(() => {
+      fetchData();
+    }, fetchInterval);
+  }
+};
+
+const stopFetchingData = () => {
+  if (intervalId) {
+    clearInterval(intervalId);
+    intervalId = null;
+  }
+};
+
+const fetchData = async () => {
+  getUnreadMsgCount({"msg_types": "工作审批,在线点名,事件管理"}).then((res)=>{
+    menu.value.forEach((v)=>{
+      let obj = res.data.find(item=>item.name === v.name);
+      if(obj) {
+        v.num = obj.num;
+      }
+    })
+  })
+}
+
 onMounted(() => {
   initData();
-  // rollCallData.value = {
-  //   id: '11111',
-  //   time1: '2024-10-22 12:00:00'
-  // };
-  // show.value = true;
-  //if (!timer && !!rollCallData.value.time1) {
-  //  timer = setInterval(updateTime, 1000);
-  //}
+
+  // 统计数
+  fetchData();
+  startFetchingData();
 });
 onUnmounted(() => {
-  //if (!!timer) {
-  //  clearInterval(timer);
-  //}
+  stopFetchingData();
 });
 </script>
 

+ 39 - 29
src/views/worker/index.vue

@@ -92,14 +92,14 @@
 
 <script lang="ts" setup>
 import { onClickOutside } from "@vueuse/core";
-import { onMounted, reactive, ref } from "vue";
+import { onMounted, onUnmounted, reactive, ref } from "vue";
 import { selectTask } from "@/api/emergencyCommandMap/JointDuty";
 import searchImg from "@/assets/images/search.png";
 import { useRouter } from "vue-router";
 import closeImg from "@/assets/images/close.png";
 import { getPointInfoComprehensiveSearch } from "@/api/globalMap";
 import OnlineRollCall from "@/components/OnlineRollCall/index.vue";
-import { InformationList } from "@/api/InformationReception/InformationReception";
+import { InformationList, getUnreadMsgCount } from "@/api/InformationReception/InformationReception";
 
 const router = useRouter();
 const noticeBarState = reactive({
@@ -185,34 +185,7 @@ const initData = async() => {
 const handleInfo = (item) => {
   router.push("/infoDetails?id=" + item.id);
 }
-/*
-const initData = async () => {
-  try {
-    const sortOrder = "desc";
-    const sortBy = "creation_time";
-    const event_code = "YJSJ0000000001";
 
-    console.log("请求任务数据:", event_code);
-    const res = await selectTask({
-      sortOrder: sortOrder,
-      sortBy: sortBy,
-      event_code: event_code
-    });
-    if (res && res.data) {
-      noticeBarState.latestMessages = res.data.slice(0, 3).map(msg => ({
-        event_title: msg.event_title,
-        event_time: msg.event_time
-      }));
-      noticeBarState.show = true;
-    } else {
-      console.error("API response data is empty or invalid");
-    }
-  } catch (error) {
-    console.error("请求任务数据失败:", error);
-    noticeBarState.show = false; // 如果请求失败,不显示通知栏
-  }
-};
-*/
 // 搜索
 const searchBoxRef = ref();
 let showSearch = ref();
@@ -274,8 +247,45 @@ const handleClickItem = item => {
   finished.value = false;
   searchList.value = [];
 };
+
+// 设置定时器,刷新统计数
+const fetchInterval = process.env.NODE_ENV === 'development' ? 60000 : 3000; // 每60秒刷新一次(刷新太频繁影响调试)
+let intervalId: any | null = null;
+const startFetchingData = () => {
+  if (!intervalId) {
+    intervalId = setInterval(() => {
+      fetchData();
+    }, fetchInterval);
+  }
+};
+
+const stopFetchingData = () => {
+  if (intervalId) {
+    clearInterval(intervalId);
+    intervalId = null;
+  }
+};
+
+const fetchData = async () => {
+  getUnreadMsgCount({"msg_types": "巡查工作,在线点名,风险防控,数据管理"}).then((res)=>{
+    menu.value.forEach((v)=>{
+      let obj = res.data.find(item=>item.name === v.name);
+      if(obj) {
+        v.num = obj.num;
+      }
+    })
+  })
+}
+
 onMounted(() => {
   initData();
+
+  // 统计数
+  fetchData();
+  startFetchingData();
+});
+onUnmounted(() => {
+  stopFetchingData();
 });
 </script>