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