|
@@ -1,8 +1,8 @@
|
|
|
-import { fastLogin, logout, login,complogin, getRoule, getCurrentUserInfo, companyInfo, isLandBased, getAccountLoginHistoryCount, updateShowInfo }
|
|
|
- from '@/model/indexRx'
|
|
|
+import { fastLogin, logout, login, complogin, getRoule, getCurrentUserInfo, companyInfo, isLandBased, getAccountLoginHistoryCount, updateShowInfo }
|
|
|
+from '@/model/indexRx'
|
|
|
import { getNoviceGuideData, findVesselSysVersion, getStaffHomeShowList } from '@/model/indexRx'
|
|
|
import {
|
|
|
- getTenantInfoByUser,
|
|
|
+ getTenantInfoByUser,
|
|
|
} from '@/model/signIn/index'
|
|
|
import { setToken, getCompanyId, clearStorage } from '../../utils/auth'
|
|
|
import { resetRouter, asyncRoutes } from '../../router'
|
|
@@ -10,309 +10,332 @@ import notification from '../../notification'
|
|
|
import { Message } from 'element-ui';
|
|
|
import Cookies from 'js-cookie'
|
|
|
import {
|
|
|
- setStore,
|
|
|
+ setStore,
|
|
|
} from '@/utils/store'
|
|
|
import { groupBy } from 'lodash'
|
|
|
|
|
|
const state = {
|
|
|
- token: '',
|
|
|
- name: '',
|
|
|
- avatar: '',
|
|
|
- openRoute:[],
|
|
|
- companyId: getCompanyId(),
|
|
|
- introduction: '',
|
|
|
- roles: [],
|
|
|
- tabActiveName: '', // 用于存放采购管理模块的tab
|
|
|
- baseInfo: {},
|
|
|
- scheduleState: true,
|
|
|
- guideInfo: {},
|
|
|
- isTrainDialog: '',
|
|
|
- userInfo: '',
|
|
|
- userSetting: '',
|
|
|
- adminId: Cookies.get('adminId') || ''
|
|
|
+ carNumber1: '',
|
|
|
+ carNumber2: '',
|
|
|
+ token: '',
|
|
|
+ name: '',
|
|
|
+ avatar: '',
|
|
|
+ openRoute: [],
|
|
|
+ companyId: getCompanyId(),
|
|
|
+ introduction: '',
|
|
|
+ roles: [],
|
|
|
+ tabActiveName: '', // 用于存放采购管理模块的tab
|
|
|
+ baseInfo: {},
|
|
|
+ scheduleState: true,
|
|
|
+ guideInfo: {},
|
|
|
+ isTrainDialog: '',
|
|
|
+ userInfo: '',
|
|
|
+ userSetting: '',
|
|
|
+ adminId: Cookies.get('adminId') || ''
|
|
|
}
|
|
|
|
|
|
const getters = {
|
|
|
- // ...
|
|
|
- getUserSetting: (state, getters) => {
|
|
|
- return getters.userSetting
|
|
|
- }
|
|
|
+ // ...
|
|
|
+ getUserSetting: (state, getters) => {
|
|
|
+ return getters.userSetting
|
|
|
+ },
|
|
|
}
|
|
|
|
|
|
const mutations = {
|
|
|
- // 设置基础信息
|
|
|
- SET_BASE_INFO: (state, baseInfo) => {
|
|
|
- state.baseInfo = { ...baseInfo } // , fileUrl: '/pb'
|
|
|
- },
|
|
|
- // 新手指引信息
|
|
|
- SET_GUIDE_INFO: (state, guideInfo) => {
|
|
|
- state.guideInfo = { ...guideInfo }
|
|
|
- },
|
|
|
- SET_TOKEN: (state, token) => {
|
|
|
- state.token = token
|
|
|
- },
|
|
|
- SET_INTRODUCTION: (state, introduction) => {
|
|
|
- state.introduction = introduction
|
|
|
- },
|
|
|
- SET_NAME: (state, name) => {
|
|
|
- state.name = name
|
|
|
- },
|
|
|
- SET_AVATAR: (state, avatar) => {
|
|
|
- state.avatar = avatar
|
|
|
- },
|
|
|
- SET_ROLES: (state, roles) => {
|
|
|
- state.roles = roles
|
|
|
- },
|
|
|
- SET_OPEN_ROUTE: (state, openRoute) => {
|
|
|
- console.log(state, openRoute)
|
|
|
- state.openRoute = openRoute
|
|
|
- },
|
|
|
- SET_COMPANY: (state, companyId) => {
|
|
|
- state.companyId = companyId
|
|
|
- },
|
|
|
- // SET_TRAIN: (state, isTrainDialog) => {
|
|
|
- // state.isTrainDialog = isTrainDialog
|
|
|
- // },
|
|
|
- SET_TABNAME: (state, tabActiveName) => {
|
|
|
- state.tabActiveName = tabActiveName
|
|
|
- },
|
|
|
- SET_SCHEDULE_STATE: (state, params) => {
|
|
|
- state.scheduleState = params
|
|
|
- },
|
|
|
- SET_USER_INFO: (state, params) => {
|
|
|
- state.userInfo = params
|
|
|
- },
|
|
|
- SET_USERSETTING: (state, params) => {
|
|
|
- state.userSetting = params
|
|
|
- },
|
|
|
- SET_ADMINID: (state, adminId) => {
|
|
|
- state.adminId = adminId
|
|
|
- Cookies.set('adminId', adminId)
|
|
|
- }
|
|
|
+ // 设置基础信息
|
|
|
+ SET_BASE_INFO: (state, baseInfo) => {
|
|
|
+ state.baseInfo = {...baseInfo } // , fileUrl: '/pb'
|
|
|
+ },
|
|
|
+ // 新手指引信息
|
|
|
+ SET_GUIDE_INFO: (state, guideInfo) => {
|
|
|
+ state.guideInfo = {...guideInfo }
|
|
|
+ },
|
|
|
+ SET_TOKEN: (state, token) => {
|
|
|
+ state.token = token
|
|
|
+ },
|
|
|
+ SET_VIDEOSRC1: (state, videoSrc1) => {
|
|
|
+ state.videoSrc1 = videoSrc1
|
|
|
+ },
|
|
|
+ SET_VIDEOSRC2: (state, videoSrc2) => {
|
|
|
+ state.videoSrc2 = videoSrc2
|
|
|
+ },
|
|
|
+ SET_CARNUMBER1: (state, carNumber1) => {
|
|
|
+ state.carNumber1 = carNumber1
|
|
|
+ },
|
|
|
+ SET_CARNUMBER2: (state, carNumber2) => {
|
|
|
+ state.carNumber2 = carNumber2
|
|
|
+ },
|
|
|
+
|
|
|
+ SET_INTRODUCTION: (state, introduction) => {
|
|
|
+ state.introduction = introduction
|
|
|
+ },
|
|
|
+ SET_NAME: (state, name) => {
|
|
|
+ state.name = name
|
|
|
+ },
|
|
|
+ SET_AVATAR: (state, avatar) => {
|
|
|
+ state.avatar = avatar
|
|
|
+ },
|
|
|
+ SET_ROLES: (state, roles) => {
|
|
|
+ state.roles = roles
|
|
|
+ },
|
|
|
+ SET_OPEN_ROUTE: (state, openRoute) => {
|
|
|
+ state.openRoute = openRoute
|
|
|
+ },
|
|
|
+ SET_COMPANY: (state, companyId) => {
|
|
|
+ state.companyId = companyId
|
|
|
+ },
|
|
|
+ // SET_TRAIN: (state, isTrainDialog) => {
|
|
|
+ // state.isTrainDialog = isTrainDialog
|
|
|
+ // },
|
|
|
+ SET_TABNAME: (state, tabActiveName) => {
|
|
|
+ state.tabActiveName = tabActiveName
|
|
|
+ },
|
|
|
+ SET_SCHEDULE_STATE: (state, params) => {
|
|
|
+ state.scheduleState = params
|
|
|
+ },
|
|
|
+ SET_USER_INFO: (state, params) => {
|
|
|
+ state.userInfo = params
|
|
|
+ },
|
|
|
+ SET_USERSETTING: (state, params) => {
|
|
|
+ state.userSetting = params
|
|
|
+ },
|
|
|
+ SET_ADMINID: (state, adminId) => {
|
|
|
+ state.adminId = adminId
|
|
|
+ Cookies.set('adminId', adminId)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
const actions = {
|
|
|
- async login({ commit, dispatch }, userInfo) {
|
|
|
- const { username, password, domainName, companyName,status } = userInfo
|
|
|
- localStorage.setItem('ws-pf_pass',password)
|
|
|
- const data = await login({
|
|
|
- username: username.trim(),
|
|
|
- password: password,
|
|
|
- domainName: domainName,
|
|
|
- companyName: companyName
|
|
|
- }).toPromise()
|
|
|
-
|
|
|
- const { compId,
|
|
|
- tenantId,
|
|
|
- vesselId,
|
|
|
- vesselBankFlag,
|
|
|
- clientFag,
|
|
|
- userId
|
|
|
- } = data
|
|
|
+ async login({ commit, dispatch }, userInfo) {
|
|
|
+ const { username, password, domainName, companyName, status } = userInfo
|
|
|
+ localStorage.setItem('ws-pf_pass', password)
|
|
|
+ const data = await login({
|
|
|
+ username: username.trim(),
|
|
|
+ password: password,
|
|
|
+ domainName: domainName,
|
|
|
+ companyName: companyName
|
|
|
+ }).toPromise()
|
|
|
|
|
|
- // {TYPE='' MESSAGE} [第一次,失效].indexOf(type){type,msg,到期时间}
|
|
|
- // EventBus.$emit('success', '登录成功')
|
|
|
- localStorage.setItem('ws-pf_compId', compId)
|
|
|
- localStorage.setItem('ws-pf_userId', userId)
|
|
|
- localStorage.setItem('ws-pf_tenantId', tenantId)
|
|
|
- localStorage.setItem('ws-pf_vesselId', vesselId) // 仅适用于一条船
|
|
|
- localStorage.setItem('ws-pf_vesselBankFlag', vesselBankFlag) // 当前登录人是船端还是岸端的人员
|
|
|
- localStorage.setItem('ws-pf_clientFag', clientFag)
|
|
|
- notification.setSessionId(userId) // 设置通知唯一标识
|
|
|
- notification.start() // 开始监听通知
|
|
|
- // 查询当前租户服务类型
|
|
|
- await isLandBased().toPromise().then(response => {
|
|
|
- localStorage.setItem('ws-pf_serviceTypeFlag', response)
|
|
|
- })
|
|
|
- const { organizationMonetaryKey,
|
|
|
- compName,
|
|
|
- compDomainName,
|
|
|
- organizationMonetaryValue
|
|
|
- } = await companyInfo({ compId: compId }).toPromise()
|
|
|
- localStorage.setItem('ws-pf_organMonetaryKey', organizationMonetaryKey)
|
|
|
- localStorage.setItem('ws-pf_compName', compName)
|
|
|
- localStorage.setItem('ws-pf_compDomainName', compDomainName)
|
|
|
- localStorage.setItem('ws-pf_organMonetaryValue', organizationMonetaryValue)
|
|
|
- dispatch('getUserInfo', { vesselBankFlag, compName })
|
|
|
- dispatch('toSetShow', userId)
|
|
|
- setToken('Admin-Token')
|
|
|
- return data
|
|
|
- },
|
|
|
-
|
|
|
- // async complogin({ commit, dispatch }, userInfo) {
|
|
|
-
|
|
|
-
|
|
|
- // },
|
|
|
- async fastLogin({ dispatch }, userInfo) {
|
|
|
- const { mobilePhone, veriCode } = userInfo
|
|
|
- const data = await fastLogin({
|
|
|
- mobilePhone: mobilePhone,
|
|
|
- veriCode: veriCode
|
|
|
- }).toPromise()
|
|
|
- const {
|
|
|
- compId,
|
|
|
- userId,
|
|
|
- tenantId,
|
|
|
- vesselId,
|
|
|
- vesselBankFlag
|
|
|
- } = data
|
|
|
- localStorage.setItem('ws-pf_compId', compId)
|
|
|
- localStorage.setItem('ws-pf_userId', userId)
|
|
|
- localStorage.setItem('ws-pf_tenantId', tenantId)
|
|
|
- localStorage.setItem('ws-pf_vesselId', vesselId) // 仅适用于一条船
|
|
|
- localStorage.setItem('ws-pf_vesselBankFlag', vesselBankFlag) // 当前登录人是船端还是岸端的人员
|
|
|
+ const {
|
|
|
+ compId,
|
|
|
+ tenantId,
|
|
|
+ vesselId,
|
|
|
+ vesselBankFlag,
|
|
|
+ clientFag,
|
|
|
+ userId
|
|
|
+ } = data
|
|
|
+
|
|
|
+ // {TYPE='' MESSAGE} [第一次,失效].indexOf(type){type,msg,到期时间}
|
|
|
+ // EventBus.$emit('success', '登录成功')
|
|
|
+ localStorage.setItem('ws-pf_compId', compId)
|
|
|
+ localStorage.setItem('ws-pf_userId', userId)
|
|
|
+ localStorage.setItem('ws-pf_tenantId', tenantId)
|
|
|
+ localStorage.setItem('ws-pf_vesselId', vesselId) // 仅适用于一条船
|
|
|
+ localStorage.setItem('ws-pf_vesselBankFlag', vesselBankFlag) // 当前登录人是船端还是岸端的人员
|
|
|
+ localStorage.setItem('ws-pf_clientFag', clientFag)
|
|
|
+ notification.setSessionId(userId) // 设置通知唯一标识
|
|
|
+ notification.start() // 开始监听通知
|
|
|
+ // 查询当前租户服务类型
|
|
|
+ await isLandBased().toPromise().then(response => {
|
|
|
+ localStorage.setItem('ws-pf_serviceTypeFlag', response)
|
|
|
+ })
|
|
|
+ const {
|
|
|
+ organizationMonetaryKey,
|
|
|
+ compName,
|
|
|
+ compDomainName,
|
|
|
+ organizationMonetaryValue
|
|
|
+ } = await companyInfo({ compId: compId }).toPromise()
|
|
|
+ localStorage.setItem('ws-pf_organMonetaryKey', organizationMonetaryKey)
|
|
|
+ localStorage.setItem('ws-pf_compName', compName)
|
|
|
+ localStorage.setItem('ws-pf_compDomainName', compDomainName)
|
|
|
+ localStorage.setItem('ws-pf_organMonetaryValue', organizationMonetaryValue)
|
|
|
+ dispatch('getUserInfo', { vesselBankFlag, compName })
|
|
|
+ dispatch('toSetShow', userId)
|
|
|
+ setToken('Admin-Token')
|
|
|
+ return data
|
|
|
+ },
|
|
|
|
|
|
- notification.setSessionId(userId) // 设置通知唯一标识
|
|
|
- notification.start() // 开始监听通知
|
|
|
+ // async complogin({ commit, dispatch }, userInfo) {
|
|
|
|
|
|
- // 查询当前租户服务类型
|
|
|
- isLandBased().toPromise().then(response => {
|
|
|
- localStorage.setItem('ws-pf_serviceTypeFlag', response)
|
|
|
- })
|
|
|
- const {
|
|
|
- organizationMonetaryKey,
|
|
|
- compName,
|
|
|
- organizationMonetaryValue
|
|
|
- } = await companyInfo({ compId: compId }).toPromise()
|
|
|
|
|
|
- localStorage.setItem('ws-pf_organMonetaryKey', organizationMonetaryKey)
|
|
|
- localStorage.setItem('ws-pf_compName', compName)
|
|
|
- localStorage.setItem(
|
|
|
- 'ws-pf_organMonetaryValue',
|
|
|
- organizationMonetaryValue
|
|
|
- )
|
|
|
- dispatch('getUserInfo', { vesselBankFlag, compName })
|
|
|
- dispatch('toSetShow', userId)
|
|
|
- setToken('Admin-Token')
|
|
|
- return data
|
|
|
+ // },
|
|
|
+ async fastLogin({ dispatch }, userInfo) {
|
|
|
+ const { mobilePhone, veriCode } = userInfo
|
|
|
+ const data = await fastLogin({
|
|
|
+ mobilePhone: mobilePhone,
|
|
|
+ veriCode: veriCode
|
|
|
+ }).toPromise()
|
|
|
+ const {
|
|
|
+ compId,
|
|
|
+ userId,
|
|
|
+ tenantId,
|
|
|
+ vesselId,
|
|
|
+ vesselBankFlag
|
|
|
+ } = data
|
|
|
+ localStorage.setItem('ws-pf_compId', compId)
|
|
|
+ localStorage.setItem('ws-pf_userId', userId)
|
|
|
+ localStorage.setItem('ws-pf_tenantId', tenantId)
|
|
|
+ localStorage.setItem('ws-pf_vesselId', vesselId) // 仅适用于一条船
|
|
|
+ localStorage.setItem('ws-pf_vesselBankFlag', vesselBankFlag) // 当前登录人是船端还是岸端的人员
|
|
|
|
|
|
- },
|
|
|
- // get user info
|
|
|
- getRoule({ commit, state }) {
|
|
|
- return new Promise(async (resolve, reject) => {
|
|
|
- try {
|
|
|
- const data = await getRoule(state.roles)
|
|
|
- data.forEach(route => { asyncRoutes.push(route) })
|
|
|
- commit('SET_ROUTES', asyncRoutes)
|
|
|
- resolve(asyncRoutes)
|
|
|
- } catch (error) {
|
|
|
- reject(error)
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
+ notification.setSessionId(userId) // 设置通知唯一标识
|
|
|
+ notification.start() // 开始监听通知
|
|
|
|
|
|
- // user logout
|
|
|
- logout({ commit, state }) {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- logout(state.token).toPromise()
|
|
|
- .then(() => {
|
|
|
- commit('SET_TOKEN', '')
|
|
|
- commit('SET_COMPANY', '')
|
|
|
- // commit('SET_TRAIN', '')
|
|
|
- commit('SET_ROLES', [])
|
|
|
- commit('SET_OPEN_ROUTE', [])
|
|
|
- commit('SET_GUIDE_INFO', [])
|
|
|
- commit('permission/SET_ROUTES', [], { root: true }) // 清空路由,因为有权限管理
|
|
|
- localStorage.removeItem('wf-pf_admin-token')
|
|
|
- clearStorage()
|
|
|
- resetRouter()
|
|
|
- notification.end() // 取消监听通知
|
|
|
- resolve()
|
|
|
+ // 查询当前租户服务类型
|
|
|
+ isLandBased().toPromise().then(response => {
|
|
|
+ localStorage.setItem('ws-pf_serviceTypeFlag', response)
|
|
|
})
|
|
|
- .catch(error => {
|
|
|
- reject(error)
|
|
|
+ const {
|
|
|
+ organizationMonetaryKey,
|
|
|
+ compName,
|
|
|
+ organizationMonetaryValue
|
|
|
+ } = await companyInfo({ compId: compId }).toPromise()
|
|
|
+
|
|
|
+ localStorage.setItem('ws-pf_organMonetaryKey', organizationMonetaryKey)
|
|
|
+ localStorage.setItem('ws-pf_compName', compName)
|
|
|
+ localStorage.setItem(
|
|
|
+ 'ws-pf_organMonetaryValue',
|
|
|
+ organizationMonetaryValue
|
|
|
+ )
|
|
|
+ dispatch('getUserInfo', { vesselBankFlag, compName })
|
|
|
+ dispatch('toSetShow', userId)
|
|
|
+ setToken('Admin-Token')
|
|
|
+ return data
|
|
|
+
|
|
|
+ },
|
|
|
+ // get user info
|
|
|
+ getRoule({ commit, state }) {
|
|
|
+ return new Promise(async(resolve, reject) => {
|
|
|
+ try {
|
|
|
+ const data = await getRoule(state.roles)
|
|
|
+ data.forEach(route => { asyncRoutes.push(route) })
|
|
|
+ commit('SET_ROUTES', asyncRoutes)
|
|
|
+ resolve(asyncRoutes)
|
|
|
+ } catch (error) {
|
|
|
+ reject(error)
|
|
|
+ }
|
|
|
})
|
|
|
- })
|
|
|
- },
|
|
|
+ },
|
|
|
|
|
|
- // remove token
|
|
|
- resetToken({ commit }) {
|
|
|
- return new Promise(resolve => {
|
|
|
- commit('SET_TOKEN', '')
|
|
|
- commit('SET_ROLES', [])
|
|
|
- clearStorage()
|
|
|
- resolve()
|
|
|
- })
|
|
|
- },
|
|
|
+ // user logout
|
|
|
+ logout({ commit, state }) {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ logout(state.token).toPromise()
|
|
|
+ .then(() => {
|
|
|
+ commit('SET_TOKEN', '')
|
|
|
+ commit('SET_COMPANY', '')
|
|
|
+ // commit('SET_TRAIN', '')
|
|
|
+ commit('SET_ROLES', [])
|
|
|
+ commit('SET_OPEN_ROUTE', [])
|
|
|
+ commit('SET_GUIDE_INFO', [])
|
|
|
+ commit('permission/SET_ROUTES', [], { root: true }) // 清空路由,因为有权限管理
|
|
|
+ localStorage.removeItem('wf-pf_admin-token')
|
|
|
+ clearStorage()
|
|
|
+ resetRouter()
|
|
|
+ notification.end() // 取消监听通知
|
|
|
+ resolve()
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ reject(error)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
|
|
|
- async getBaseInfo({ commit }, params) {
|
|
|
- if (process.env.VUE_APP_PACKAGE_ENV === 'ship') {
|
|
|
- findVesselSysVersion().toPromise().then(res => {
|
|
|
- let loginAddress = 'http://' + res.localHostAddress + ':81/'
|
|
|
- commit('SET_BASE_INFO', {
|
|
|
- fileUrl: loginAddress
|
|
|
+ // remove token
|
|
|
+ resetToken({ commit }) {
|
|
|
+ return new Promise(resolve => {
|
|
|
+ commit('SET_TOKEN', '')
|
|
|
+ commit('SET_ROLES', [])
|
|
|
+ clearStorage()
|
|
|
+ resolve()
|
|
|
})
|
|
|
- })
|
|
|
- } else {
|
|
|
- }
|
|
|
+ },
|
|
|
|
|
|
- },
|
|
|
- setScheduleState({ commit }, params) {
|
|
|
- commit('SET_SCHEDULE_STATE', params)
|
|
|
- },
|
|
|
- async getTrainInfo({ commit }, params) {
|
|
|
- let guideData = await getNoviceGuideData().toPromise()
|
|
|
- commit('SET_GUIDE_INFO', guideData.data)
|
|
|
- },
|
|
|
+ async getBaseInfo({ commit }, params) {
|
|
|
+ if (process.env.VUE_APP_PACKAGE_ENV === 'ship') {
|
|
|
+ findVesselSysVersion().toPromise().then(res => {
|
|
|
+ let loginAddress = 'http://' + res.localHostAddress + ':81/'
|
|
|
+ commit('SET_BASE_INFO', {
|
|
|
+ fileUrl: loginAddress
|
|
|
+ })
|
|
|
+ })
|
|
|
+ } else {}
|
|
|
|
|
|
- async getNewLogin({ commit }, params) {
|
|
|
- // let res = await getAccountLoginHistoryCount().toPromise()
|
|
|
- // commit('SET_TRAIN', res * 1 <= 0 ? 'new' : 'old')
|
|
|
- },
|
|
|
- async getUserInfo({ commit, dispatch }, { vesselBankFlag = 'B', compName = '' }) {
|
|
|
- const response = await getCurrentUserInfo().toPromise()
|
|
|
- const {
|
|
|
- staffName, deptId, deptName, deptNameEn, vessels = [],
|
|
|
- majorRole: { roleName = '', roleId = '', dutyId = '' },
|
|
|
- roles
|
|
|
- } = response
|
|
|
- const content = {
|
|
|
- ...response,
|
|
|
- showRoleName: roleName || roles[0].roleName,
|
|
|
- showRoleId: roleId || roles[0].roleId,
|
|
|
- showCompName: vesselBankFlag === 'V' ? vessels[0].vesselName : compName,
|
|
|
- avatar: 'img/user.png'
|
|
|
- }
|
|
|
- setStore({
|
|
|
- name: 'userInfo', content: content, type: 'session'
|
|
|
- })
|
|
|
- dispatch('common/setLocalVessels', vessels, { root: true })
|
|
|
- commit('SET_USER_INFO', content)
|
|
|
+ },
|
|
|
+ setScheduleState({ commit }, params) {
|
|
|
+ commit('SET_SCHEDULE_STATE', params)
|
|
|
+ },
|
|
|
+ async getTrainInfo({ commit }, params) {
|
|
|
+ let guideData = await getNoviceGuideData().toPromise()
|
|
|
+ commit('SET_GUIDE_INFO', guideData.data)
|
|
|
+ },
|
|
|
+
|
|
|
+ async getNewLogin({ commit }, params) {
|
|
|
+ // let res = await getAccountLoginHistoryCount().toPromise()
|
|
|
+ // commit('SET_TRAIN', res * 1 <= 0 ? 'new' : 'old')
|
|
|
+ },
|
|
|
+ async getUserInfo({ commit, dispatch }, { vesselBankFlag = 'B', compName = '' }) {
|
|
|
+ const response = await getCurrentUserInfo().toPromise()
|
|
|
+ const {
|
|
|
+ staffName,
|
|
|
+ deptId,
|
|
|
+ deptName,
|
|
|
+ deptNameEn,
|
|
|
+ vessels = [],
|
|
|
+ majorRole: { roleName = '', roleId = '', dutyId = '' },
|
|
|
+ roles
|
|
|
+ } = response
|
|
|
+ const content = {
|
|
|
+ ...response,
|
|
|
+ showRoleName: roleName || roles[0].roleName,
|
|
|
+ showRoleId: roleId || roles[0].roleId,
|
|
|
+ showCompName: vesselBankFlag === 'V' ? vessels[0].vesselName : compName,
|
|
|
+ avatar: 'img/user.png'
|
|
|
+ }
|
|
|
+ setStore({
|
|
|
+ name: 'userInfo',
|
|
|
+ content: content,
|
|
|
+ type: 'session'
|
|
|
+ })
|
|
|
+ dispatch('common/setLocalVessels', vessels, { root: true })
|
|
|
+ commit('SET_USER_INFO', content)
|
|
|
|
|
|
- localStorage.setItem('ws-pf_dutyId', dutyId || response.roles[0].dutyId)
|
|
|
- localStorage.setItem('ws-pf_roleName', roleName || roles[0].roleName)
|
|
|
+ localStorage.setItem('ws-pf_dutyId', dutyId || response.roles[0].dutyId)
|
|
|
+ localStorage.setItem('ws-pf_roleName', roleName || roles[0].roleName)
|
|
|
|
|
|
- localStorage.setItem('ws-pf_staffName', staffName)
|
|
|
- localStorage.setItem('ws-pf_deptId', deptId)
|
|
|
- localStorage.setItem('ws-pf_deptName', deptName)
|
|
|
- localStorage.setItem('ws-pf_deptNameEn', deptNameEn)
|
|
|
- localStorage.setItem('ws-pf_vessels', JSON.stringify(vessels))
|
|
|
- localStorage.setItem('ws-pf_roleId', roleId || roles[0].roleId)
|
|
|
+ localStorage.setItem('ws-pf_staffName', staffName)
|
|
|
+ localStorage.setItem('ws-pf_deptId', deptId)
|
|
|
+ localStorage.setItem('ws-pf_deptName', deptName)
|
|
|
+ localStorage.setItem('ws-pf_deptNameEn', deptNameEn)
|
|
|
+ localStorage.setItem('ws-pf_vessels', JSON.stringify(vessels))
|
|
|
+ localStorage.setItem('ws-pf_roleId', roleId || roles[0].roleId)
|
|
|
|
|
|
- },
|
|
|
- async toSetShow({ commit, dispatch }, { userId = '' }) {
|
|
|
- const data = await getStaffHomeShowList({
|
|
|
- staffId: userId
|
|
|
- }).toPromise()
|
|
|
- const showObject = groupBy(data, 'typeId')
|
|
|
- setStore({
|
|
|
- name: 'userSetting', content: showObject, type: 'session'
|
|
|
- })
|
|
|
- commit('SET_USERSETTING', showObject)
|
|
|
- },
|
|
|
- async changeVesslBank({ commit, dispatch, state }, showVal) {
|
|
|
- await updateShowInfo(showVal).toPromise()
|
|
|
- dispatch('toSetShow', { userId: localStorage.getItem('ws-pf_userId') })
|
|
|
- },
|
|
|
- setAdminId({ commit }, adminId) {
|
|
|
- commit('SET_ADMINID', adminId)
|
|
|
- },
|
|
|
+ },
|
|
|
+ async toSetShow({ commit, dispatch }, { userId = '' }) {
|
|
|
+ const data = await getStaffHomeShowList({
|
|
|
+ staffId: userId
|
|
|
+ }).toPromise()
|
|
|
+ const showObject = groupBy(data, 'typeId')
|
|
|
+ setStore({
|
|
|
+ name: 'userSetting',
|
|
|
+ content: showObject,
|
|
|
+ type: 'session'
|
|
|
+ })
|
|
|
+ commit('SET_USERSETTING', showObject)
|
|
|
+ },
|
|
|
+ async changeVesslBank({ commit, dispatch, state }, showVal) {
|
|
|
+ await updateShowInfo(showVal).toPromise()
|
|
|
+ dispatch('toSetShow', { userId: localStorage.getItem('ws-pf_userId') })
|
|
|
+ },
|
|
|
+ setAdminId({ commit }, adminId) {
|
|
|
+ commit('SET_ADMINID', adminId)
|
|
|
+ },
|
|
|
}
|
|
|
|
|
|
export default {
|
|
|
- namespaced: true,
|
|
|
- state,
|
|
|
- mutations,
|
|
|
- actions,
|
|
|
- getters
|
|
|
-}
|
|
|
+ namespaced: true,
|
|
|
+ state,
|
|
|
+ mutations,
|
|
|
+ actions,
|
|
|
+ getters
|
|
|
+}
|