You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dianshang-qianduan/src/layout/components/Navbar.vue

552 lines
14 KiB
Vue

5 years ago
<template>
<div :class="['navbar', { 'teacher-navbar': role === 3 }]">
2 months ago
<div :class="[role !== 3 ? 'navTitle' : 'TnavTitle']">
<span class="nacber-name" v-if="role !== 3"></span>
<span class="nacber-name" v-else></span>
2 months ago
</div>
<div :class="['el-ment', { 'platform-nav': role === 1 || role === 2, 'school-admin-nav': role === 2, 'teacher-nav': role === 3 }]">
<template v-for="item in roleList" :key="item.name">
<div :class="['el-ment-item', { 'el-ment-item-active': isActive(item) }]" @click="go(item)">{{ item.name }}</div>
</template>
</div>
2 months ago
<div class="right-menu">
5 years ago
<div class="avatar-container">
2 months ago
<el-dropdown @command="handleCommand" class="right-menu-item hover-effect" trigger="click">
5 years ago
<div class="avatar-wrapper">
2 months ago
<img src="../../assets/images/头像.webp" class="user-avatar" />
5 years ago
<el-icon><caret-bottom /></el-icon>
</div>
<template #dropdown>
<el-dropdown-menu>
2 months ago
<!-- <router-link to="/user/profile">
5 years ago
<el-dropdown-item>个人中心</el-dropdown-item>
2 months ago
</router-link>-->
<el-dropdown-item @click="openProfile">
2 months ago
<span>个人中心</span>
5 years ago
</el-dropdown-item>
<el-dropdown-item divided command="logout">
5 years ago
<span>退出登录</span>
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
</div>
<el-dialog title="个人中心" custom-class="gdialog" v-model="showModel" width="40%" append-to-body>
2 months ago
<div class="dialog-content">
<el-form :model="form" label-width="80px" class="dialog-form">
<el-form-item :label="userStore.userInfo.roleId == 4 ? '姓名' : '教师姓名'">
<el-input v-model="form.name" disabled></el-input>
</el-form-item>
<el-form-item :label="userStore.userInfo.roleId == 4 ? '学号' : '工号'">
<el-input v-model="form.username" disabled></el-input>
</el-form-item>
2 months ago
<el-form-item :label="userStore.userInfo.roleId == 4 ? '院系' : '院系名称'">
<el-input v-model="form.schoolFacultyId" disabled></el-input>
</el-form-item>
<el-form-item :label="userStore.userInfo.roleId == 4 ? '专业' : '专业名称'">
<el-input v-model="form.schoolMajorId" disabled></el-input>
</el-form-item>
<el-form-item label="班级:">
<el-input v-model="form.schoolClassId" disabled></el-input>
</el-form-item>
<el-form-item label="密码:">
<el-input v-model="form.password" disabled></el-input>
</el-form-item>
<el-form-item label="新密码:">
<el-input v-model="form.passwords"></el-input>
</el-form-item>
</el-form>
</div>
<template #footer>
<span class="dialog-footers">
<el-button @click="showModel = false">取消</el-button>
<el-button @click="changePassword"></el-button>
</span>
</template>
</el-dialog>
5 years ago
</div>
</template>
<script setup>
import { ElMessageBox } from "element-plus";
import Breadcrumb from "@/components/Breadcrumb";
import TopNav from "@/components/TopNav";
import Hamburger from "@/components/Hamburger";
import Screenfull from "@/components/Screenfull";
import SizeSelect from "@/components/SizeSelect";
import HeaderSearch from "@/components/HeaderSearch";
import RuoYiGit from "@/components/RuoYi/Git";
import RuoYiDoc from "@/components/RuoYi/Doc";
import useAppStore from "@/store/modules/app";
import useUserStore from "@/store/modules/user";
import useSettingsStore from "@/store/modules/settings";
import * as indexApi from "@/api/teacher";
import { getStudentDemoSession, isStudentDemo } from "@/utils/studentDemo";
2 months ago
const { proxy } = getCurrentInstance();
const router = useRouter();
const appStore = useAppStore();
const userStore = useUserStore();
const settingsStore = useSettingsStore();
const showModel = ref(false);
const form = ref({});
const role = computed(() => Number(userStore.userInfo.roleId));
2 months ago
const mentList = ref([
{
name: "首页",
path: "/index",
},
{
name: "学校管理",
path: "/platform-schools/index",
role: 1,
activePrefix: "/platform-schools",
},
{
name: "教师管理",
path: "/platform-teachers/index",
role: 1,
activePrefix: "/platform-teachers",
},
{
name: "实训任务管理",
path: "/platform-training-task/index",
role: 1,
activePrefix: "/platform-training-task",
},
{
name: "院系管理",
path: "/admin-faculty/index",
role: 2,
activePrefix: "/admin-faculty",
},
{
name: "专业管理",
path: "/admin-major/index",
role: 2,
activePrefix: "/admin-major",
},
{
name: "班级管理",
path: "/admin-class/index",
role: 2,
activePrefix: "/admin-class",
},
{
name: "教师管理",
path: "/admin-teacher/index",
role: 2,
activePrefix: "/admin-teacher",
},
{
name: "学生管理",
path: "/admin-student/index",
role: 2,
activePrefix: "/admin-student",
},
{
name: "实验报告",
path: "/report/index",
2 months ago
role: 4,
},
{
name: "BI可视化",
path: "/bi",
2 months ago
role: 4,
},
{
name: "AI学情分析",
path: "/analysis/index",
},
{
name: "AI实训教案",
path: "/ai/teaching-plan",
role: 3,
},
{
name: "院系管理",
path: "/school/index",
role: 3,
teacherMenu: true,
activePrefix: "/school",
},
{
name: "专业管理",
path: "/major/index",
role: 3,
teacherMenu: true,
activePrefix: "/major",
},
{
name: "班级管理",
path: "/class/index",
role: 3,
teacherMenu: true,
activePrefix: "/class",
},
{
name: "教师管理",
path: "/teacher/index",
role: 3,
teacherMenu: true,
activePrefix: "/teacher",
},
{
name: "学生管理",
path: "/student/index",
role: 3,
teacherMenu: true,
activePrefix: "/student",
},
{
name: "任务分配",
path: "/task/index",
role: 3,
teacherMenu: true,
activePrefix: "/task",
},
{
name: "成绩中心",
path: "/score/index",
role: 3,
teacherMenu: true,
activePrefix: "/score",
},
]);
2 months ago
const activement = ref(mentList.value[0]);
5 years ago
function toggleSideBar() {
appStore.toggleSideBar();
5 years ago
}
function handleCommand(command) {
switch (command) {
case "setLayout":
openProfile();
break;
case "logout":
logout();
break;
default:
break;
}
}
5 years ago
function logout() {
ElMessageBox.confirm("确定注销并退出系统吗?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
userStore.logOut().then(() => {
location.href = "/index";
});
5 years ago
})
.catch(() => {});
5 years ago
}
2 months ago
// const emits = defineEmits(["setLayout"]);
function openProfile() {
getUserInfo();
showModel.value = true;
}
const go = (item) => {
if (router.currentRoute.value.path === item.path) {
return;
}
activement.value = item;
router.push(item.path);
};
const isActive = (item) => {
return item.activePrefix ? router.currentRoute.value.path.startsWith(item.activePrefix) : item.path === router.currentRoute.value.path;
};
// 根据角色显示菜单
const roleList = computed(() => {
const currentRole = role.value;
if (currentRole === 3) {
const teacherOrder = ["/index", "/analysis/index", "/ai/teaching-plan"];
return teacherOrder.map((path) => mentList.value.find((item) => item.path === path)).filter(Boolean);
}
return mentList.value.filter((item) => {
if (currentRole === 1) {
return item.path === "/index" || item.role === 1;
}
if (currentRole === 2) {
return item.path === "/index";
}
if (!item.role || item.path === "/index" || item.path === "/analysis/index") return true;
return item.role == currentRole;
});
});
2 months ago
// 获取用户详情
const getUserInfo = () => {
if (isStudentDemo()) {
const demoUser = getStudentDemoSession()?.userInfo || userStore.userInfo;
form.value = {
name: demoUser.name || "演示学生",
username: demoUser.username || "",
schoolFacultyId: "演示模式",
schoolMajorId: "演示模式",
schoolClassId: demoUser.className || "教学班",
password: "******",
passwords: "",
};
return;
}
if (role.value === 1) {
form.value = {
name: userStore.userInfo.name,
username: userStore.userInfo.username,
schoolFacultyId: "平台级账号",
schoolMajorId: "平台级账号",
schoolClassId: "无",
password: "******",
passwords: "",
};
return;
}
indexApi
.getInfo({ userId: userStore.userInfo.userId })
2 months ago
.then((res) => {
form.value = res.data;
})
.catch(() => {});
};
// 修改密码
const changePassword = () => {
if (isStudentDemo()) {
proxy.$modal.msgWarning("演示模式不支持修改密码");
return;
}
indexApi
2 months ago
.updatePassword({ userId: userStore.userInfo.userId, password: form.value.passwords })
.then(() => {
proxy.$modal.msgSuccess("修改成功");
showModel.value = false;
getUserInfo();
})
.catch(() => {});
};
onMounted(() => {
getUserInfo();
});
5 years ago
</script>
<style lang="scss" scoped>
5 years ago
.navbar {
2 months ago
width: 100%;
5 years ago
height: 50px;
overflow: hidden;
2 months ago
position: fixed;
5 years ago
background: #fff;
box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
2 months ago
background: url("@/assets/images/top.png") no-repeat;
background-size: 100% 100%;
.navTitle {
z-index: 1;
position: fixed;
top: 0;
background-size: 100% 100%;
.nacber-name {
height: 42px;
display: flex;
// justify-content: center;
align-items: center;
font-family: Source Han Sans CN;
font-weight: bold;
color: #ffffff;
font-size: 27px;
margin-left: 10px;
margin-top: 3px;
letter-spacing: 4px;
}
}
.TnavTitle {
background: url("../assets/images/top1.png");
background-size: 100% 100% !important;
box-shadow: 0 1px 4px #00152914;
position: fixed;
width: 100%;
z-index: 1000;
padding: 5px 20px;
span {
font-size: 26px;
font-family: Source Han Sans CN;
font-weight: 700;
color: #fff;
line-height: 50px;
}
}
5 years ago
.hamburger-container {
line-height: 46px;
height: 100%;
float: left;
cursor: pointer;
transition: background 0.3s;
-webkit-tap-highlight-color: transparent;
&:hover {
background: rgba(0, 0, 0, 0.025);
}
}
.breadcrumb-container {
float: left;
}
.topmenu-container {
position: absolute;
left: 50px;
}
.errLog-container {
display: inline-block;
vertical-align: top;
}
2 months ago
.el-ment {
position: absolute;
left: 45%;
top: 50%;
transform: translate(-50%, -50%);
font-size: 20px;
color: #fff;
font-weight: bold;
display: flex;
gap: 18px;
align-items: center;
white-space: nowrap;
.el-ment-item {
padding: 6px 16px;
border: 1px solid transparent;
border-radius: 999px;
cursor: pointer;
line-height: 1;
transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
&:hover {
color: #9ee7ff;
border-color: rgba(0, 170, 255, 0.42);
background: rgba(0, 124, 204, 0.18);
}
}
.el-ment-item-active {
color: #9ee7ff;
border-color: rgba(0, 170, 255, 0.68);
background: linear-gradient(90deg, rgba(0, 143, 254, 0.32), rgba(10, 92, 134, 0.2));
box-shadow: inset 0 0 12px rgba(0, 170, 255, 0.12);
}
&.platform-nav {
gap: 14px;
}
&.school-admin-nav {
left: 55%;
gap: 8px;
font-size: 16px;
.el-ment-item {
padding: 6px 10px;
}
}
&.teacher-nav {
left: 53%;
z-index: 1002;
max-width: calc(100vw - 560px);
gap: 8px;
font-size: 15px;
overflow-x: auto;
overflow-y: hidden;
padding: 4px 2px;
scrollbar-width: none;
&::-webkit-scrollbar {
display: none;
}
.el-ment-item {
padding: 7px 10px;
color: #cde9ff;
border-color: rgba(94, 207, 255, 0.12);
background: rgba(0, 98, 154, 0.08);
}
.el-ment-item-active {
color: #ffffff;
border-color: rgba(70, 202, 255, 0.8);
background: linear-gradient(95deg, rgba(0, 174, 255, 0.34), rgba(36, 96, 255, 0.18));
box-shadow: 0 0 16px rgba(0, 174, 255, 0.24), inset 0 0 14px rgba(133, 217, 255, 0.12);
}
}
}
5 years ago
.right-menu {
float: right;
height: 100%;
line-height: 50px;
display: flex;
&:focus {
outline: none;
}
.right-menu-item {
display: inline-block;
padding: 0 8px;
height: 100%;
font-size: 18px;
color: #5a5e66;
vertical-align: text-bottom;
&.hover-effect {
cursor: pointer;
transition: background 0.3s;
&:hover {
background: rgba(0, 0, 0, 0.025);
}
}
}
.avatar-container {
margin-right: 40px;
.avatar-wrapper {
margin-top: 5px;
position: relative;
.user-avatar {
cursor: pointer;
width: 40px;
height: 40px;
border-radius: 10px;
}
i {
cursor: pointer;
position: absolute;
right: -20px;
top: 25px;
font-size: 12px;
}
}
}
}
}
.teacher-navbar {
background: linear-gradient(180deg, rgba(5, 17, 31, 0.96), rgba(5, 20, 35, 0.9)) !important;
border-bottom: 1px solid rgba(60, 192, 255, 0.34);
box-shadow: 0 8px 24px rgba(0, 8, 20, 0.35);
backdrop-filter: blur(14px);
.TnavTitle {
background: linear-gradient(90deg, rgba(0, 102, 180, 0.38), rgba(4, 18, 35, 0.2) 58%, transparent) !important;
box-shadow: none;
width: 470px;
z-index: 1001;
span {
font-size: 22px;
letter-spacing: 2px;
text-shadow: 0 0 14px rgba(80, 200, 255, 0.28);
}
}
.right-menu {
position: relative;
z-index: 1003;
}
.avatar-container {
margin-right: 28px !important;
}
}
</style>