diff --git a/.env.development b/.env.development index 6a303b8..743a4a3 100644 --- a/.env.development +++ b/.env.development @@ -2,7 +2,7 @@ ENV = 'development' # base api -VUE_APP_BASE_API='http://192.167.20.118:8080/' +VUE_APP_BASE_API='https://cz-hjjc-test.115.langye.net/' #VUE_APP_BASE_API='http://czemc.localhost' VUE_APP_UPLOAD_API='https://cz-hjjc-test.115.langye.net/api/upload-file' VUE_APP_PREVIEW=//view.langye.net/preview/onlinePreview diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 0ccdf66..93a8ee2 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -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) diff --git a/src/views/attendance/YearStatistics.vue b/src/views/attendance/YearStatistics.vue index 19eb6bc..f36d063 100644 --- a/src/views/attendance/YearStatistics.vue +++ b/src/views/attendance/YearStatistics.vue @@ -4,14 +4,14 @@