|
@@ -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>
|
|
|
|