| | |
| | | VUE_APP_ROLE_LIST=admin.roleList |
| | | VUE_APP_DEPARTMENT_LIST=admin.departmentList |
| | | VUE_APP_DOWNLOAD_FLAG=admin.downloadFlag |
| | | VUE_APP_PROJECT_MANAGER_LIST= admin.projectManagerList |
| | | VUE_APP_GENERAL_MANAGER_LIST = admin.generalManagerList |
| | |
| | | import {mapMutations} from 'vuex' |
| | | import { userLogin } from './apis' |
| | | import { values } from 'lodash'; |
| | | import {getAllRole} from "@/pages/user/apis"; |
| | | import {getAllRole, getUserByRoleId} from "@/pages/user/apis"; |
| | | import { hasAnyRole } from '@/utils/authority-utils'; |
| | | export default { |
| | | name: 'Login', |
| | |
| | | } |
| | | }, |
| | | methods: { |
| | | ...mapMutations('account', ['setUser', 'setPermissions', 'setRoles', 'setRoleList', 'setDepartmentList', 'setDownloadFlag']), |
| | | ...mapMutations('account', ['setUser', 'setPermissions', 'setRoles', 'setRoleList', |
| | | 'setDepartmentList', 'setDownloadFlag', 'setProjectManagerList', 'setGeneralManagerList']), |
| | | onSubmit (e) { |
| | | let vm = this; |
| | | e.preventDefault() |
| | |
| | | this.setRoleList(roleList); |
| | | this.setDepartmentList(departmentList); |
| | | this.setDownloadFlag(downloadFlag); |
| | | this.getUserByRoleId(1002); |
| | | this.getUserByRoleId(1003); |
| | | |
| | | setAuthorization({token: loginRes.data.token, expireAt: new Date(loginRes.data.expireAt)}) |
| | | // 获取路由配置 |
| | |
| | | }).catch(error=>{ |
| | | console.log(error); |
| | | }); |
| | | }, |
| | | getUserByRoleId(id) { |
| | | getUserByRoleId(id).then(res=>{ |
| | | let rs = res.data; |
| | | let data = []; |
| | | if(rs.code == 1 && rs.data) { |
| | | data = rs.data2.map(item=>{ |
| | | item.key = item.name; |
| | | return item; |
| | | }); |
| | | } |
| | | console.log(data); |
| | | // 根据id设置列表 |
| | | if(id==1002) { |
| | | this.setProjectManagerList(data); |
| | | }else { |
| | | this.setGeneralManagerList(data); |
| | | } |
| | | }).catch(error => { |
| | | console.log(error); |
| | | }); |
| | | } |
| | | }, |
| | | mounted() { |
| | |
| | | roleList: null, |
| | | departmentList: null, |
| | | downloadFlag: null, |
| | | projectManagerList: null, // 项目经理列表 |
| | | generalManagerList: null, // 总经理列表 |
| | | }, |
| | | getters: { |
| | | user: state => { |
| | |
| | | const downloadFlag = localStorage.getItem(process.env.VUE_APP_DOWNLOAD_FLAG); |
| | | state.downloadFlag = downloadFlag; |
| | | return state.downloadFlag == 1?true:false; |
| | | }, |
| | | projectManagerList: state=>{ |
| | | if(!state.projectManagerList) { |
| | | try { |
| | | const projectManagerList = localStorage.getItem(process.env.VUE_APP_PROJECT_MANAGER_LIST); |
| | | state.projectManagerList = JSON.parse(projectManagerList); |
| | | state.projectManagerList = state.projectManagerList?state.projectManagerList:[]; |
| | | }catch (e){ |
| | | console.error(e.message); |
| | | } |
| | | } |
| | | return state.projectManagerList; |
| | | }, |
| | | generalManagerList: state=>{ |
| | | if(!state.generalManagerList) { |
| | | try { |
| | | const generalManagerList = localStorage.getItem(process.env.VUE_APP_GENERAL_MANAGER_LIST); |
| | | state.generalManagerList = JSON.parse(generalManagerList); |
| | | state.generalManagerList = state.generalManagerList?state.generalManagerList:[]; |
| | | }catch (e){ |
| | | console.error(e.message); |
| | | } |
| | | } |
| | | return state.generalManagerList; |
| | | } |
| | | }, |
| | | mutations: { |
| | |
| | | setDownloadFlag(state, downloadFlag) { |
| | | state.downloadFlag = downloadFlag; |
| | | localStorage.setItem(process.env.VUE_APP_DOWNLOAD_FLAG, downloadFlag); |
| | | }, |
| | | setProjectManagerList(state, projectManagerList) { |
| | | state.projectManagerList = projectManagerList; |
| | | localStorage.setItem(process.env.VUE_APP_PROJECT_MANAGER_LIST, JSON.stringify(projectManagerList)); |
| | | }, |
| | | setGeneralManagerList(state, generalManagerList) { |
| | | state.generalManagerList = generalManagerList; |
| | | localStorage.setItem(process.env.VUE_APP_GENERAL_MANAGER_LIST, JSON.stringify(generalManagerList)); |
| | | } |
| | | } |
| | | } |