This commit is contained in:
zhuoda
2020-04-07 22:10:57 +08:00
parent 478b39d61a
commit 8394525697
456 changed files with 5963 additions and 2908 deletions

View File

@@ -0,0 +1,54 @@
<template>
<Select clearable filterable :multiple="multiple" :style="selectorStyle" v-model="selectValue">
<Option :key="item.id" :value="item.id" v-for="item in dataList">{{ item.actualName }}</Option>
</Select>
</template>
<script>
import { employeeApi } from '@/api/employee';
export default {
name: 'EmployeeSelector',
props: {
// 选中的员工
value: null,
multiple: {
type: Boolean,
default: false
},
selectorStyle:{
type:String,
default:'width:180px'
}
},
data() {
return {
dataList: [],
selectValue: this.value
};
},
mounted() {
this.reset();
this.query();
},
methods: {
reset() {
if (this.multiple) {
this.selectValue = [];
} else {
this.selectValue = -1;
}
},
updateSelect(value) {
this.selectValue = value;
},
getSelectValue() {
return this.selectValue;
},
query() {
(async () => {
let res = await employeeApi.getAllEmployee();
this.dataList = res.data;
})();
}
}
};
</script>

View File

@@ -21,7 +21,7 @@ export default {
// 面包屑显示字体大小
fontSize: {
type: Number,
default: 14
default: 12
},
// 是否显示图标
showIcon: {

View File

@@ -1,7 +1,37 @@
<template>
<div class="header-bar">
<SiderTrigger :collapsed="collapsed" icon="icon iconfont icondaohangzhedie" @on-change="handleCollpasedChange"/>
<CustomBreadCrumb show-icon style="margin-left: 30px;" :list="breadCrumbList"/>
<SiderTrigger
:collapsed="collapsed"
@on-change="handleCollpasedChange"
icon="icon iconfont icondaohangzhedie"
/>
<div class="custom-bread-crumb" style="margin-left: 30px;">
<div class="ivu-breadcrumb" >
<Dropdown @on-click="changeTopMenu">
<a href="javascript:void(0)" style="font-size:15px;font-weight:600">
{{currentTopMenuTitle}}
<Icon type="ios-arrow-down" style="font-size:16px"></Icon>
</a>
<DropdownMenu slot="list">
<DropdownItem :key="i" v-for="(item,i) in topMenuArray" :name="item.name">
<Icon :type="item.meta.icon" style="font-size: 14px;"/>
<span style="font-size: 14px;"> {{item.meta.title}} </span>
</DropdownItem>
</DropdownMenu>
</Dropdown>
<i>
<CustomBreadCrumb :list="breadCrumbList" show-icon style="margin-left: 20px;" />
</i>
<!-- <Tabs value="name1">
<TabPane style="font-size:16px;font-weight:700;padding:12px 16px" label="标签一" name="name1"/>
<TabPane style="font-size:16px;font-weight:700;padding:12px 16px" label="标签二" name="name2"/>
<TabPane style="font-size:16px;font-weight:700;padding:12px 16px" label="标签三" name="name3">标签三的内容</TabPane>
</Tabs> -->
</div>
</div>
<div class="custom-content-con">
<slot></slot>
</div>
@@ -22,17 +52,30 @@ export default {
collapsed: {
type: Boolean,
require: false
},
//顶级菜单
topMenuArray:{
type:Array,
required:true
},
//当前顶级菜单名字
currentTopMenuTitle:{
type:String,
required:true
}
},
computed: {
// 面包屑集合
breadCrumbList () {
breadCrumbList() {
return this.$store.state.app.breadCrumbList;
}
},
methods: {
handleCollpasedChange (state) {
handleCollpasedChange(state) {
this.$emit('on-coll-change', state);
},
changeTopMenu(name){
this.$emit('on-change-top-menu', name);
}
}
};

View File

@@ -9,7 +9,7 @@ export default {
return showTitle(item, this);
},
showChildren (item) {
return item.children && (item.children.length > 1 || (item.meta && item.meta.showAlways));
return item.children && (item.children.length > 0 || (item.meta && item.meta.showAlways));
},
getNameOrHref (item, children0) {
return item.href ? `isTurnByHref_${item.href}` : (children0 ? item.children[0].name : item.name);

View File

@@ -13,7 +13,7 @@
>
<template v-for="item in menuList">
<template v-if="item.children && item.children.length === 1">
<side-menu-item :key="`menu-${item.name}`" :parent-item="item" v-if="showChildren(item)"></side-menu-item>
<side-menu-item :key="`menu-${item.name}`" :parent-item="item.children[0]" v-if="item.children[0].children && item.children[0].children.length > 0 "></side-menu-item>
<menu-item
:key="`menu-${item.children[0].name}`"
:name="getNameOrHref(item, true)"
@@ -24,7 +24,7 @@
</menu-item>
</template>
<template v-else>
<side-menu-item :key="`menu-${item.name}`" :parent-item="item" v-if="showChildren(item)"></side-menu-item>
<side-menu-item :key="`menu-${item.name}`" :parent-item="item" v-if="item.children && item.children.length > 0"></side-menu-item>
<menu-item :key="`menu-${item.name}`" :name="getNameOrHref(item)" v-else>
<common-icon :type="item.icon || ''" />
<span>{{ showTitle(item) }}</span>
@@ -81,6 +81,13 @@ export default {
CollapsedMenu
},
props: {
// 菜单path数组
menuNameMatchedMap:{
type: Map,
default() {
return new Map();
}
},
// 菜单集合
menuList: {
type: Array,
@@ -161,6 +168,7 @@ export default {
},
methods: {
updateActiveName(name){
this.updateOpenName(name)
this.$nextTick(() => {
this.$refs.menu.updateOpened();
this.$refs.menu.updateActiveName(name);
@@ -171,13 +179,20 @@ export default {
},
// 从激活菜单的名称中获取打开的菜单
getOpenedNamesByActiveName(name) {
return this.$route.matched
.map(item => item.name)
.filter(item => item !== name);
// return this.$route.matched
// .map(item => item.name)
// .filter(item => item !== name);
let array = this.menuNameMatchedMap.get(name);
if(array){
return array;
}else{
return [];
}
},
updateOpenName(name) {
if (name === this.$config.homeName) this.openedNames = [];
else this.openedNames = this.getOpenedNamesByActiveName(name);
// if (name === this.$config.homeName) this.openedNames = [];
// else this.openedNames = this.getOpenedNamesByActiveName(name);
this.openedNames = this.menuNameMatchedMap.get(name);
}
}
};

View File

@@ -13,6 +13,7 @@
:active-name="$route.name"
:collapsed="collapsed"
:menu-list="menuList"
:menuNameMatchedMap="menuNameMatchedMap"
@on-select="turnToPage"
accordion
ref="sideMenu"
@@ -47,7 +48,13 @@
</Sider>
<Layout>
<Header class="header-con">
<HeaderBar :collapsed="collapsed" @on-coll-change="handleCollapsedChange">
<HeaderBar
:collapsed="collapsed"
:currentTopMenuTitle="currentTopMenuTitle"
:topMenuArray="userTopMenuArray"
@on-change-top-menu="handleChangeTopMenu"
@on-coll-change="handleCollapsedChange"
>
<User :message-unread-count="unreadCount" />
<language
:lang="local"
@@ -59,7 +66,7 @@
<Fullscreen style="margin-right: 10px;" v-model="isFullscreen" />
</HeaderBar>
</Header>
<Content class="main-content-con">
<Content class="main-content-con" v-if="isLoadedPrvileges">
<Layout class="main-layout-con">
<div class="tag-nav-wrapper">
<TagsNav
@@ -89,6 +96,7 @@ import HeaderBar from './components/header-bar';
import TagsNav from './components/tags-nav';
import Notice from './components/notice/notice';
import User from './components/user';
import { topMenuArray } from '@/router';
import Fullscreen from './components/fullscreen';
import Language from './components/language';
import { mapMutations, mapActions, mapGetters } from 'vuex';
@@ -112,6 +120,13 @@ export default {
},
data() {
return {
//是否加载完了权限
isLoadedPrvileges:false,
//用户所拥有的顶级菜单数组
userTopMenuArray: [],
//当前顶级菜单名字
currentTopMenuName: '',
currentTopMenuTitle: '',
// 是否折叠
collapsed: false,
minLogo,
@@ -123,7 +138,8 @@ export default {
searchKeyWord: '',
searchList: [],
searchListResult: [],
menuList: []
menuList: [],
menuNameMatchedMap: new Map()
};
},
computed: {
@@ -183,6 +199,7 @@ export default {
this.setBreadCrumb(newRoute);
// this.pushKeepAliveIncludes(newRoute);
this.setTagNavList(getNewTagList(this.tagNavList, newRoute));
//更新左侧目录打开
this.$refs.sideMenu.updateOpenName(newRoute.name);
// 如果param参数 存在 noKeepAlive切位true
let isParamNoKeepAlive = params && params.noKeepAlive === true;
@@ -202,32 +219,18 @@ export default {
},
mounted() {
/**
* @description 初始化设置面包屑导航和标签导航
* 初始化设置面包屑导航和标签导航
*/
this.setTagNavList();
this.setHomeRoute(routers);
this.setCollapsed();
this.setBreadCrumb(this.$route);
//初始化左侧菜单
this.initSideMenu();
const { name, params, query, meta } = this.$route;
this.addTag({
route: {
name,
params,
query,
meta
}
});
this.buildTopMenu();
// 设置初始语言
this.setLocal(this.$i18n.locale);
// 如果当前打开页面不在标签栏中跳到homeName页
if (!this.tagNavList.find(item => item.name === this.$route.name)) {
this.$router.push({
name: this.$config.homeName
});
}
//初始化左侧菜单
this.initSideMenu();
this.jumpRouter();
},
methods: {
...mapMutations([
@@ -244,13 +247,34 @@ export default {
]),
...mapActions(['handleLogin']),
jumpRouter() {
const { name, params, query, meta } = this.$route;
this.addTag({
route: {
name,
params,
query,
meta
}
});
// 如果当前打开页面不在标签栏中跳到homeName页
if (!this.tagNavList.find(item => item.name === this.$route.name)) {
this.$router.push({
name: this.$config.homeName
});
}
},
initSideMenu() {
//如果是登录跳转过来
if (this.$store.state.user.isUpdatePrivilege) {
this.isLoadedPrvileges = true;
this.$Spin.show();
this.buildMenuTree();
this.$refs.sideMenu.updateActiveName(this.$route.name);
this.jumpRouter();
this.$Spin.hide();
} else {
//如果页面刷新,需要重新获取权限
(async () => {
@@ -261,22 +285,68 @@ export default {
'setUserPrivilege',
sessionResult.data.privilegeList
);
this.isLoadedPrvileges = true;
this.buildTopMenu();
this.buildMenuTree();
//刷新以后手动更新左侧菜单打开和选中
this.$refs.sideMenu.updateActiveName(this.$route.name);
this.jumpRouter();
this.$Spin.hide();
})();
}
},
buildTopMenu() {
let arr = [];
for (let topMenu of topMenuArray) {
if (
this.$store.state.user.userLoginInfo.isSuperMan ||
this.$store.state.user.privilegeMenuKeyList.indexOf(topMenu.name) !==
-1
) {
arr.push(topMenu);
}
}
if (arr.length > 0) {
this.currentTopMenuName = arr[0].name;
this.currentTopMenuTitle = arr[0].meta.title;
} else {
this.currentTopMenuName = '';
this.currentTopMenuTitle = '';
}
this.userTopMenuArray = arr;
},
handleChangeTopMenu(name) {
this.currentTopMenuName = name;
for (let topMenu of this.userTopMenuArray) {
if (topMenu.name === name) {
this.currentTopMenuTitle = topMenu.meta.title;
}
}
this.initSideMenu();
},
getCurrentTopMenuChild() {
if (this.userTopMenuArray.length === 0) {
return [];
} else {
for (const router of this.userTopMenuArray) {
if (router.name === this.currentTopMenuName) {
return router.children;
}
}
return [];
}
},
buildMenuTree() {
let privilegeTree = [];
for (const router of routers) {
let routerArray = this.getCurrentTopMenuChild();
for (const router of routerArray) {
//过滤非菜单
if (!router.meta.hideInMenu) {
//判断是否有权限
if (
this.$store.state.user.userLoginInfo.isSuperMan ||
this.$store.state.user.privilegeMenuKeyList.indexOf(router.name) !==
-1
-1
) {
let menu = {
name: router.name,
@@ -284,6 +354,7 @@ export default {
icon: _.isUndefined(router.meta.icon) ? '' : router.meta.icon,
children: []
};
this.menuNameMatchedMap.set(menu.name, [menu.name]);
privilegeTree.push(menu);
//存在孩子节点,开始递归
if (router.children && router.children.length > 0) {
@@ -299,6 +370,16 @@ export default {
for (const router of children) {
//过滤非菜单
if (!router.meta.hideInMenu) {
//验证权限
if (!this.$store.state.user.userLoginInfo.isSuperMan) {
if (
this.$store.state.user.privilegeMenuKeyList.indexOf(
router.name
) === -1
) {
continue;
}
}
let menu = {
name: router.name,
meta: router.meta,
@@ -309,6 +390,10 @@ export default {
name: router.name,
title: router.meta.title
});
let menuNameArray = this.menuNameMatchedMap.get(parentMenu.name);
this.menuNameMatchedMap.set(menu.name, [...menuNameArray, menu.name]);
parentMenu.children.push(menu);
//存在孩子节点,开始递归
if (router.children && router.children.length > 0) {