|
|
|
|
@ -12,7 +12,8 @@ const getDefaultState = () => {
|
|
|
|
|
yearHoliday: 0,
|
|
|
|
|
department: {},
|
|
|
|
|
role: [],
|
|
|
|
|
roles:[]
|
|
|
|
|
roles: [],
|
|
|
|
|
moduleRoles: {}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -48,6 +49,9 @@ const mutations = {
|
|
|
|
|
},
|
|
|
|
|
SET_USERNAME: (state, username) => {
|
|
|
|
|
state.username = username
|
|
|
|
|
},
|
|
|
|
|
SET_MODULE_ROLES: (state, moduleRoles) => {
|
|
|
|
|
state.moduleRoles = moduleRoles
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -72,20 +76,29 @@ const actions = {
|
|
|
|
|
getInfo({ commit, state }) {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
getInfo(getToken()).then(response => {
|
|
|
|
|
|
|
|
|
|
const { name, avatar, id, role, roles, department, username, year_holiday } = response
|
|
|
|
|
const { name, avatar, id, role, roles, department, username, year_holiday, module_roles } = response
|
|
|
|
|
let rolesArr = []
|
|
|
|
|
if(roles&&roles.length>0){
|
|
|
|
|
rolesArr = roles.map(i=>i.name)
|
|
|
|
|
if (roles && roles.length > 0) {
|
|
|
|
|
rolesArr = roles.map(i => i.name)
|
|
|
|
|
}
|
|
|
|
|
// 处理 module_roles:转换为 { module_name: roles } 格式
|
|
|
|
|
const moduleRolesObj = {}
|
|
|
|
|
if (module_roles && Array.isArray(module_roles) && module_roles.length > 0) {
|
|
|
|
|
module_roles.forEach(item => {
|
|
|
|
|
if (item.module_name && item.roles) {
|
|
|
|
|
moduleRolesObj[item.module_name] = item.roles
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
commit('SET_DEPARTMENT',department)
|
|
|
|
|
commit('SET_DEPARTMENT', department)
|
|
|
|
|
commit('SET_NAME', name)
|
|
|
|
|
commit('SET_AVATAR', avatar)
|
|
|
|
|
commit('SET_ADMIN_ID', id)
|
|
|
|
|
commit('SET_ROLE', role)
|
|
|
|
|
commit('SET_ROLES', rolesArr)
|
|
|
|
|
commit('SET_USERNAME', username)
|
|
|
|
|
commit('SET_YEAR_HOLIDAY', year_holiday??0)
|
|
|
|
|
commit('SET_YEAR_HOLIDAY', year_holiday ?? 0)
|
|
|
|
|
commit('SET_MODULE_ROLES', moduleRolesObj)
|
|
|
|
|
resolve(response)
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
reject(error)
|
|
|
|
|
|