菜单
This commit is contained in:
@@ -126,3 +126,11 @@ export const updatePass = (newPass, oldPass) => post('api/users/updatePass', {
|
||||
newPass: newPass,
|
||||
oldPass: oldPass
|
||||
})
|
||||
|
||||
// 用户登录获取菜单
|
||||
export const sysMenuBuild = () => post('api/sysMenu/build', {
|
||||
})
|
||||
|
||||
// 用户退出
|
||||
export const authLogout = () => post('auth/logout', {
|
||||
})
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
<script>
|
||||
import jxTime from '@components/time.vue'
|
||||
import jxDialog from '@components/dialog.vue'
|
||||
import { updatePass } from '@config/getData2.js'
|
||||
import { updatePass, sysMenuBuild, authLogout } from '@config/getData2.js'
|
||||
import {encrypt} from '../../../main.js'
|
||||
export default {
|
||||
components: {
|
||||
@@ -103,84 +103,85 @@ export default {
|
||||
data () {
|
||||
return {
|
||||
username: this.$store.getters.userInfo !== '' ? JSON.parse(this.$store.getters.userInfo).user.username : '',
|
||||
menus: [{
|
||||
label: '首页',
|
||||
index: '1',
|
||||
router: '',
|
||||
children: [{
|
||||
label: '首页',
|
||||
index: '1',
|
||||
router: '/index/home'
|
||||
}]
|
||||
}, {
|
||||
label: '任务管理',
|
||||
index: '2',
|
||||
router: '',
|
||||
children: [{
|
||||
label: '搬运站点',
|
||||
index: '1',
|
||||
router: '/index/carrypoint'
|
||||
}, {
|
||||
label: '任务列表',
|
||||
index: '2',
|
||||
router: '/index/tasklists'
|
||||
}, {
|
||||
label: '任务操作',
|
||||
index: '3',
|
||||
router: '/index/taskoperates'
|
||||
}]
|
||||
}, {
|
||||
label: '故障管理',
|
||||
index: '3',
|
||||
router: '',
|
||||
children: [{
|
||||
label: '故障信息',
|
||||
index: '1',
|
||||
router: '/index/errorinfo'
|
||||
}, {
|
||||
label: '故障处理',
|
||||
index: '2',
|
||||
router: '/index/errordeal'
|
||||
}]
|
||||
}, {
|
||||
label: '车辆信息',
|
||||
index: '4',
|
||||
router: '',
|
||||
children: [{
|
||||
label: '车辆状态',
|
||||
index: '1',
|
||||
router: '/index/vehiclestatus'
|
||||
}, {
|
||||
label: '车辆控制',
|
||||
index: '2',
|
||||
router: '/index/vehiclecontrol'
|
||||
}]
|
||||
}, {
|
||||
label: '示教',
|
||||
index: '5',
|
||||
router: '/index/teach'
|
||||
}, {
|
||||
label: '系统管理',
|
||||
index: '6',
|
||||
router: '',
|
||||
children: [{
|
||||
label: '用户管理',
|
||||
index: '1',
|
||||
router: '/index/user'
|
||||
}, {
|
||||
label: '角色管理',
|
||||
index: '2',
|
||||
router: '/index/role'
|
||||
}, {
|
||||
label: '系统参数',
|
||||
index: '3',
|
||||
router: '/index/system'
|
||||
}, {
|
||||
label: '开发者选项',
|
||||
index: '4',
|
||||
router: '/index/developer'
|
||||
}]
|
||||
}],
|
||||
menus: [] || JSON.parse(this.$store.getters.menus),
|
||||
// menus: [{
|
||||
// label: '首页',
|
||||
// index: '1',
|
||||
// router: '',
|
||||
// children: [{
|
||||
// label: '首页',
|
||||
// index: '1',
|
||||
// router: '/index/home'
|
||||
// }]
|
||||
// }, {
|
||||
// label: '任务管理',
|
||||
// index: '2',
|
||||
// router: '',
|
||||
// children: [{
|
||||
// label: '搬运站点',
|
||||
// index: '1',
|
||||
// router: '/index/carrypoint'
|
||||
// }, {
|
||||
// label: '任务列表',
|
||||
// index: '2',
|
||||
// router: '/index/tasklists'
|
||||
// }, {
|
||||
// label: '任务操作',
|
||||
// index: '3',
|
||||
// router: '/index/taskoperates'
|
||||
// }]
|
||||
// }, {
|
||||
// label: '故障管理',
|
||||
// index: '3',
|
||||
// router: '',
|
||||
// children: [{
|
||||
// label: '故障信息',
|
||||
// index: '1',
|
||||
// router: '/index/errorinfo'
|
||||
// }, {
|
||||
// label: '故障处理',
|
||||
// index: '2',
|
||||
// router: '/index/errordeal'
|
||||
// }]
|
||||
// }, {
|
||||
// label: '车辆信息',
|
||||
// index: '4',
|
||||
// router: '',
|
||||
// children: [{
|
||||
// label: '车辆状态',
|
||||
// index: '1',
|
||||
// router: '/index/vehiclestatus'
|
||||
// }, {
|
||||
// label: '车辆控制',
|
||||
// index: '2',
|
||||
// router: '/index/vehiclecontrol'
|
||||
// }]
|
||||
// }, {
|
||||
// label: '示教',
|
||||
// index: '5',
|
||||
// router: '/index/teach'
|
||||
// }, {
|
||||
// label: '系统管理',
|
||||
// index: '6',
|
||||
// router: '',
|
||||
// children: [{
|
||||
// label: '用户管理',
|
||||
// index: '1',
|
||||
// router: '/index/user'
|
||||
// }, {
|
||||
// label: '角色管理',
|
||||
// index: '2',
|
||||
// router: '/index/role'
|
||||
// }, {
|
||||
// label: '系统参数',
|
||||
// index: '3',
|
||||
// router: '/index/system'
|
||||
// }, {
|
||||
// label: '开发者选项',
|
||||
// index: '4',
|
||||
// router: '/index/developer'
|
||||
// }]
|
||||
// }],
|
||||
dropdown: false,
|
||||
oldpassword: '',
|
||||
newpassword1: '',
|
||||
@@ -193,7 +194,11 @@ export default {
|
||||
return this.$route.meta.jumpPath
|
||||
},
|
||||
childmenus () {
|
||||
return this.menus[Number(this.$route.meta.jumpPath) - 1].children
|
||||
let res = []
|
||||
if (this.menus.length) {
|
||||
res = this.menus[Number(this.$route.meta.jumpPath) - 1].children
|
||||
}
|
||||
return res
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -220,11 +225,14 @@ export default {
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.menus.map(el => {
|
||||
if (el.router === this.$route.path) {
|
||||
this.childmenus = el.children
|
||||
}
|
||||
})
|
||||
this._sysMenuBuild()
|
||||
if (this.menus.length) {
|
||||
this.menus.map(el => {
|
||||
if (el.router === this.$route.path) {
|
||||
this.childmenus = el.children
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleSelect (key) {
|
||||
@@ -292,8 +300,22 @@ export default {
|
||||
this.$refs.child.disabled = false
|
||||
}
|
||||
},
|
||||
async _sysMenuBuild () {
|
||||
let res = await sysMenuBuild()
|
||||
this.menus = [...res]
|
||||
res.map(el => {
|
||||
if (el.router === this.$route.path) {
|
||||
this.childmenus = el.children
|
||||
}
|
||||
})
|
||||
this.$store.dispatch('getMenus', [...res])
|
||||
},
|
||||
async _authLogout () {
|
||||
await authLogout()
|
||||
},
|
||||
toEixt () {
|
||||
this.$store.dispatch('setSignOut')
|
||||
this._authLogout()
|
||||
this.$router.push('/login')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,11 +61,13 @@ import { getStore, setStore } from '@config/utils.js'
|
||||
// }
|
||||
|
||||
const state = {
|
||||
userInfo: getStore('userInfo') || '' // 用户信息
|
||||
userInfo: getStore('userInfo') || '', // 用户信息
|
||||
menus: getStore('menus') || [] // 菜单
|
||||
}
|
||||
|
||||
const getters = {
|
||||
userInfo: state => state.userInfo
|
||||
userInfo: state => state.userInfo,
|
||||
menus: state => state.menus
|
||||
}
|
||||
|
||||
const actions = {
|
||||
@@ -75,7 +77,12 @@ const actions = {
|
||||
},
|
||||
setSignOut ({ commit }) {
|
||||
localStorage.removeItem('userInfo')
|
||||
localStorage.removeItem('menus')
|
||||
commit(types.SET_SIGN_OUT)
|
||||
},
|
||||
getMenus ({ commit }, res) {
|
||||
setStore('menus', res)
|
||||
commit(types.GET_MENUS, res)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +92,9 @@ const mutations = {
|
||||
},
|
||||
[types.SET_SIGN_OUT] (state) {
|
||||
state.accountId = ''
|
||||
},
|
||||
[types.GET_MENUS] (state, res) {
|
||||
state.menus = res
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ export const COM_ALERT_MSG = 'COM_ALERT_MSG'
|
||||
// 用户
|
||||
export const SET_USER_INFO = 'SET_USER_INFO'
|
||||
export const SET_SIGN_OUT = 'SET_SIGN_OUT'
|
||||
export const GET_MENUS = 'GET_MENUS'
|
||||
|
||||
// 数据
|
||||
export const SET_DEVICE = 'SET_DEVICE'
|
||||
|
||||
Reference in New Issue
Block a user