|
@@ -2,32 +2,90 @@
|
|
|
<div class="headsBreadcrumb">
|
|
|
<el-breadcrumb separator-class="el-icon-arrow-right">
|
|
|
<el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
|
|
|
- <breadcrumbItem v-if="childrens !== null" :childrens="childrens"></breadcrumbItem>
|
|
|
+ <breadcrumbItem @itemClick="itemClick" v-if="childrens !== null" :childrens="childrens"></breadcrumbItem>
|
|
|
</el-breadcrumb>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { mapState, mapActions } from 'vuex';
|
|
|
import breadcrumbItem from './breadcrumb-item';
|
|
|
export default {
|
|
|
components: {
|
|
|
breadcrumbItem
|
|
|
},
|
|
|
- computed: {},
|
|
|
+ computed: {
|
|
|
+ ...mapState(['menusalls'])
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
- childrens: null
|
|
|
+ childrens: null,
|
|
|
+ activeIndex: ''
|
|
|
};
|
|
|
},
|
|
|
- mounted() {
|
|
|
+ async mounted() {
|
|
|
this.getSession();
|
|
|
+ await this.menusQueryAlls();
|
|
|
},
|
|
|
methods: {
|
|
|
+ ...mapActions(['menusQueryAlls']),
|
|
|
getSession() {
|
|
|
this.childrens = JSON.parse(sessionStorage.getItem('childrens'));
|
|
|
},
|
|
|
reset() {
|
|
|
this.getSession();
|
|
|
+ },
|
|
|
+ async itemClick(env) {
|
|
|
+ // 获取最后一级菜单
|
|
|
+ const last = await this.setactiveIndex(env);
|
|
|
+ // 赋值当前选选个
|
|
|
+ this.activeIndex = last?.code;
|
|
|
+ // 缓存写入当前一例菜单
|
|
|
+ this.$setParentsetSession({ menus: this.menusalls, iscode: last });
|
|
|
+ // 写入当前菜单编码
|
|
|
+ sessionStorage.setItem('code', this.activeIndex);
|
|
|
+ // 获取当前一例的顶级菜单编码
|
|
|
+ const parentCode = env.code.substring(0, 2);
|
|
|
+ // 如果编码 = 00 进入主页
|
|
|
+ if (env.code == '00') {
|
|
|
+ this.$router.push('/');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 如果编码 = 012(领导)进入领导页
|
|
|
+ if (env.code == '012') {
|
|
|
+ this.$router.push('/leader');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 如果编码 = 013(章程)进入章程页
|
|
|
+ if (env.code == '013') {
|
|
|
+ this.$router.push(`/constitution/${this.activeIndex}?parentCode=${parentCode}`);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 如果编码 = 014(机构)进入机构页
|
|
|
+ if (env.code == '014') {
|
|
|
+ this.$router.push(`/org/${this.activeIndex}?parentCode=${parentCode}`);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 类型为0(链接)跳转链接
|
|
|
+ if (env.type == '0') window.open(env.url);
|
|
|
+ // 类型为1(栏目)进入列表页
|
|
|
+ if (env.type == '1') this.$router.push(`/list/${this.activeIndex}?parentCode=${parentCode}`);
|
|
|
+ // 类型为2(单页)进入单页页面
|
|
|
+ if (env.type == '2') this.$router.push(`/pages/${env.code}?parentCode=${parentCode}`);
|
|
|
+ },
|
|
|
+ // 递归最后的菜单编码
|
|
|
+ async setactiveIndex (j) {
|
|
|
+ let item = {};
|
|
|
+ const children = k => {
|
|
|
+ const list = this.menusalls.filter(e => e.parentCode == k.code);
|
|
|
+ if (list.length > 0) {
|
|
|
+ children(list[0]);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ item = k;
|
|
|
+ };
|
|
|
+ children(j);
|
|
|
+ return item;
|
|
|
}
|
|
|
}
|
|
|
};
|