集优化项目工程代码提交

init
gongdi 4 years ago
parent a32438e379
commit 959acd19a1

@ -11,4 +11,26 @@ export default {
method:'get',
isTestLogin:false
},
/*
* 1.4.1用户名密码登录接口
* login_name 必填 string 登录名称base64后传输
* login_pwd 必填 string 登录密码base64后传输
* */
loginByLoginNameAndPassword:{
url:'intellioa/sys/login/loginByLoginNameAndPassword',
method:'post',
isTestLogin:false
},
/*
* 1.4.2根据person_ididentity_id获取用户上下文信息
* person_id 必填 string 登录名称base64后传输
* identity_id 必填 string 登录密码base64后传输
* */
getPersonInfo:{
url:'intellioa/sys/base/getPersonInfo',
method:'get',
isTestLogin:true
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 KiB

@ -6,29 +6,33 @@ const menuConfig = [
{
title: "首页",
path: "/homePage",
name: "home",
role: "all"
},
{
title: "整体概况",
path: "",
name: "whole",
path: "/whole",
name: "wholePage",
role: ["city", "county", "district"],
children: [
{
title: "全市概况",
path: "/whole/city",
name: "whole_city",
role: ["city"],
component: () => import("./page/businessPages/whole/city.vue"),
},
{
title: "区县概况",
path: "/whole/county",
name: "whole_county",
role: ["city", "county"],
component: () => import("./page/businessPages/whole/county.vue"),
},
{
title: "学区概况",
path: "/whole/district",
name: "whole_district",
role: ["city", "county", "district"],
component: () => import("./page/businessPages/whole/district.vue"),
}
@ -36,35 +40,154 @@ const menuConfig = [
},
{
title: "资源配置",
path: "",
name: "resources",
path: "/resources",
name: "resourcesPage",
role: ["city", "county", "district", "school"],
children: [
{
title: "全市概况",
path: "/resources/city",
name: "resources_city",
role: ["city"],
component: () => import("./page/businessPages/resources/city.vue"),
},
{
title: "区县概况",
path: "/resources/county",
name: "resources_county",
role: ["city", "county"],
component: () => import("./page/businessPages/resources/county.vue"),
},
{
title: "学区概况",
path: "/resources/district",
name: "resources_district",
role: ["city", "county", "district"],
component: () => import("./page/businessPages/resources/district.vue"),
},
{
title: "学校概况",
path: "/resources/school",
role: ["city", "county", "district","school"],
name: "resources_school",
role: ["city", "county", "district", "school"],
component: () => import("./page/businessPages/resources/school.vue"),
}
]
}
},
{
title: "队伍建设",
path: "/teamBuilding",
name: "teamBuildingPage",
role: ["city", "county", "district", "school"],
children: [
{
title: "全市概况",
path: "/teamBuilding/city",
name: "teamBuilding_city",
role: ["city"],
component: () => import("./page/businessPages/teamBuilding/city.vue"),
},
{
title: "区县概况",
path: "/teamBuilding/county",
name: "teamBuilding_county",
role: ["city", "county"],
component: () => import("./page/businessPages/teamBuilding/county.vue"),
},
{
title: "学区概况",
path: "/teamBuilding/district",
name: "teamBuilding_district",
role: ["city", "county", "district"],
component: () => import("./page/businessPages/teamBuilding/district.vue"),
},
{
title: "学校概况",
path: "/teamBuilding/school",
name: "teamBuilding_school",
role: ["city", "county", "district", "school"],
component: () => import("./page/businessPages/teamBuilding/school.vue"),
}
]
},
{
title: "课程建设",
path: "/courseBuilding",
name: "courseBuildingPage",
role: ["city", "county", "district", "school"],
component: () => import("./page/businessPages/courseBuilding/courseBuilding.vue"),
},
{
title: "特色创建",
path: "/specialSet",
name: "specialSetPage",
role: ["city", "county", "district", "school"],
children: [
{
title: "全市概况",
path: "/specialSet/city",
name: "specialSet_city",
role: ["city"],
component: () => import("./page/businessPages/specialSet/city.vue"),
},
{
title: "区县概况",
path: "/specialSet/county",
name: "specialSet_county",
role: ["city", "county"],
component: () => import("./page/businessPages/specialSet/county.vue"),
},
{
title: "学区概况",
path: "/specialSet/district",
name: "specialSet_district",
role: ["city", "county", "district"],
component: () => import("./page/businessPages/specialSet/district.vue"),
},
{
title: "学校概况",
path: "/specialSet/school",
name: "specialSet_school",
role: ["city", "county", "district", "school"],
component: () => import("./page/businessPages/specialSet/school.vue"),
}
]
},
{
title: "质量监测",
path: "/qualityMonitor",
name: "qualityMonitorPage",
role: ["city", "county", "district", "school"],
children: [
{
title: "全市概况",
path: "/qualityMonitor/city",
name: "qualityMonitor_city",
role: ["city"],
component: () => import("./page/businessPages/qualityMonitor/city.vue"),
},
{
title: "区县概况",
path: "/qualityMonitor/county",
name: "qualityMonitor_county",
role: ["city", "county"],
component: () => import("./page/businessPages/qualityMonitor/county.vue"),
},
{
title: "学区概况",
path: "/qualityMonitor/district",
name: "qualityMonitor_district",
role: ["city", "county", "district"],
component: () => import("./page/businessPages/qualityMonitor/district.vue"),
},
{
title: "学校概况",
path: "/qualityMonitor/school",
name: "qualityMonitor_school",
role: ["city", "county", "district", "school"],
component: () => import("./page/businessPages/qualityMonitor/school.vue"),
}
]
},
]
export default menuConfig;

@ -0,0 +1,17 @@
<template>
<div>
课程建设
</div>
</template>
<script>
export default{
data(){
return {}
}
}
</script>
<style></style>

@ -1,6 +1,6 @@
<template>
<div>
123
</div>
</template>
<script>

@ -0,0 +1,17 @@
<template>
<div>
全市概况
</div>
</template>
<script>
export default{
data(){
return {}
}
}
</script>
<style></style>

@ -0,0 +1,17 @@
<template>
<div>
区县概况
</div>
</template>
<script>
export default{
data(){
return {}
}
}
</script>
<style></style>

@ -0,0 +1,17 @@
<template>
<div>
学区概况
</div>
</template>
<script>
export default{
data(){
return {}
}
}
</script>
<style></style>

@ -0,0 +1,16 @@
<template>
<div>
学校概况
</div>
</template>
<script>
export default{
data(){
return {}
}
}
</script>
<style></style>

@ -0,0 +1,17 @@
<template>
<div>
全市概况
</div>
</template>
<script>
export default{
data(){
return {}
}
}
</script>
<style></style>

@ -0,0 +1,17 @@
<template>
<div>
区县概况
</div>
</template>
<script>
export default{
data(){
return {}
}
}
</script>
<style></style>

@ -0,0 +1,17 @@
<template>
<div>
学区概况
</div>
</template>
<script>
export default{
data(){
return {}
}
}
</script>
<style></style>

@ -0,0 +1,16 @@
<template>
<div>
学校概况
</div>
</template>
<script>
export default{
data(){
return {}
}
}
</script>
<style></style>

@ -0,0 +1,17 @@
<template>
<div>
全市概况
</div>
</template>
<script>
export default{
data(){
return {}
}
}
</script>
<style></style>

@ -0,0 +1,17 @@
<template>
<div>
区县概况
</div>
</template>
<script>
export default{
data(){
return {}
}
}
</script>
<style></style>

@ -0,0 +1,17 @@
<template>
<div>
学区概况
</div>
</template>
<script>
export default{
data(){
return {}
}
}
</script>
<style></style>

@ -0,0 +1,16 @@
<template>
<div>
学校概况
</div>
</template>
<script>
export default{
data(){
return {}
}
}
</script>
<style></style>

@ -0,0 +1,104 @@
<template>
<div class="banner-carousel-style">
<a-carousel autoplay ref="varousel">
<img style="width: 100%;height: 100%" v-for="item in imgArr" :key="item.src" :src="item.src"/>
</a-carousel>
<div class="home-page-menu-style">
<div v-for="menu in menus" :key="menu.name" class="home-menu-style">
{{menu.title}}
</div>
</div>
</div>
</template>
<script>
/*
* banner轮播组件
* */
import {Carousel} from "ant-design-vue";
export default{
data(){
return {
imgArr: [
{
title: "banner1",
src: require("../../assets/banner1.jpg")
},
{
title: "banner2",
src: require("../../assets/banner2.jpg")
}
],
menus: this.$store.state.userStore.menus.filter(menu => {
//
return menu.name !== 'home';
})
}
},
components: {
ACarousel: Carousel
}
}
</script>
<style scoped lang="scss">
.banner-carousel-style {
width: 100%;
height: auto;
position: relative;
.ant-carousel {
width: 100%;
height: 100%;
}
.ant-carousel .slick-slider {
width: 100%;
height: 100%;
}
.ant-carousel .slick-slider .slick-list {
width: 100%;
height: 100%;
}
.ant-carousel .slick-slider .slick-list .slick-track {
width: 100%;
height: 100%;
}
.ant-carousel .slick-slider .slick-list .slick-slider {
width: 100%;
height: 100%;
}
.ant-carousel .slick-slider .slick-list .slick-track div {
width: 100%;
height: 100%;
}
.ant-carousel .slick-slider .slick-list .slick-track div img {
width: 100%;
height: 100%;
}
.home-page-menu-style {
position: absolute;
width: 100%;
height: 6rem;
bottom: 0;
display: flex;
justify-content: center;
align-items: center;
.home-menu-style {
height: 5rem;
padding: 0.5rem 1rem;
background-color: black;
opacity: 0.5;
color: white;
margin-left: 1rem;
display: flex;
justify-content: center;
align-items: center;
font-size: 1.5rem;
font-weight: bolder;
border-radius: 5px;
cursor: pointer;
}
.home-menu-style:hover {
opacity: 1;
}
}
}
</style>

@ -0,0 +1,55 @@
<template>
<div class="home-page-bottom-style">
<div class="bottom-part-style">
<span class="title-span">长春市基础教育集优化发展管理服务平台</span>
</div>
<div class="bottom-part-style">
<div class="part-row-style">地址吉林省长春市自由大路696号</div>
<div class="part-row-style">电话0431-85616988</div>
<div class="part-row-style">邮编130000</div>
</div>
<div class="bottom-part-style">
<div class="part-row-style">EmailXXXXXX@168.com</div>
<div class="part-row-style">技术支持东北师大理想软件股份有限公司</div>
<div class="part-row-style">版权所有 Copright @ XXXX-XXXX</div>
</div>
</div>
</template>
<script>
export default{
data(){
return {}
}
}
</script>
<style scoped lang="scss">
.home-page-bottom-style{
width: 100%;
height: 8rem;
position: absolute;
bottom: 0;
background-color: #98acf8;
display: flex;
.bottom-part-style{
width: 33%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: white;
.title-span{
font-size: 1rem;
font-weight: bolder;
position: relative;
top: -10px;
}
.part-row-style{
width: 100%;
}
}
}
.home-page-bottom-style:hover{
background-color: #394af8;
}
</style>

@ -0,0 +1,116 @@
<template>
<div class="fixed-navigation-style" :style="{top:((windowHeight - 500)/2) + 'px'}">
<div v-for="menu in menus" :key="menu.iconType" class="menu-style" @mouseenter="mouseenter(menu)"
@mouseleave="mouseleave(menu)">
<span v-show="isOpen && !menu.isBigger">{{menu.title}}</span>
<a-icon v-show="!isOpen" :type="menu.iconType" :title="menu.title" class="menu-icon-style"></a-icon>
<div v-show="isOpen && menu.isBigger" class="menu-bigger-style">
<a-icon :type="menu.iconType" class="bigger-menu-icon-style"></a-icon>
<span>{{menu.title}}</span>
</div>
</div>
<div class="menu-style">
<a-icon :type="!isOpen?'menu-fold':'menu-unfold'"
class="menu-icon-style"
:title="!isOpen?'展开':'收起'"
@click="changeState"
/>
</div>
</div>
</template>
<script>
/*
* 首页定位导航组件
* */
import {Icon} from 'ant-design-vue';
export default{
data(){
return {
windowHeight: document.documentElement.clientHeight,//
isOpen: false,//
menus: [
{iconType: "read", title: "政策方针"},
{iconType: "solution", title: "会议动态"},
{iconType: "notification", title: "信息宣传"},
{iconType: "profile", title: "工作要点"},
{iconType: "apartment", title: "评估指标"},
{iconType: "line-chart", title: "评估结果"},
]
}
},
methods: {
/*
* 展开/收起
* */
changeState: function () {
this.isOpen = !this.isOpen;
},
/*
* 鼠标滑入
* */
mouseenter: function (menu) {
if (this.isOpen) {
this.$set(menu, "isBigger", true);
}
},
/*
* 鼠标滑出
* */
mouseleave: function (menu) {
if (this.isOpen) {
this.$set(menu,"isBigger",false);
}
},
},
components: {
AIcon: Icon
}
}
</script>
<style scoped lang="scss">
.fixed-navigation-style {
position: fixed;
right: 0;
display: flex;
flex-direction: column;
background-color: white;
.menu-style {
height: 3.5rem;
display: flex;
justify-content: center;
align-items: center;
padding: 1rem 1rem;
position: relative;
span {
cursor: pointer;
}
.menu-bigger-style {
width: 10rem;
background-color: #f59a23;
color: white;
position: absolute;
right: 0;
height: 3.5rem;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.5rem 1rem;
border-top-left-radius: 3.5rem;
border-bottom-left-radius: 3.5rem;
span {
font-size: 1rem;
}
.bigger-menu-icon-style {
font-size: 1.5rem;
}
}
.menu-icon-style {
font-size: 22px;
cursor: pointer;
:hover {
color: #31a8fa;
}
}
}
}
</style>

@ -1,19 +1,38 @@
<template>
<div>
<div class="system-home-page-style">
<PageTop/>
<BannerCarousel/>
<FixedNavigation/>
<BottomInfo/>
</div>
</template>
<script>
/*
* 系统首页
* */
import PageTop from './pageTop.vue';
import BannerCarousel from './bannerCarousel.vue';
import FixedNavigation from './fixedNavigation.vue';
import BottomInfo from './bottomInfo.vue';
export default{
data(){
return {}
},
components:{
PageTop,
BannerCarousel,
FixedNavigation,
BottomInfo
}
}
</script>
<style></style>
<style scoped lang="scss">
.system-home-page-style{
width: 100%;
display: flex;
flex-direction: column;
}
</style>

@ -0,0 +1,36 @@
<template>
<div class="home-page-title-style">
<div class="system-title-style">长春市基础教育集优化发展管理服务平台</div>
<LogOut/>
</div>
</template>
<script>
/*
* 首页顶部
* */
import LogOut from '../logout/logout.vue';
export default{
data(){
return {}
},
components:{
LogOut
}
}
</script>
<style scoped lang="scss">
.home-page-title-style{
width: 100%;
height: 5rem;
background-color: #394af8;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 1rem;
.system-title-style{
font-size: 1.6rem;
color: white;
}
}
</style>

@ -17,25 +17,28 @@
<span class="error-tips-style">{{passwordErrorTips}}</span>
</div>
<div class="login-info-row-style">
<a-button class="login-button-style" @click="login"></a-button>
<a-button v-if="!isLogining" class="login-button-style" @click="login"></a-button>
<div v-if="isLogining"><a-spin/><span style="margin-left: 0.5rem">登录中请稍后...</span></div>
</div>
<span class="error-tips-style">{{errorTips}}</span>
<!--<span class="error-tips-style">{{errorTips}}</span>-->
</div>
</div>
</div>
</div>
</template>
<script>
import {Input, Icon, Button} from 'ant-design-vue';
import InterfaceConfig from '../../../../commonInterface/interfaceConfig';
import {Input, Icon, Button,Spin} from 'ant-design-vue';
import CommonInter from '../../api/commonInter';
import Base64 from '../../../../global-llibs/base64';
export default{
data(){
return {
isLogining: false,//
account: "",//
password: "",//
accountErrorTips: "",//
passwordErrorTips: "",//
errorTips: "",//
//errorTips: "",//
}
},
methods: {
@ -68,67 +71,89 @@
this.passwordErrorTips = "密码不能为空";
return
}
this.isLogining = true;
this.InterfaceConfig.callInterface([{
url: InterfaceConfig.checkLoginStatus.url,
params: {user: this.account, pwd: this.password},
method: InterfaceConfig.checkLoginStatus.method,
isTestLogin: InterfaceConfig.checkLoginStatus.isTestLogin,
url: CommonInter.loginByLoginNameAndPassword.url,
params: {login_name: Base64.encode(this.account), login_pwd: Base64.encode(this.password)},
method: CommonInter.loginByLoginNameAndPassword.method,
isTestLogin: CommonInter.loginByLoginNameAndPassword.isTestLogin,
}], (result) => {
if (result[0].status === 200) {
let data = result[0].data;
if (data.success === true) {
this.errorTips = "";
this.Cookie.set("person_id", data.person_id);
this.Cookie.set("identity_id", data.identity_id);
this.BaseConfig.userInfo.person_id = data.person_id;
this.BaseConfig.userInfo.person_id_cookie = data.person_id;
this.BaseConfig.userInfo.identity_id = data.identity_id;
this.BaseConfig.userInfo.identity_id_cookie = data.identity_id;
if (data.code === 2000) {
//this.errorTips = "";
this.Cookie.set("person_id", data.data.user_id);
this.Cookie.set("identity_id", data.data.user_identity_id);
this.Cookie.set('token', data.data.access_token);
//
//this.BaseConfig.ConfigFn.getPersonInfo_I();
//storerouter
new Promise(function (resolve, reject) {
_this.BaseConfig.ConfigFn.getPersonInfo_I(resolve);
_this.getPersonInfo(resolve);
}).then(function (res) {
_this.setUserStore(res);
if (res[0].status === 200) {
_this.setUserStore(res[0].data.data);
}else {
this.isLogining = false;
}
})
} else {
this.errorTips = data.info;
}else {
this.isLogining = false;
}
}else {
this.isLogining = false;
}
})
},
/**
* 获取个人信息
*/
getPersonInfo: function (resolve) {
let param = {
person_id: this.Cookie.get("person_id"),
identity_id: this.Cookie.get("identity_id")
}
this.InterfaceConfig.callInterface([{
url: CommonInter.getPersonInfo.url,
params: param,
method: CommonInter.getPersonInfo.method,
isTestLogin: CommonInter.getPersonInfo.isTestLogin,
}], (result) => {
resolve(result)
})
},
/**
* store存储user信息
*/
setUserStore: function (res) {
this.$store.commit('userStore/setUser',{
personId: this.BaseConfig.userInfo.person_id,
identityId: this.BaseConfig.userInfo.identity_id,
this.$store.commit('userStore/setUser', {
personId: res.person_info.user_id,
identityId: res.person_info.user_identity_id,
token: this.Cookie.get('token'),
personName: res.person_name,
orgId: res.bureau_id,
deptId: res.dep_id,
orgName: res.bureau_name
})
// bureau_iid 101 - 102 - 103 - /104 -
let bureau_iid = this.BaseConfig.person_info_my.bureau_iid;
this.$store.commit('userStore/setRoles',{role:this.getRoleById(bureau_iid)});
personName: res.person_info.user_name,
orgId: res.org_info.org_id,
deptId: res.person_info.dept_id,
orgName: res.org_info.org_name
});
// "org_level": "12345
let org_level = res.org_info.org_level;
this.$store.commit('userStore/setRoles', {role: this.getRoleById(org_level)});
this.isLogining = false;
this.$router.replace('main');
},
/*
* 根据机构ID获取角色信息
* */
getRoleById:function (bureau_iid) {
* 根据机构ID获取角色信息
* */
getRoleById: function (bureau_iid) {
let role = "";
switch (bureau_iid){
case 102:
switch (bureau_iid) {
case 2:
role = "city";
break;
case 103:
case 3:
role = "county";
break;
case 104:
case 5:
role = "school";
break;
default:
@ -141,7 +166,8 @@
AInput: Input,
AIcon: Icon,
AButton: Button,
AInputPassword: Input.Password
AInputPassword: Input.Password,
ASpin:Spin
}
}
</script>

@ -3,7 +3,7 @@
<Portrait :personId="personId"/>
<div class="person-info-style">
<div class="info-style name-style">{{personName}}</div>
<div class="info-style">{{'【' + orgName + '/' + depName + '】'}}</div>
<div class="info-style">{{'【' + orgName + (depName && depName !== ''? '/' + depName:'') + '】'}}</div>
</div>
<div class="logout-button-style">
<span title="退出" @click="logut">退</span>
@ -15,10 +15,10 @@
export default{
data(){
return {
personId: this.BaseConfig.userInfo.person_id,
personName: this.BaseConfig.userInfo.person_name,
orgName: this.BaseConfig.person_info_my.bureau_name,
depName: this.BaseConfig.person_info_my.dep_name,
personId: this.$store.state.userStore.user.personId,
personName: this.$store.state.userStore.user.personName,
orgName: this.$store.state.userStore.user.orgName,
depName: this.$store.state.userStore.user.depName,
}
},
methods: {
@ -33,8 +33,6 @@
this.Cookie.delete("token");
//store
this.$store.commit('userStore/clearUser');
window.person_info_my = null;
window.pt_type = null;
this.$router.replace('login');
}
},
@ -45,16 +43,18 @@
</script>
<style scoped lang="scss">
.logout-style {
width: 100%;
width: auto;
display: flex;
align-items: center;
height: 4rem;
font-size: 13px;
color: #999;
color: white;
.person-info-style {
display: flex;
flex-direction: column;
border-right: 1px solid #999;
padding-right: 0.5rem;
.name-style {
padding-left: 0.3rem;
}

@ -14,8 +14,8 @@ const loginGuard = (to, from, next, options) => {
//如果cookie中有登录信息且路由为login则跳转到根路由
//加载动态路由
loadRoutes(options);
if (to.path === '/login') {
next({path: '/'})
if (to.path === '/') {
next({path: '/main'})
} else {
next()
}

@ -2,7 +2,20 @@ import Vue from 'vue';
import Router from 'vue-router';
import routes from '../router/loginRoutes';
Vue.use(Router);
// // 解决报错 Error: Navigation cancelled from "/login" to "/main" with a new navigation
const originalPush = Router.prototype.push
const originalReplace = Router.prototype.replace
// push
Router.prototype.push = function push (location, onResolve, onReject) {
if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
return originalPush.call(this, location).catch(err => err)
}
// replace
Router.prototype.replace = function push (location, onResolve, onReject) {
if (onResolve || onReject) return originalReplace.call(this, location, onResolve, onReject)
return originalReplace.call(this, location).catch(err => err)
}
export default new Router({
mode: 'hash',
routes
routes:routes
});

@ -3,7 +3,8 @@
* 登陆路由配置
*/
import Login from '../page/login/login.vue';
import MainPage from '../page/mainPage.vue';
import HomePage from '../page/homePage/homePage.vue';
const routes = [
{
path: '/login',
@ -13,7 +14,7 @@ const routes = [
{
path: '/main',
name: 'main',
component: MainPage
component: HomePage
},
]
export default routes;

@ -1,9 +1,19 @@
import Vue from 'vue'
import Vuex from 'vuex'
import userStore from './modules/userStore'
import persistedState from 'vuex-persistedstate'
Vue.use(Vuex)
export default new Vuex.Store({
modules: {
userStore
},
/*
* store里的数据是保存在运行内存中的,当页面刷新时页面会重新加载vue实例store里面的数据就会被重新赋值初始化
* 将state的数据保存在localstoragesessionstorage或cookie中这样即可保证页面刷新数据不丢失且易于读取
* 此项目存储在localstorage中
* */
plugins: [persistedState({
storage: window.localStorage
})]
})

@ -3,10 +3,12 @@ export default {
state: {
user: null,
roles: null,
menus: null,
},
getter: {
user: state => state.user,
roles: state => state.roles,
menus: state => state.menus,
},
mutations: {
setUser (state, user) {
@ -15,9 +17,13 @@ export default {
setRoles (state, roles) {
state.roles = roles;
},
setMenus (state, menus) {
state.menus = menus;
},
clearUser (state) {
state.user = null;
state.roles = null;
state.menus = null;
}
}
}

@ -6,30 +6,33 @@ import menuConfig from '../menuConfig';
* @param options
*/
function loadRoutes(options) {
const { router, store } = options;
console.log("options:",store.state.userStore)
const {router, store} = options;
//当前登录人角色信息
let role = store.state.userStore.roles?store.state.userStore.roles.role:"";
let role = store.state.userStore.roles ? store.state.userStore.roles.role : "";
//根据登录信息筛选菜单以及路由配置
console.log("role:",role)
let routes = menuFilter(menuConfig,role);
console.log("过滤后的菜单:",routes)
router.addRoutes(routes)
if(role && role !== ""){
let routes = menuFilter(menuConfig, role);
//直接添加路由根目录
router.options.routes.push(...routes);
//添加权限菜单
store.commit('userStore/setMenus', routes);
//router.addRoutes(routes);
}
}
/*
* 根据角色过滤菜单及路由信息
* */
function menuFilter(menuConfig,role) {
let menuArray = menuConfig.filter(function (menu) {
return menu.role === "all" || menu.role.indexOf(role) > -1;
* 根据角色过滤菜单及路由信息
* */
function menuFilter(menuConfig, role) {
return menuConfig.filter(menu => {
return menu.role === "all" || menu.role.indexOf(role) > -1
}).map(route => {
route = Object.assign({},route);
if(route.children){
route.children = menuFilter(route.children,role)
}
return route
})
// .map(route=>{
// if (route.children) {
// route.children = menuFilter(route.children, role)
// }
// })
return menuArray;
}
@ -39,16 +42,16 @@ function menuFilter(menuConfig,role) {
* @param options
*/
function loadGuards(guards, options) {
const { beforeEachArray, afterEachArray } = guards;
const {beforeEachArray, afterEachArray} = guards;
const {router} = options;
if(beforeEachArray){
if (beforeEachArray) {
beforeEachArray.forEach(guard => {
if (guard && typeof guard === 'function') {
router.beforeEach((to, from, next) => guard(to, from, next, options));
}
})
}
if(afterEachArray && typeof afterEachArray == Array){
if (afterEachArray && typeof afterEachArray == Array) {
afterEachArray.forEach(guard => {
if (guard && typeof guard === 'function') {
router.afterEach((to, from) => guard(to, from, options));
@ -57,4 +60,4 @@ function loadGuards(guards, options) {
}
}
export { loadGuards,loadRoutes }
export {loadGuards, loadRoutes}
Loading…
Cancel
Save