This commit is contained in:
2023-04-03 11:14:32 +08:00
commit e423452dfd
70 changed files with 14097 additions and 0 deletions

55
src/vuex/modules/user.js Normal file
View File

@@ -0,0 +1,55 @@
import * as types from '../types'
import { getStore, setStore } from '@config/utils.js'
const state = {
accountId: getStore('accountId') || '',
accountName: getStore('accountName') || '',
userName: getStore('userName') || '',
deptName: getStore('deptName') || ''
}
const getters = {
accountId: state => state.accountId,
accountName: state => state.accountName,
userName: state => state.userName,
deptName: state => state.deptName
}
const actions = {
setUserInfo ({ commit }, res) {
setStore('accountId', res.account_id)
setStore('accountName', res.account_name)
setStore('userName', res.user_name)
setStore('deptName', res.dept_name)
commit(types.SET_USER_INFO, res)
},
setSignOut ({ commit }) {
localStorage.removeItem('accountId')
localStorage.removeItem('accountName')
localStorage.removeItem('userName')
localStorage.removeItem('deptName')
commit(types.SET_SIGN_OUT)
}
}
const mutations = {
[types.SET_USER_INFO] (state, res) {
state.accountId = res.account_id
state.accountName = res.account_name
state.userName = res.user_name
state.deptName = res.dept_name
},
[types.SET_SIGN_OUT] (state) {
state.accountId = ''
state.accountName = ''
state.userName = ''
state.deptName = ''
}
}
export default {
state,
getters,
actions,
mutations
}