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

330 lines
8.9 KiB
Vue

5 years ago
<template>
<div class="navbar">
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>
</div>
<div class="el-ment">
<template v-for="item in roleList" :key="item.name">
<div :class="['el-ment-item', { 'el-ment-item-active': item.path == $route.path }]" @click="go(item)">{{ item.name }}</div>
5 years ago
</template>
2 months ago
</div>
<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 command="setLayout">
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>
2 months ago
<el-dialog title="个人中心" custom-class="gdialog" v-model="showModel" width="40%">
<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.username" disabled></el-input>
</el-form-item>
<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.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";
2 months ago
import * as indexApi from "@/api/teacher";
const { proxy } = getCurrentInstance();
const router = useRouter();
const appStore = useAppStore();
const userStore = useUserStore();
const settingsStore = useSettingsStore();
2 months ago
const showModel = ref(false);
const form = ref({});
const mentList = ref([
{
name: "首页",
path: "/index",
},
{
name: "实验报告",
path: "/report/index",
role: 4,
},
{
name: "实验数据源",
path: "/data/index",
role: 4,
},
{
name: "BI可视化",
path: "/bi",
role: 4,
},
{
name: "AI学情分析",
path: "/analysis/index",
},
{
name: "AI实训教案",
path: "/ai/teaching-plan",
role: 3,
},
]);
const activement = ref(mentList.value[0]);
5 years ago
function toggleSideBar() {
appStore.toggleSideBar();
5 years ago
}
function handleCommand(command) {
switch (command) {
case "setLayout":
setLayout();
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"]);
5 years ago
function setLayout() {
2 months ago
showModel.value = true;
5 years ago
}
2 months ago
const go = (item) => {
activement.value = item;
router.push(item.path);
};
// 根据角色显示菜单
const roleList = computed(() => {
return mentList.value.filter((item) => {
if (!item.role || item.name === "首页" || item.name === "AI学情分析") return true;
return item.role == userStore.userInfo.roleId;
});
});
// 获取用户详情
const getUserInfo = () => {
indexApi
.getInfo({ userId: userStore.userInfo.userId })
.then((res) => {
form.value = res.data;
})
.catch(() => {});
};
// 修改密码
const changePassword = () => {
indexApi
.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: 30px;
.el-ment-item {
cursor: pointer;
&:hover {
color: #409eff;
}
}
.el-ment-item-active {
color: #409eff;
}
}
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;
}
}
}
}
}
</style>