Commit 73cde75d authored by 张俊's avatar 张俊

菜单处理及跳转

parent 26d00834
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
</template> </template>
<script> <script>
import bgMenu from "@/components/bg-menu.vue"; import bgMenu from "@/components/bg-menu/index.vue";
import login from "@/page/login/index.vue"; import login from "@/page/login/index.vue";
import page404 from "@/page/404.vue"; import page404 from "@/page/404.vue";
import register from "@/page/register/index.vue"; import register from "@/page/register/index.vue";
......
...@@ -26,7 +26,16 @@ ...@@ -26,7 +26,16 @@
@click="menuAction(item, item)"> @click="menuAction(item, item)">
<span> <span>
{{ item.menuName }} {{ item.menuName }}
<bg-icon
v-if="item.children && item.children.length && item.menuType !== 1"
icon="#bg-ic-arrow-down"
style="font-size: 8px; margin-left: 3px"></bg-icon>
</span> </span>
<menu-list
v-if="item.children && item.children.length"
:p_level="item.level"
:children="item.children"
:parent="item"></menu-list>
</div> </div>
</div> </div>
</div> </div>
...@@ -68,14 +77,16 @@ ...@@ -68,14 +77,16 @@
<script> <script>
import { mapState, mapMutations } from "vuex"; import { mapState, mapMutations } from "vuex";
import { clearCookie } from "../services/cookie.js"; import { clearCookie } from "@/services/cookie.js";
import { resetRouter } from "../router/index"; import { resetRouter } from "@/router/index";
import { getImageUrl } from "@/services/helper.js"; import { getImageUrl } from "@/services/helper.js";
import { normalizeProps } from "vue-demi"; import menuList from "./menu-list.vue";
export default { export default {
name: "BgMenu", name: "BgMenu",
components: {}, components: {
menuList,
},
props: { props: {
path: { path: {
type: String, type: String,
...@@ -506,6 +517,9 @@ export default { ...@@ -506,6 +517,9 @@ export default {
&:hover { &:hover {
background-color: #3753a4; background-color: #3753a4;
> .menu-list-main {
display: block;
}
} }
} }
} }
......
<template>
<div class="menu-list-main" :class="[p_level > 2 ? 'right' : 'bottom']">
<div class="menu-list" v-if="children && children.length > 0 && p_level <= 3">
<div
class="menu-item"
:class="{ hasChildren: item.children && item.children.length > 0 }"
@click.stop="childMenuAction(item)"
v-show="item.menuType !== 2"
v-for="item in children"
:key="item.id">
<div :title="item.menuName">
<span>{{ item.menuName }}</span>
<div class="menu-icon" v-if="item.children && item.children.length > 0 && item.level <= 3">
<bg-icon style="font-size: 10px" v-if="item.menuType == 0" icon="#bg-ic-arrow-right" />
</div>
</div>
<menu-list
v-if="children && children.length > 0"
:p_level="item.level"
:children="item.children"
:parent="item">
</menu-list>
</div>
</div>
</div>
</template>
<script>
export default {
name: "menuList", //给组件命名
};
</script>
<script setup>
import { ElMessage } from "element-plus";
import { useRouter } from "vue-router";
const router = useRouter();
const props = defineProps({
parent: {
type: Object,
default: () => ({}),
},
children: {
type: Array,
default: () => [],
},
p_level: {
type: Number,
default: 0,
},
});
const childMenuAction = (item) => {
// if (isDeveloping(item.path)) return;
// window.open(item.path);
router.push(item.path);
};
</script>
<style lang="scss" scoped>
.menu-list-main {
height: auto;
position: absolute;
z-index: 9;
display: none;
&.right {
width: auto;
left: 100%;
padding-left: 5px;
top: -4px;
> .menu-list {
width: auto !important;
}
}
&.bottom {
min-width: 100%;
width: auto;
padding-top: 5px;
top: 100%;
left: 0;
> .menu-list {
width: 100%;
}
}
}
.menu-list {
box-shadow: 0 4px 12px 0 rgba(18, 30, 63, 0.1);
background-color: #ffffff;
border-radius: 4px;
padding: 4px 0;
// z-index: 9;
text-align: center;
.menu-item {
width: auto;
height: 34px;
font-size: 14px;
line-height: 34px;
padding: 0 16px;
background-color: #fff;
color: #202531;
text-align: left;
white-space: nowrap;
position: relative;
&.hasChildren {
padding: 0 34px 0 16px;
}
.menu-icon {
width: 34px;
height: 34px;
display: flex;
align-items: center;
justify-content: center;
position: absolute;
right: 0;
top: 0;
transform: rotate(0);
transition: all 300ms;
}
&:hover {
background-color: #eff2fa;
> .menu-list-main {
display: block;
}
> div > .menu-icon {
transform: rotate(180deg);
}
}
.width-num {
display: inline-block;
vertical-align: middle;
min-width: 30px;
background-color: #ff6a00;
font-size: 10px;
line-height: 16px;
color: #fff;
padding: 0 8px;
margin-left: 5px;
box-sizing: border-box;
border-radius: 8px;
text-align: center;
overflow: hidden;
}
}
.menu-item {
cursor: pointer;
}
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment