From 3f3d35d6d6445f9cc90a8cf7bb496bee7f465542 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期二, 06 一月 2026 17:12:09 +0800
Subject: [PATCH] fix: 会议管理页面合并

---
 src/layout/components/Navbar.vue |  255 ++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 214 insertions(+), 41 deletions(-)

diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue
index c9f516c..5e73968 100644
--- a/src/layout/components/Navbar.vue
+++ b/src/layout/components/Navbar.vue
@@ -1,31 +1,56 @@
 <template>
   <div class="navbar">
-    <hamburger id="hamburger-container" :is-active="getters.sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" />
-    <breadcrumb id="breadcrumb-container" class="breadcrumb-container" v-if="!$store.state.settings.topNav" />
-    <top-nav id="topmenu-container" class="topmenu-container" v-if="$store.state.settings.topNav" />
-
+    <div>
+      <hamburger id="hamburger-container" :is-active="appStore.sidebar.opened" class="hamburger-container"
+        @toggleClick="toggleSideBar" />
+      <breadcrumb v-if="!settingsStore.topNav" id="breadcrumb-container" class="breadcrumb-container" />
+    </div>
+    <!--    <top-nav v-if="settingsStore.topNav" id="topmenu-container" class="topmenu-container" />-->
+    <div class="center-menu">
+      <span class="label">{{ userStore.currentFactoryName }}</span>
+      <el-dropdown @command="handleFactoryChange" class="right-menu-item hover-effect" trigger="click">
+        <div>
+          <el-icon size="20">
+            <Switch />
+          </el-icon>
+        </div>
+        <template #dropdown>
+          <el-dropdown-menu>
+            <el-dropdown-item v-for="item in factoryList" :key="item.deptId" :command="item">
+              {{ item.deptName }}
+            </el-dropdown-item>
+          </el-dropdown-menu>
+        </template>
+      </el-dropdown>
+    </div>
     <div class="right-menu">
-      <template v-if="getters.device !== 'mobile'">
-        <header-search id="header-search" class="right-menu-item" />
-
-        <el-tooltip content="婧愮爜鍦板潃" effect="dark" placement="bottom">
-          <ruo-yi-git id="ruoyi-git" class="right-menu-item hover-effect" />
-        </el-tooltip>
-
-        <el-tooltip content="鏂囨。鍦板潃" effect="dark" placement="bottom">
-          <ruo-yi-doc id="ruoyi-doc" class="right-menu-item hover-effect" />
-        </el-tooltip>
-
-        <screenfull id="screenfull" class="right-menu-item hover-effect" />
-
-        <el-tooltip content="甯冨眬澶у皬" effect="dark" placement="bottom">
-          <size-select id="size-select" class="right-menu-item hover-effect" />
-        </el-tooltip>
-      </template>
+      <!-- 娑堟伅閫氱煡 -->
+      <el-popover
+        v-model:visible="notificationVisible"
+        :width="500"
+        placement="bottom-end"
+        trigger="click"
+        :popper-options="{ modifiers: [{ name: 'offset', options: { offset: [0, 10] } }] }"
+        popper-class="notification-popover"
+      >
+        <template #reference>
+          <div class="notification-container right-menu-item hover-effect">
+            <el-badge :value="unreadCount" :hidden="unreadCount === 0" class="notification-badge">
+              <el-icon :size="20" style="cursor: pointer;">
+                <Bell />
+              </el-icon>
+            </el-badge>
+          </div>
+        </template>
+        <NotificationCenter
+          @unreadCountChange="handleUnreadCountChange"
+          ref="notificationCenterRef"
+        />
+      </el-popover>
       <div class="avatar-container">
         <el-dropdown @command="handleCommand" class="right-menu-item hover-effect" trigger="click">
           <div class="avatar-wrapper">
-            <img :src="getters.avatar" class="user-avatar" />
+            <img :src="userStore.avatar" class="user-avatar" />
             <el-icon><caret-bottom /></el-icon>
           </div>
           <template #dropdown>
@@ -33,7 +58,7 @@
               <router-link to="/user/profile">
                 <el-dropdown-item>涓汉涓績</el-dropdown-item>
               </router-link>
-              <el-dropdown-item command="setLayout">
+              <el-dropdown-item command="setLayout" v-if="settingsStore.showSettings">
                 <span>甯冨眬璁剧疆</span>
               </el-dropdown-item>
               <el-dropdown-item divided command="logout">
@@ -49,6 +74,7 @@
 
 <script setup>
 import { ElMessageBox } from 'element-plus'
+import { Bell } from '@element-plus/icons-vue'
 import Breadcrumb from '@/components/Breadcrumb'
 import TopNav from '@/components/TopNav'
 import Hamburger from '@/components/Hamburger'
@@ -57,25 +83,39 @@
 import HeaderSearch from '@/components/HeaderSearch'
 import RuoYiGit from '@/components/RuoYi/Git'
 import RuoYiDoc from '@/components/RuoYi/Doc'
+import NotificationCenter from './NotificationCenter/index.vue'
+import useAppStore from '@/store/modules/app'
+import useUserStore from '@/store/modules/user'
+import useSettingsStore from '@/store/modules/settings'
+import { userLoginFacotryList } from "@/api/system/user.js"
+import Cookies from "js-cookie";
+import { decrypt } from "@/utils/jsencrypt"
 
-const store = useStore();
-const router = useRouter();
-const getters = computed(() => store.getters);
-
+const appStore = useAppStore()
+const userStore = useUserStore()
+const settingsStore = useSettingsStore()
+const factoryList = ref([])
+const notificationVisible = ref(false)
+const notificationCenterRef = ref(null)
+const unreadCount = ref(0)
 function toggleSideBar() {
-  store.dispatch('app/toggleSideBar')
+  appStore.toggleSideBar()
 }
+// const redirect = ref(undefined)
+// watch(route, (newRoute) => {
+//   redirect.value = newRoute.query && newRoute.query.redirect
+// }, { immediate: true })
 
 function handleCommand(command) {
   switch (command) {
     case "setLayout":
-      setLayout();
-      break;
+      setLayout()
+      break
     case "logout":
-      logout();
-      break;
+      logout()
+      break
     default:
-      break;
+      break
   }
 }
 
@@ -85,16 +125,93 @@
     cancelButtonText: '鍙栨秷',
     type: 'warning'
   }).then(() => {
-    store.dispatch('LogOut').then(() => {
-      location.href = '/index';
+    userStore.logOut().then(() => {
+      location.href = '/index'
     })
-  }).catch(() => { });
+  }).catch(() => { })
 }
 
 const emits = defineEmits(['setLayout'])
 function setLayout() {
-  emits('setLayout');
+  emits('setLayout')
 }
+
+function toggleTheme() {
+  settingsStore.toggleTheme()
+}
+
+function getUserLoginFacotryList() {
+  if (userStore.id) {
+    userLoginFacotryList({ userId: userStore.id }).then(res => {
+      console.log('res', res)
+      factoryList.value = res.data
+    })
+  } else {
+    factoryList.value = []
+  }
+}
+
+function handleFactoryChange(command) {
+  console.log('command', command)
+  handleLogin(command.deptId);
+}
+
+function handleLogin(currentFatoryId) {
+  const loginForm = {
+    username: Cookies.get("username"),
+    password: Cookies.get("password") === undefined ? null : decrypt(Cookies.get("password")),
+    currentFatoryId: currentFatoryId
+  }
+  userStore.loginCheckFactory(loginForm).then(res => {
+    forceReload();
+  }).catch((err) => {
+    console.log(err)
+  })
+}
+function forceReload() {
+  const currentUrl = window.location.origin + window.location.pathname;
+  const timestamp = new Date().getTime();
+  window.location.href = `${currentUrl}?reload=${timestamp}`;
+}
+
+getUserLoginFacotryList();
+
+// 娑堟伅閫氱煡鐩稿叧
+function handleUnreadCountChange(count) {
+  unreadCount.value = count
+}
+
+// 缁勪欢鎸傝浇鏃跺姞杞芥湭璇绘暟閲忓拰瀹氭椂鍒锋柊
+let unreadCountTimer = null
+onMounted(() => {
+  // 寤惰繜鍔犺浇锛岀‘淇濈粍浠跺凡娓叉煋
+  nextTick(() => {
+    if (notificationCenterRef.value) {
+      notificationCenterRef.value.loadUnreadCount()
+    }
+  })
+  // 瀹氭椂鍒锋柊鏈鏁伴噺锛堟瘡30绉掞級
+  unreadCountTimer = setInterval(() => {
+    if (notificationCenterRef.value) {
+      notificationCenterRef.value.loadUnreadCount()
+    }
+  }, 30000)
+})
+
+// 鐩戝惉 popover 鏄剧ず鐘舵�侊紝鎵撳紑鏃跺姞杞芥秷鎭垪琛�
+watch(notificationVisible, (val) => {
+  if (val && notificationCenterRef.value) {
+    nextTick(() => {
+      notificationCenterRef.value.loadMessages()
+    })
+  }
+})
+
+onUnmounted(() => {
+  if (unreadCountTimer) {
+    clearInterval(unreadCountTimer)
+  }
+})
 </script>
 
 <style lang='scss' scoped>
@@ -102,8 +219,24 @@
   height: 50px;
   overflow: hidden;
   position: relative;
-  background: #fff;
+  background: var(--navbar-bg);
   box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
+
+  .center-menu {
+    line-height: 50px;
+    position: absolute;
+    left: 50%;
+    transform: translateX(-50%);
+    display: flex;
+    align-items: center;
+
+    .label {
+      font-weight: bold;
+      font-size: 18px;
+      color: #333333;
+      margin-right: 10px;
+    }
+  }
 
   .hamburger-container {
     line-height: 46px;
@@ -147,7 +280,7 @@
       padding: 0 8px;
       height: 100%;
       font-size: 18px;
-      color: #5a5e66;
+      color: var(--navbar-text);
       vertical-align: text-bottom;
 
       &.hover-effect {
@@ -156,6 +289,32 @@
 
         &:hover {
           background: rgba(0, 0, 0, 0.025);
+        }
+      }
+
+      &.theme-switch-wrapper {
+        display: flex;
+        align-items: center;
+
+        svg {
+          transition: transform 0.3s;
+
+          &:hover {
+            transform: scale(1.15);
+          }
+        }
+      }
+    }
+
+    .notification-container {
+      margin-right: 20px;
+      display: flex;
+      align-items: center;
+      cursor: pointer;
+
+      .notification-badge {
+        :deep(.el-badge__content) {
+          border: none;
         }
       }
     }
@@ -171,14 +330,14 @@
           cursor: pointer;
           width: 40px;
           height: 40px;
-          border-radius: 10px;
+          border-radius: 50px;
         }
 
         i {
           cursor: pointer;
           position: absolute;
           right: -20px;
-          top: 25px;
+          top: 14px;
           font-size: 12px;
         }
       }
@@ -186,3 +345,17 @@
   }
 }
 </style>
+
+<style lang="scss">
+.notification-popover {
+  padding: 0 !important;
+  
+  .el-popover__title {
+    display: none;
+  }
+  
+  .el-popover__body {
+    padding: 0 !important;
+  }
+}
+</style>

--
Gitblit v1.9.3