You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
2.2 KiB

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