1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const UserContext = {
state: {
userName: "",
userId: "",
ptyCode: "",
menu: [],
state: "LOGOUT",
token: "",
curRole: null,
currentOrg: null,
homeCellsSetting: {
defaultCells: [],
cellRows: 2,
cellCols: 2,
cellNames: [
['QuickVisit', 'TaskStatistics'],
['CustomerAnalyse', 'NoticeAnnouncement']
]
}
},
mutations: {
// 设置全局的用户信息
setLoginInfo(state, info) {
state.state = "LOGIN"
state.userId = info.userId
state.userName = info.userName
state.ptyCode = info.ptyCode
state.menu = info.menu
state.token = info.token
state.curRole = info.curRole
state.currentOrg = info.currentOrg
window.sessionStorage.userId = info.userId
window.sessionStorage.userName = info.username
window.sessionStorage.ptyCode = info.ptyCode
window.sessionStorage.menu = info.menu
//window.sessionStorage.token = info.token
window.sessionStorage.curRole = JSON.stringify(info.curRole)
window.sessionStorage.currentOrg = JSON.stringify(info.currentOrg)
window.sessionStorage.accbch = JSON.stringify(info.accbch)
window.sessionStorage.usr = JSON.stringify(info.usr)
},
updateCurrentOrg (state, parsms) {
window.sessionStorage.currentOrg = JSON.stringify(parsms)
state.currentOrg = parsms
},
updateAccbch (state, parsms) {
window.sessionStorage.accbch = JSON.stringify(parsms)
state.accbch = parsms
},
updateUsr (state, parsms) {
window.sessionStorage.usr = JSON.stringify(parsms)
state.usr = parsms
},
updateCurRole (state,parsms) {
window.sessionStorage.curRole = JSON.stringify(parsms)
state.curRole = parsms
},
setLogout(state) {
state.userName = ""
state.userId = ""
state.ptyCode = ""
state.menu = []
state.state = "LOGOUT"
state.token = ""
},
setMenu(state, menu) {
state.menu = menu;
},
setHomeCellsSetting(state, setting) {
state.homeCellsSetting.cellRows = setting.cellRows
state.homeCellsSetting.cellCols = setting.cellCols
state.homeCellsSetting.cellNames = setting.cellNames
localStorage.setItem(`cells-setting-${state.userId}`, JSON.stringify(setting));
},
setHomeDefaultCells(state, cells) {
state.homeCellsSetting.defaultCells = cells;
}
}
}
export default UserContext;