index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <script setup lang="ts">
  2. import { ref } from "vue";
  3. import { noticesData } from "./data";
  4. import NoticeList from "./noticeList.vue";
  5. import { templateRef } from "@vueuse/core";
  6. import { Tabs, TabPane } from "@pureadmin/components";
  7. const dropdownDom = templateRef<ElRef | null>("dropdownDom", null);
  8. const activeName = ref(noticesData[0].name);
  9. const notices = ref(noticesData);
  10. let noticesNum = ref(0);
  11. notices.value.forEach(notice => {
  12. noticesNum.value += notice.list.length;
  13. });
  14. function tabClick() {
  15. // @ts-expect-error
  16. dropdownDom.value.handleOpen();
  17. }
  18. </script>
  19. <template>
  20. <el-dropdown ref="dropdownDom" trigger="click" placement="bottom-end">
  21. <span class="dropdown-badge navbar-bg-hover select-none">
  22. <el-badge :value="noticesNum" :max="99">
  23. <span class="header-notice-icon">
  24. <IconifyIconOffline icon="bell" />
  25. </span>
  26. </el-badge>
  27. </span>
  28. <template #dropdown>
  29. <el-dropdown-menu>
  30. <Tabs
  31. centered
  32. class="dropdown-tabs"
  33. v-model:activeName="activeName"
  34. @tabClick="tabClick"
  35. >
  36. <template v-for="item in notices" :key="item.key">
  37. <TabPane :tab="`${item.name}(${item.list.length})`">
  38. <el-scrollbar max-height="330px">
  39. <div class="noticeList-container">
  40. <NoticeList :list="item.list" />
  41. </div>
  42. </el-scrollbar>
  43. </TabPane>
  44. </template>
  45. </Tabs>
  46. </el-dropdown-menu>
  47. </template>
  48. </el-dropdown>
  49. </template>
  50. <style>
  51. .ant-tabs-dropdown {
  52. z-index: 2900 !important;
  53. }
  54. </style>
  55. <style lang="scss" scoped>
  56. .dropdown-badge {
  57. display: flex;
  58. align-items: center;
  59. justify-content: center;
  60. height: 48px;
  61. width: 60px;
  62. cursor: pointer;
  63. .header-notice-icon {
  64. font-size: 18px;
  65. }
  66. }
  67. .dropdown-tabs {
  68. width: 336px;
  69. background-color: #fff;
  70. box-shadow: 0 2px 8px rgb(0 0 0 / 15%);
  71. border-radius: 4px;
  72. :deep(.el-tabs__header) {
  73. margin: 0;
  74. }
  75. :deep(.el-tabs__nav-scroll) {
  76. display: flex;
  77. justify-content: center;
  78. }
  79. :deep(.el-tabs__nav-wrap)::after {
  80. height: 1px;
  81. }
  82. :deep(.noticeList-container) {
  83. padding: 15px 24px 0 24px;
  84. }
  85. }
  86. :deep(.ant-tabs-nav) {
  87. margin-bottom: 0;
  88. }
  89. </style>