|
@@ -11,33 +11,51 @@
|
|
>
|
|
>
|
|
{{ item.name }}
|
|
{{ item.name }}
|
|
</div>
|
|
</div>
|
|
|
|
+ <el-dropdown @command="handleCommand" class="avatar-dropdown" trigger="hover">
|
|
|
|
+ <div class="avatar-wrapper">
|
|
|
|
+ <img src="@/assets/images/人像.png" class="user-avatar" />
|
|
|
|
+ <p class="user-nickname"> {{ userStore.nickName }} </p>
|
|
|
|
+ <img src="@/assets/images/down箭头.png" class="user-icon">
|
|
|
|
+ </div>
|
|
|
|
+ <template #dropdown>
|
|
|
|
+ <el-dropdown-menu>
|
|
|
|
+ <router-link to="/user/profile">
|
|
|
|
+ <el-dropdown-item>个人中心</el-dropdown-item>
|
|
|
|
+ </router-link>
|
|
|
|
+ <el-dropdown-item divided command="logout">
|
|
|
|
+ <span>退出登录</span>
|
|
|
|
+ </el-dropdown-item>
|
|
|
|
+ </el-dropdown-menu>
|
|
|
|
+ </template>
|
|
|
|
+ </el-dropdown>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="yjContent">
|
|
<div class="yjContent">
|
|
- <div class="contentLeft" :class="{ collapsed: !leftItem }">
|
|
|
|
|
|
+ <div class="contentLeft" :class="{ collapsed: !leftItem}" v-show="showLeftMenu">
|
|
<div class="leftMenu">
|
|
<div class="leftMenu">
|
|
<el-menu
|
|
<el-menu
|
|
- default-active="2"
|
|
|
|
|
|
+ :default-active="currentRoute"
|
|
class="el-menu-vertical-demo"
|
|
class="el-menu-vertical-demo"
|
|
:collapse="isCollapse"
|
|
:collapse="isCollapse"
|
|
|
|
+ @select="handleMenuSelect"
|
|
|
|
+ :router="true"
|
|
>
|
|
>
|
|
<div class="leftTitle">
|
|
<div class="leftTitle">
|
|
- <template v-if="leftItem == true"
|
|
|
|
- >{{ menuLeftValue }}
|
|
|
|
|
|
+ <template v-if="leftItem">{{ menuLeftValue }}
|
|
<img
|
|
<img
|
|
src="/src/assets/images/left.png"
|
|
src="/src/assets/images/left.png"
|
|
alt=""
|
|
alt=""
|
|
class="imgLeft"
|
|
class="imgLeft"
|
|
- @click="imgLeftFn"
|
|
|
|
- /></template>
|
|
|
|
|
|
+ @click="imgLeftFn"/>
|
|
|
|
+ </template>
|
|
<template v-else>
|
|
<template v-else>
|
|
<img
|
|
<img
|
|
src="/src/assets/images/right.png"
|
|
src="/src/assets/images/right.png"
|
|
alt=""
|
|
alt=""
|
|
- @click="imgLeftFn"
|
|
|
|
- /></template>
|
|
|
|
|
|
+ @click="imgLeftFn"/>
|
|
|
|
+ </template>
|
|
</div>
|
|
</div>
|
|
- <template v-for="item in menuData" :key="item.index">
|
|
|
|
|
|
+ <template v-for="item in menuData[menuLeftValue]" :key="item.index">
|
|
<el-sub-menu v-if="item.children" :index="item.index">
|
|
<el-sub-menu v-if="item.children" :index="item.index">
|
|
<template #title>
|
|
<template #title>
|
|
<el-icon><component :is="item.icon" /></el-icon>
|
|
<el-icon><component :is="item.icon" /></el-icon>
|
|
@@ -51,7 +69,6 @@
|
|
{{ child.title }}
|
|
{{ child.title }}
|
|
</el-menu-item>
|
|
</el-menu-item>
|
|
</el-sub-menu>
|
|
</el-sub-menu>
|
|
-
|
|
|
|
<el-menu-item v-else :index="item.index">
|
|
<el-menu-item v-else :index="item.index">
|
|
<el-icon><component :is="item.icon" /></el-icon>
|
|
<el-icon><component :is="item.icon" /></el-icon>
|
|
<template #title>{{ item.title }}</template>
|
|
<template #title>{{ item.title }}</template>
|
|
@@ -60,56 +77,120 @@
|
|
</el-menu>
|
|
</el-menu>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
- <div class="contentRight" :class="{ collapsed: !leftItem }"></div>
|
|
|
|
|
|
+ <div class="contentRight" :class="{ collapsed: !leftItem }">
|
|
|
|
+ <router-view v-slot="{ Component, route }">
|
|
|
|
+ <transition name="fade-transform" mode="out-in">
|
|
|
|
+ <keep-alive >
|
|
|
|
+ <component v-if="!route.meta.link" :is="Component" :key="route.path"/>
|
|
|
|
+ </keep-alive>
|
|
|
|
+ </transition>
|
|
|
|
+ </router-view>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
import { ref, reactive, markRaw } from "vue";
|
|
import { ref, reactive, markRaw } from "vue";
|
|
-import {
|
|
|
|
- Document,
|
|
|
|
- Menu as IconMenu,
|
|
|
|
- Location,
|
|
|
|
- Setting,
|
|
|
|
-} from "@element-plus/icons-vue";
|
|
|
|
|
|
+import useUserStore from '@/store/modules/user'
|
|
|
|
+import {Setting} from "@element-plus/icons-vue";
|
|
|
|
+import { ElMessageBox } from 'element-plus'
|
|
|
|
+
|
|
|
|
+const routerInstance = useRouter();
|
|
|
|
+const userStore = useUserStore();
|
|
const menuLeftValue = ref("首页");
|
|
const menuLeftValue = ref("首页");
|
|
-const menuList = ref([
|
|
|
|
- {
|
|
|
|
- name: "首页",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- name: "值班管理",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- name: "水功能区",
|
|
|
|
- },
|
|
|
|
-]);
|
|
|
|
const leftItem = ref(true);
|
|
const leftItem = ref(true);
|
|
-const menuData = reactive([
|
|
|
|
- {
|
|
|
|
- index: "1",
|
|
|
|
- title: "事务管理",
|
|
|
|
- icon: markRaw(Location),
|
|
|
|
- children: [
|
|
|
|
- { index: "1-1", title: "item one" },
|
|
|
|
- { index: "1-2", title: "item two" },
|
|
|
|
- { index: "1-3", title: "item three" },
|
|
|
|
- ],
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- index: "2",
|
|
|
|
- title: "邮件管理",
|
|
|
|
- icon: markRaw(IconMenu),
|
|
|
|
- },
|
|
|
|
|
|
+const currentRoute = ref('/');
|
|
|
|
+const showLeftMenu = ref(false);
|
|
|
|
+const menuList = ref([
|
|
|
|
+ { name: "首页", path: "/YuJing/shouye/index" },
|
|
|
|
+ { name: "值班管理",path: "/YuJing/transaction/dutyRecord" },
|
|
|
|
+ { name: "水功能区"}
|
|
]);
|
|
]);
|
|
|
|
+const menuData = reactive({
|
|
|
|
+ "值班管理": [
|
|
|
|
+ {
|
|
|
|
+ index: "3",
|
|
|
|
+ title: "事务管理",
|
|
|
|
+ icon: markRaw(Setting),
|
|
|
|
+ children: [
|
|
|
|
+ { index: "3-1", title: "值班记录",icon: markRaw(Setting), path: "/YuJing/transaction/dutyRecord" },
|
|
|
|
+ { index: "3-2", title: "会商记录",icon: markRaw(Setting), path: "/YuJing/transaction/consultationRecord" }]
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ index: "4",
|
|
|
|
+ title: "邮件管理",
|
|
|
|
+ icon: markRaw(Setting),
|
|
|
|
+ }
|
|
|
|
+ ],
|
|
|
|
+ "水功能区": [
|
|
|
|
+ {
|
|
|
|
+ index: "5",
|
|
|
|
+ title: "监视告警",
|
|
|
|
+ icon: markRaw(Setting),
|
|
|
|
+ },
|
|
|
|
+ ]
|
|
|
|
+});
|
|
const isCollapse = ref(false);
|
|
const isCollapse = ref(false);
|
|
-function menuValueFn(val) {
|
|
|
|
- menuLeftValue.value = val.name;
|
|
|
|
-}
|
|
|
|
function imgLeftFn() {
|
|
function imgLeftFn() {
|
|
isCollapse.value = !isCollapse.value;
|
|
isCollapse.value = !isCollapse.value;
|
|
leftItem.value = !leftItem.value;
|
|
leftItem.value = !leftItem.value;
|
|
- console.log(leftItem.value, "3333");
|
|
|
|
|
|
+}
|
|
|
|
+const menuValueFn = (val) => {
|
|
|
|
+ menuLeftValue.value = val.name;
|
|
|
|
+ // 点击首页时隐藏左侧菜单
|
|
|
|
+ showLeftMenu.value = val.name === "首页" ? false : true;
|
|
|
|
+ if (val.path) {
|
|
|
|
+ routerInstance.push(val.path);
|
|
|
|
+ currentRoute.value = val.path;
|
|
|
|
+ };
|
|
|
|
+};
|
|
|
|
+function handleMenuSelect(index) {
|
|
|
|
+ // 查找对应的路径
|
|
|
|
+ let path = '/';
|
|
|
|
+ for (const category of Object.values(menuData)) {
|
|
|
|
+ for (const item of category) {
|
|
|
|
+ if (item.index === index) {
|
|
|
|
+ path = item.path || '/';
|
|
|
|
+ break;
|
|
|
|
+ };
|
|
|
|
+ if (item.children) {
|
|
|
|
+ const child = item.children.find(child => child.index === index);
|
|
|
|
+ if (child) {
|
|
|
|
+ path = child.path || '/';
|
|
|
|
+ break;
|
|
|
|
+ };
|
|
|
|
+ };
|
|
|
|
+ };
|
|
|
|
+ };
|
|
|
|
+ routerInstance.push(path);
|
|
|
|
+ currentRoute.value = path;
|
|
|
|
+};
|
|
|
|
+function handleCommand(command) {
|
|
|
|
+ switch (command) {
|
|
|
|
+ case "setLayout":
|
|
|
|
+ setLayout()
|
|
|
|
+ break
|
|
|
|
+ case "logout":
|
|
|
|
+ logout()
|
|
|
|
+ break
|
|
|
|
+ default:
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+function logout() {
|
|
|
|
+ ElMessageBox.confirm('确定注销并退出系统吗?', '提示', {
|
|
|
|
+ confirmButtonText: '确定',
|
|
|
|
+ cancelButtonText: '取消',
|
|
|
|
+ type: 'warning'
|
|
|
|
+ }).then(() => {
|
|
|
|
+ userStore.logOut().then(() => {
|
|
|
|
+ location.href = '/index'
|
|
|
|
+ })
|
|
|
|
+ }).catch(() => { })
|
|
|
|
+}
|
|
|
|
+const emits = defineEmits(['setLayout'])
|
|
|
|
+function setLayout() {
|
|
|
|
+ emits('setLayout')
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
<style scoped lang="scss">
|
|
<style scoped lang="scss">
|
|
@@ -145,6 +226,28 @@ function imgLeftFn() {
|
|
width: 100px;
|
|
width: 100px;
|
|
cursor: pointer;
|
|
cursor: pointer;
|
|
}
|
|
}
|
|
|
|
+ .avatar-dropdown{
|
|
|
|
+ position: absolute;
|
|
|
|
+ right: 10px;
|
|
|
|
+ top: 2.5%;
|
|
|
|
+ .avatar-wrapper{
|
|
|
|
+ display: flex;
|
|
|
|
+ align-items: center;
|
|
|
|
+ .user-avatar{
|
|
|
|
+ width: 40px;
|
|
|
|
+ height: 40px;
|
|
|
|
+ }
|
|
|
|
+ .user-nickname{
|
|
|
|
+ font-size: 14px;
|
|
|
|
+ padding: 0 10px;
|
|
|
|
+ color: #fff;
|
|
|
|
+ }
|
|
|
|
+ .user-icon{
|
|
|
|
+ width: 17px;
|
|
|
|
+ height: 10px;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.yjContent {
|
|
.yjContent {
|
|
@@ -200,10 +303,9 @@ function imgLeftFn() {
|
|
}
|
|
}
|
|
.contentRight {
|
|
.contentRight {
|
|
flex: 1;
|
|
flex: 1;
|
|
- // width: calc(90% - 10px);
|
|
|
|
|
|
+ transition: margin-left 0.3s;
|
|
height: 100%;
|
|
height: 100%;
|
|
margin-left: 10px;
|
|
margin-left: 10px;
|
|
- background: #ccc;
|
|
|
|
&.expanded {
|
|
&.expanded {
|
|
margin-left: 73px; /* 63px + 10px */
|
|
margin-left: 73px; /* 63px + 10px */
|
|
}
|
|
}
|
|
@@ -214,7 +316,7 @@ function imgLeftFn() {
|
|
<style>
|
|
<style>
|
|
.contentLeft .el-menu {
|
|
.contentLeft .el-menu {
|
|
height: 100%;
|
|
height: 100%;
|
|
- background: rgb(113, 184, 252);
|
|
|
|
|
|
+ background: rgb(74, 147, 245);
|
|
}
|
|
}
|
|
.contentLeft .el-sub-menu__title,
|
|
.contentLeft .el-sub-menu__title,
|
|
.contentLeft .el-menu-item {
|
|
.contentLeft .el-menu-item {
|