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

动态菜单

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