From cc4f8046f4fab83306e7514367de7a6ad424e493 Mon Sep 17 00:00:00 2001
From: zhanghua <314079846@qq.com>
Date: 星期二, 28 十月 2025 22:59:05 +0800
Subject: [PATCH] 班级考勤汇总表
---
src/layout/components/Navbar.vue | 61 ++++++++++++++++--------------
1 files changed, 33 insertions(+), 28 deletions(-)
diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue
index b28233e..e9918c7 100644
--- a/src/layout/components/Navbar.vue
+++ b/src/layout/components/Navbar.vue
@@ -1,10 +1,6 @@
<template>
<div class="navbar">
- <hamburger
- :is-active="sidebar.opened"
- class="hamburger-container"
- @toggleClick="toggleSideBar"
- />
+ <hamburger :is-active="sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" />
<breadcrumb class="breadcrumb-container" />
<!-- 鍥哄畾鍙充笂瑙� -->
@@ -14,17 +10,13 @@
<el-dropdown trigger="click" ref="eldrop" style="margin-right: 20px">
<div class="avatar-wrapper" style="font-size: 20px">
{{ selectStaff ? selectStaff.org.name : "" }}-{{
- selectStaff ? selectStaff.sysRole.name : ""
+ selectStaff && selectStaff.sysRole ? selectStaff.sysRole.name : ""
}}
<i class="el-icon-caret-bottom"></i>
</div>
<el-dropdown-menu slot="dropdown" align="center">
- <el-dropdown-item
- v-for="item in staffs"
- @click.native="changeStaff(item)"
- :key="item.id"
- >
- {{ item ? item.org.name : "" }}-{{ item ? item.sysRole.name : "" }}
+ <el-dropdown-item v-for="item in staffs" @click.native="changeStaff(item)" :key="item.id">
+ {{ item ? item.org.name : "" }}-{{ item && item.sysRole ? item.sysRole.name : "" }}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
@@ -88,22 +80,33 @@
// await this.$store.dispatch('user/logout')
this.$router.push(`/login`);
},
- },
- beforeCreate() {
- const user = JSON.parse(localStorage.getItem("user"));
- if (!user) {
- this.$router.push(`/login`);
- }
+ loadStaffs() {
+ const selectStaff = JSON.parse(localStorage.getItem("selectStaff"));
+ if (selectStaff) {
+ this.selectStaff = selectStaff;
+ }
+ const staffs = JSON.parse(localStorage.getItem("staffs"));
+
+ console.log('Navbar-created');
+ if (staffs) {
+ this.staffs = staffs;
+ }
+ },
+ beforeCreate() {
+ const user = JSON.parse(localStorage.getItem("user"));
+ if (!user) {
+ this.$router.push(`/login`);
+ }
+ },
},
created() {
- const selectStaff = JSON.parse(localStorage.getItem("selectStaff"));
- if (selectStaff) {
- this.selectStaff = selectStaff;
- }
- const staffs = JSON.parse(localStorage.getItem("staffs"));
- if (staffs) {
- this.staffs = staffs;
- }
+ this.loadStaffs();
+ },
+ mounted() {
+ this.$EventBus.$on("updateStaffs", (data) => {
+
+ this.loadStaffs();
+ });
},
};
</script>
@@ -188,7 +191,9 @@
}
.el-dropdown-menu {
- max-height: 400px; /*璁剧疆鑿滃崟楂樺害涓�200px*/
- overflow-y: auto; /*璁剧疆婊氬姩鏉�*/
+ max-height: 400px;
+ /*璁剧疆鑿滃崟楂樺害涓�200px*/
+ overflow-y: auto;
+ /*璁剧疆婊氬姩鏉�*/
}
</style>
--
Gitblit v1.8.0