parent
f3795fedab
commit
3f2dc34dae
@ -0,0 +1,138 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<el-dropdown v-if="router.children" class="menu-item-box" trigger="hover">
|
||||||
|
<div
|
||||||
|
class="item-title"
|
||||||
|
:class="handleActive(router.path) ? 'dropdownActive' : ''"
|
||||||
|
>
|
||||||
|
{{ router.meta.title }}
|
||||||
|
</div>
|
||||||
|
<el-dropdown-menu slot="dropdown">
|
||||||
|
<el-dropdown-item
|
||||||
|
v-for="(item, itemIndex) in router.children"
|
||||||
|
:key="itemIndex"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-if="!item.children"
|
||||||
|
@click="handelePath(router.path, item.path)"
|
||||||
|
:class="handleActive(item.path) ? 'avtiveRouter' : ''"
|
||||||
|
>
|
||||||
|
<svg-icon
|
||||||
|
v-if="item.meta && item.meta.icon && item.meta.icon !== '#'"
|
||||||
|
:icon-class="item.meta.icon"
|
||||||
|
/>
|
||||||
|
<span style="margin-left: 6px">{{ item.meta.title }} </span>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<svg-icon
|
||||||
|
v-if="item.meta && item.meta.icon && item.meta.icon !== '#'"
|
||||||
|
:icon-class="item.meta.icon"
|
||||||
|
/>
|
||||||
|
<span style="margin-left: 6px">{{ item.meta.title }} </span>
|
||||||
|
<div
|
||||||
|
class="recursion"
|
||||||
|
v-for="(item2, item2Index) in item.children"
|
||||||
|
:key="item2Index"
|
||||||
|
>
|
||||||
|
<item
|
||||||
|
:router="item2"
|
||||||
|
:parentRouter="router.path + '/' + item.path"
|
||||||
|
></item>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-dropdown-item>
|
||||||
|
</el-dropdown-menu>
|
||||||
|
</el-dropdown>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-else
|
||||||
|
class="item-title"
|
||||||
|
@click="handelePath(parentRouter, router.path)"
|
||||||
|
:class="handleActive(router.path) ? 'avtiveRouter' : ''"
|
||||||
|
>
|
||||||
|
<span>{{ router.meta.title }} </span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import item from "./item.vue";
|
||||||
|
export default {
|
||||||
|
name: "item",
|
||||||
|
|
||||||
|
props: {
|
||||||
|
parentLevel: {
|
||||||
|
type: String,
|
||||||
|
default: "",
|
||||||
|
},
|
||||||
|
mainStyle: {
|
||||||
|
type: Object,
|
||||||
|
default: () => {},
|
||||||
|
},
|
||||||
|
parentRouter: {
|
||||||
|
type: "",
|
||||||
|
},
|
||||||
|
router: {
|
||||||
|
type: Object,
|
||||||
|
default: () => {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
item,
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
maxRouter: "",
|
||||||
|
};
|
||||||
|
},
|
||||||
|
mounted() {},
|
||||||
|
methods: {
|
||||||
|
handelePath(parent, children) {
|
||||||
|
console.log(parent, children);
|
||||||
|
this.$router.push(`${parent}/${children}`);
|
||||||
|
},
|
||||||
|
handleActive(path) {
|
||||||
|
return this.$route.path.includes(path);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@import "~@/assets/styles/element-variables.scss";
|
||||||
|
.item-title {
|
||||||
|
padding: 3px 10px;
|
||||||
|
font-size: 18px;
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: 24px;
|
||||||
|
margin: 0 5px;
|
||||||
|
color: #fff;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdownActive {
|
||||||
|
border-color: #fff !important;
|
||||||
|
background: hsla(0, 0%, 100%, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.recursion {
|
||||||
|
.item-title {
|
||||||
|
list-style: none;
|
||||||
|
padding: 0 20px;
|
||||||
|
margin: 0;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #606266;
|
||||||
|
cursor: pointer;
|
||||||
|
outline: none;
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
.item-title:hover {
|
||||||
|
// background-color: #ecf5ff;
|
||||||
|
color: $--color-primary !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.avtiveRouter {
|
||||||
|
color: $--color-primary !important;
|
||||||
|
// background: $--color-primary !important;
|
||||||
|
}
|
||||||
|
</style>
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue