diff --git a/pages/home/home.vue b/pages/home/home.vue index 85e983b..ef3a626 100644 --- a/pages/home/home.vue +++ b/pages/home/home.vue @@ -30,21 +30,42 @@ export default { data() { return { + roles: this.$store.getters.saveRoles, userName: '', - menuList: [ - // {id: '1', name: '人工排产', icon: 'RF01', path: '/pages/modules/man-paichan'}, - // {id: '2', name: '涂线板', icon: 'RF02', path: '/pages/modules/wire-board'}, - // {id: '3', name: '物料库存', icon: 'RF03', path: '/pages/modules/mater-inventory'} - // {id: '1', name: '原材料入库', icon: 'RF03', path: '/pages/modules/rawmater-instore'}, - {id: '2', name: '原材料出库', icon: 'RF07', path: '/pages/modules/rawmater-outstore'}, - {id: '3', name: '搬运任务', icon: 'RF01', path: '/pages/modules/carry-task'}, - // {id: '4', name: '组盘解绑', icon: 'RF04', path: '/pages/modules/zupan-unbind'}, - {id: '5', name: '指令管理', icon: 'RF02', path: '/pages/modules/zlmanage'}, - {id: '6', name: '任务管理', icon: 'RF09', path: '/pages/modules/taskmanage'} - ] + menuList: [] }; }, created () { + console.log(this.$store.getters.saveRoles, '11111') + if (this.roles === 'A1,A2,') { + this.menuList = [ + // {id: '1', name: '人工排产', icon: 'RF01', path: '/pages/modules/man-paichan'}, + // {id: '2', name: '涂线板', icon: 'RF02', path: '/pages/modules/wire-board'}, + // {id: '3', name: '物料库存', icon: 'RF03', path: '/pages/modules/mater-inventory'} + {id: '1', name: '原材料入库', icon: 'RF03', path: '/pages/modules/rawmater-instore'}, + {id: '2', name: '原材料出库', icon: 'RF07', path: '/pages/modules/rawmater-outstore'}, + {id: '3', name: '搬运任务', icon: 'RF01', path: '/pages/modules/carry-task'}, + {id: '4', name: '组盘解绑', icon: 'RF04', path: '/pages/modules/zupan-unbind'}, + {id: '5', name: '指令管理', icon: 'RF02', path: '/pages/modules/zlmanage'}, + {id: '6', name: '任务管理', icon: 'RF09', path: '/pages/modules/taskmanage'} + ] + } + if (this.roles === 'A1') { + this.menuList = [ + {id: '1', name: '原材料入库', icon: 'RF03', path: '/pages/modules/rawmater-instore'}, + {id: '2', name: '原材料出库', icon: 'RF07', path: '/pages/modules/rawmater-outstore'}, + {id: '5', name: '指令管理', icon: 'RF02', path: '/pages/modules/zlmanage'}, + {id: '6', name: '任务管理', icon: 'RF09', path: '/pages/modules/taskmanage'} + ] + } + if (this.roles === 'A2') { + this.menuList = [ + {id: '3', name: '搬运任务', icon: 'RF01', path: '/pages/modules/carry-task'}, + {id: '4', name: '组盘解绑', icon: 'RF04', path: '/pages/modules/zupan-unbind'}, + {id: '5', name: '指令管理', icon: 'RF02', path: '/pages/modules/zlmanage'}, + {id: '6', name: '任务管理', icon: 'RF09', path: '/pages/modules/taskmanage'} + ] + } this.$store.dispatch('setPublicObj', '') if (this.$store.getters.userInfo) { this.userName = JSON.parse(this.$store.getters.userInfo).username diff --git a/pages/login/login.vue b/pages/login/login.vue index 7c859e8..401b4ae 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -104,6 +104,7 @@ } this.$store.dispatch('saveUserInfo', JSON.stringify(res.user.user)) this.$store.dispatch('saveToken', res.token) + this.$store.dispatch('saveRoles', res.roles) uni.redirectTo({ url: '/pages/home/home' }) diff --git a/vuex/modules/user.js b/vuex/modules/user.js index d7a0242..fd0043b 100644 --- a/vuex/modules/user.js +++ b/vuex/modules/user.js @@ -9,7 +9,8 @@ const state = { setPrintName: uni.getStorageSync('setPrintName') || '', loginName: uni.getStorageSync('loginName') ? uni.getStorageSync('loginName') : '', userInfo: uni.getStorageSync('userInfo') ? uni.getStorageSync('userInfo') : '', - saveToken: uni.getStorageSync('saveToken') || '' + saveToken: uni.getStorageSync('saveToken') || '', + saveRoles: uni.getStorageSync('saveRoles') || '' } const getters = { baseUrl: state => state.baseUrl, @@ -18,7 +19,8 @@ const getters = { setPrintName: state => state.setPrintName, loginName: state => state.loginName, userInfo: state => state.userInfo, - saveToken: state => state.saveToken + saveToken: state => state.saveToken, + saveRoles: state => state.saveRoles } const actions = { setConfig ({commit}, res) { @@ -43,11 +45,16 @@ const actions = { delUserInfo({commit}, res) { uni.removeStorageSync('userInfo') uni.removeStorageSync('saveToken') + uni.removeStorageSync('saveRoles') commit(types.DEL_USER_INFO, res) }, saveToken({commit}, res) { uni.setStorageSync('saveToken', res) commit(types.SAVE_TOKEN, res) + }, + saveRoles({commit}, res) { + uni.setStorageSync('saveRoles', res) + commit(types.SAVE_ROLES, res) } } const mutations = { @@ -69,9 +76,13 @@ const mutations = { [types.DEL_USER_INFO] (state, res) { state.userInfo = res state.saveToken = res + state.saveRoles = res }, [types.SAVE_TOKEN] (state, res) { state.saveToken = res + }, + [types.SAVE_ROLES] (state, res) { + state.saveRoles = res } } diff --git a/vuex/types.js b/vuex/types.js index ee8a8f3..3aee377 100644 --- a/vuex/types.js +++ b/vuex/types.js @@ -7,6 +7,7 @@ export const COM_CONFIG = 'COM_CONFIG' export const SAVE_USER_INFO = 'SAVE_USER_INFO' export const DEL_USER_INFO = 'DEL_USER_INFO' export const SAVE_TOKEN = 'SAVE_TOKEN' +export const SAVE_ROLES = 'SAVE_ROLES' /** * data