提交 ba15c975 编写于 作者: 钟一霄's avatar 钟一霄

动态菜单

上级 404dfe66
# 所有环境默认
# 页面 title
VUE_APP_TITLE=党建管理系统
\ No newline at end of file
VUE_APP_TITLE=场地管理
\ No newline at end of file
......@@ -25,7 +25,7 @@
tokenname: 'token',//token的名字
tokentime: '120',//token的有效时间(分钟)
savetype: '0',//0为cookie方式存储token,1为localStorage方式
autojump: '5',//自动跳转登录主页的时间(秒),0为立即跳转,-1为不跳转
autojump: '0',//自动跳转登录主页的时间(秒),0为立即跳转,-1为不跳转
jumplevel: '1',//1为顶层跳转,0为当前页面跳转
pwdlength: '8',//要求密码最短长度
usertype: 'c',//指定用户类型
......
......@@ -23,7 +23,7 @@
tokenname: 'token',//token的名字
tokentime: '120',//token的有效时间(分钟)
savetype: '0',//0为cookie方式存储token,1为localStorage方式
autojump: '5',//自动跳转登录主页的时间(秒),0为立即跳转,-1为不跳转
autojump: '0',//自动跳转登录主页的时间(秒),0为立即跳转,-1为不跳转
jumplevel: '1',//1为顶层跳转,0为当前页面跳转
pwdlength: '8',//要求密码最短长度
usertype: 'c',//指定用户类型
......
<template>
<span class="i-layout-header-trigger i-layout-header-trigger-min">
<Dropdown :trigger="isMobile ? 'click' : 'hover'" class="i-layout-header-user"
<!-- <Dropdown :trigger="isMobile ? 'click' : 'hover'" class="i-layout-header-user"
:class="{ 'i-layout-header-user-mobile': isMobile }" @on-click="handleClick">
<Avatar size="default" icon="ios-person" style="background-color: #2D8CF0;"/>
<span class="i-layout-header-user-name" v-if="!isMobile">{{ userName }}</span>
<DropdownMenu slot="list">
<!-- <i-link to="/setting/user">
<i-link to="/setting/user">
<DropdownItem>
<Icon type="ios-contact-outline" />
<span>{{ $t('basicLayout.user.center') }}</span>
......@@ -16,18 +16,44 @@
<Icon type="ios-settings-outline" />
<span>{{ $t('basicLayout.user.setting') }}</span>
</DropdownItem>
</i-link> -->
</i-link>
<DropdownItem divided name="logout">
<Icon type="ios-log-out" />
<span>{{ $t('basicLayout.user.logOut') }}</span>
</DropdownItem>
</DropdownMenu>
</Dropdown> -->
<Dropdown
:trigger="isMobile ? 'click' : 'hover'"
class="i-layout-header-user"
:class="{ 'i-layout-header-user-mobile': isMobile }"
@on-click="handleClick"
>
<span class="i-layout-header-user-name" v-if="!isMobile">
{{ info.currentRoleName }}
<Icon type="md-arrow-dropdown" />
</span>
<DropdownMenu slot="list">
<DropdownItem
:selected="item.role_id == info.currentRole"
v-for="(item, index) in info.rolelist"
:key="index"
:name="item.role_id"
>
<Icon type="ios-contact-outline" />
<span>{{ item.role_name }}</span>
</DropdownItem>
</DropdownMenu>
</Dropdown>
<span style="margin-left:8px;">
<Icon type="md-power" @click="handleLogout"/>
</span>
</span>
</template>
<script>
import { mapState, mapActions } from 'vuex';
import * as api from '@/api/dataQry'
import util from '@/libs/util';
export default {
name: 'iHeaderUser',
......@@ -50,15 +76,32 @@ export default {
'logout'
]),
handleClick(name) {
// console.log('点击', name, this.info)
if (name === 'logout') {
this.logout({
confirm: this.logoutConfirm,
vm: this
});
} else {
let obj = JSON.parse(util.cookies.get('site-management-userinfo'))
let authObj = obj.role_and_power.find(a => a.role_id == name)
this.info.access = authObj.role_id
this.info.currentRole = authObj.role_id
this.info.currentRoleName = authObj.role_name
//重新设置用户权限
this.$store.dispatch("admin/user/set", this.info, { root: true });
}
}
},
handleLogout(){
this.logout({
confirm: this.logoutConfirm,
vm: this,
});
},
},
mounted() {
// console.log('account用户信息', this.info)
// 去掉链接中的token
let tind = window.location.href.indexOf('token=');
if (tind != -1) window.location.href = window.location.href.substring(0, tind);
......
......@@ -326,6 +326,7 @@ export default {
],
// 搜索条件
params:{
role_id: this.$store.state.admin.user.info.currentRole,
page_index: 1,
page_size: 10,
user_card_name: "",
......
......@@ -150,6 +150,7 @@ export default {
],
// 搜索条件
params:{
role_id: this.$store.state.admin.user.info.currentRole,
page_index: 1,
page_size: 10,
place_type_id: '',
......
......@@ -5,10 +5,18 @@
</template>
<script>
import util from '@/libs/util';
export default {
data() {
return {}
},
mounted() {
let obj = JSON.parse(util.cookies.get('site-management-userinfo'))
console.log('用户信息', obj)
let obj2 = JSON.parse(localStorage.getItem('admin'))
console.log('菜单', obj2)
},
methods:{
aaa(){
this.asc.getApiSsoPc()
......
......@@ -23,6 +23,27 @@ function filterMenu (menuList, access, lastList) {
return lastList;
}
function menuFormat(arr) {
return arr.map(a => {
return {
"id": a.menuid,
"parentId": "0",
"path": '/' + a.menu_path,
"title": a.menu_name,
"name": "",
"header": "",
"icon": "",
"custom": "",
"hideSider": "0",
"isHided": "0",
"isExistDoc": false,
"rank": 0,
"auth": [],
"children": []
}
})
}
export default {
namespaced: true,
state: {
......@@ -49,10 +70,15 @@ export default {
const userInfo = rootState.admin.user.info;
// @权限
const access = userInfo.access;
const menuList = menuFormat(userInfo.rolelist.find(a => a.role_id == userInfo.currentRole).menus)
if (access && access.length) {
return filterMenu(state.sider, access, []);
// return filterMenu(state.sider, access, []);
return menuList
} else {
return filterMenu(state.sider, [], []);
// return filterMenu(state.sider, [], []);
return menuList
}
},
/**
......
Markdown 格式
0% or
您添加了 0 人 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册 或