PageOverview.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <div class="overview-container">
  3. <NotificationSlider
  4. class="overview-container__header"
  5. :notifications="notifications"
  6. @remove-notification="handleRemoveNotification"
  7. />
  8. <div class="overview-container__main">
  9. <div class="left-info-section">
  10. <WeatherCard class="weather-section" />
  11. <div class="left-info-section__bottom-box">
  12. <DisasterWarningRecords class="disaster-warning-records" />
  13. <div class="bottom-box--right-item">
  14. <DisasterCheckingLists class="disaster-checking-lists" />
  15. <NoticeAndRules class="notice-and-rules" />
  16. </div>
  17. </div>
  18. </div>
  19. <KeyMonitorArea class="right-info-section" />
  20. </div>
  21. </div>
  22. </template>
  23. <script setup lang="ts">
  24. import { onMounted, ref } from 'vue';
  25. import { useRouter } from 'vue-router';
  26. import NotificationSlider, { Notification } from '@/components/NotificationSlider.vue';
  27. import WeatherCard from './components/WeatherCard.vue';
  28. import DisasterWarningRecords from './components/DisasterWarningRecords.vue';
  29. import DisasterCheckingLists from './components/DisasterCheckingLists.vue';
  30. import NoticeAndRules from './components/NoticeAndRules.vue';
  31. import KeyMonitorArea from './components/KeyMonitorArea.vue';
  32. import { UnReadNoticeInfo, getUnReadNoticeInfoList, updateUnReadNoticeInfoStatus } from '@/api/disaster-overview';
  33. import { getUrlByInfoType, InfoType, UnReadNoticeInfoStatus } from './components/useUnReadNotice';
  34. // 消息轮播列表
  35. const unReadNoticeInfoList = ref<UnReadNoticeInfo[]>([]);
  36. const notifications = ref<Notification[]>([]);
  37. const router = useRouter();
  38. // 消息轮播点击跳转
  39. const handleRemoveNotification = (id: number) => {
  40. const targetInfoType = unReadNoticeInfoList.value.find((item) => item.id === id)?.infoType;
  41. const targetSourceId = unReadNoticeInfoList.value.find((item) => item.id === id)?.sourceId;
  42. if (!targetInfoType) return;
  43. if (targetInfoType === InfoType.NOTICE_AND_RULE) {
  44. router.push({
  45. path: getUrlByInfoType(targetInfoType),
  46. query: {
  47. id: targetSourceId,
  48. },
  49. });
  50. } else {
  51. router.push({
  52. path: getUrlByInfoType(targetInfoType),
  53. });
  54. }
  55. updateUnReadNoticeInfoStatus({
  56. id: id,
  57. status: UnReadNoticeInfoStatus.READ,
  58. });
  59. };
  60. onMounted(async () => {
  61. const res = await getUnReadNoticeInfoList();
  62. unReadNoticeInfoList.value = res;
  63. notifications.value = res.map((item) => ({
  64. id: item.id,
  65. title: item.infoOutline,
  66. time: item.createdAt,
  67. }));
  68. });
  69. </script>
  70. <style scoped lang="scss">
  71. .overview-container {
  72. width: 100%;
  73. height: 100%;
  74. .overview-container__header {
  75. width: 100%;
  76. height: 32px;
  77. background: #fffbe6;
  78. border-radius: 8px;
  79. border: 1px solid #fff1b8;
  80. margin-bottom: 10px;
  81. }
  82. .overview-container__main {
  83. width: 100%;
  84. height: calc(100% - 42px);
  85. display: flex;
  86. }
  87. }
  88. .left-info-section {
  89. width: 75%;
  90. height: 100%;
  91. display: flex;
  92. flex-direction: column;
  93. margin-right: 10px;
  94. .weather-section {
  95. margin-bottom: 10px;
  96. }
  97. .left-info-section__bottom-box {
  98. height: calc(100% - 277px);
  99. display: flex;
  100. .disaster-warning-records {
  101. width: 30%;
  102. margin-right: 10px;
  103. background: #fff;
  104. border-radius: 4px;
  105. }
  106. .bottom-box--right-item {
  107. width: calc(70% - 10px);
  108. .disaster-checking-lists {
  109. height: 65%;
  110. // background-color: #fff;
  111. border-radius: 4px;
  112. margin-bottom: 10px;
  113. }
  114. .notice-and-rules {
  115. height: calc(35% - 10px);
  116. background-color: #fff;
  117. border-radius: 4px;
  118. }
  119. }
  120. }
  121. }
  122. .right-info-section {
  123. width: 25%;
  124. height: 100%;
  125. background-color: #fff;
  126. border-radius: 4px;
  127. }
  128. </style>