code init
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* @description: actions
|
||||
*/
|
||||
export default {
|
||||
// 设置token
|
||||
setToken (content, token) {
|
||||
content.commit('setToken', token)
|
||||
},
|
||||
// 退出登录
|
||||
logout ({ commit }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
commit('logout')
|
||||
resolve()
|
||||
})
|
||||
},
|
||||
// 保存菜单
|
||||
setMenu (content, menuList) {
|
||||
return new Promise((resolve, reject) => {
|
||||
content.commit('setMenu', menuList)
|
||||
resolve()
|
||||
})
|
||||
},
|
||||
syncStorageData({state}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
sessionStorage.clear()
|
||||
|
||||
try {
|
||||
if (localStorage.theme) { state.defaultTheme = localStorage.theme }
|
||||
if (localStorage.token) { state.defaultToken = localStorage.token }
|
||||
if (localStorage.token) { state.token = localStorage.token }
|
||||
if (sessionStorage.process) { state.process = sessionStorage.process }
|
||||
if (localStorage.userInfo) { state.userInfo = localStorage.userInfo }
|
||||
if (localStorage.userInfoModifyTime) { state.userInfoModifyTime = localStorage.userInfoModifyTime || '0' }
|
||||
if (localStorage.laws_urm) { state.lawsUrm = localStorage.laws_urm }
|
||||
if (localStorage.laws_prm) { state.lawsPrm = localStorage.laws_prm }
|
||||
if (sessionStorage.detailMap) { state.detailMap = sessionStorage.detailMap }
|
||||
if (sessionStorage.dynamicSearch) { state.dynamicSearch = sessionStorage.dynamicSearch }
|
||||
if (sessionStorage.dynamicTotal) { state.dynamicTotal = sessionStorage.dynamicTotal }
|
||||
if (sessionStorage.processForm) { state.processForm = sessionStorage.processForm }
|
||||
if (sessionStorage.processStandard) { state.processStandard = sessionStorage.processStandard }
|
||||
if (sessionStorage.processState) { state.processState = sessionStorage.processState }
|
||||
if (localStorage.menuList) { state.menuList = localStorage.menuList }
|
||||
if (sessionStorage.lastDetailMap) { state.lastDetailMap = sessionStorage.lastDetailMap }
|
||||
if (sessionStorage.searchInfoEO) { state.searchInfoEO = sessionStorage.searchInfoEO }
|
||||
if (sessionStorage.dynamicsPage) { state.searchInfoEO = sessionStorage.dynamicsPage }
|
||||
if (localStorage.JSESSIONID) { state.JSESSIONID = localStorage.JSESSIONID }
|
||||
if (sessionStorage.localPro) { state.localPro = sessionStorage.localPro }
|
||||
if (sessionStorage.roleModuleList) { state.roleModuleList = sessionStorage.roleModuleList }
|
||||
if (sessionStorage.typeFlag) { state.typeFlag = sessionStorage.typeFlag }
|
||||
if (sessionStorage.standItemList) { state.standItemList = sessionStorage.standItemList }
|
||||
if (sessionStorage.processLastDetails) { state.processLastDetails = sessionStorage.processLastDetails }
|
||||
if (sessionStorage.language) { state.language = sessionStorage.language }
|
||||
if (sessionStorage.isCollapse) { state.isCollapse = sessionStorage.isCollapse }
|
||||
if (sessionStorage.handleInfo) { state.handleInfo = sessionStorage.handleInfo }
|
||||
if (sessionStorage.myBussStandardPlan) { state.myBussStandardPlan = sessionStorage.myBussStandardPlan }
|
||||
if (sessionStorage.proLastDetail) { state.proLastDetail = sessionStorage.proLastDetail }
|
||||
if (sessionStorage.rukuBaseInfo) { state.rukuBaseInfo = sessionStorage.rukuBaseInfo }
|
||||
resolve()
|
||||
} catch (e) {
|
||||
reject(e)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
/**
|
||||
* @description: getters
|
||||
*/
|
||||
const config = require('@/sysConfig')
|
||||
export default {
|
||||
userInfo: state => {
|
||||
if (state.userInfo === '') {
|
||||
return state.userInfo
|
||||
} else {
|
||||
let userInfo = JSON.parse(state.userInfo)
|
||||
if (userInfo.configContent === null || userInfo.configContent === undefined) {
|
||||
userInfo.configContent = 20
|
||||
} else {
|
||||
userInfo.configContent = parseInt(userInfo.configContent)
|
||||
}
|
||||
return userInfo
|
||||
}
|
||||
},
|
||||
getDynamicHistory: state => {
|
||||
if (state.dynamicSearch === '') {
|
||||
return state.dynamicSearch
|
||||
} else {
|
||||
return JSON.parse(state.dynamicSearch)
|
||||
}
|
||||
},
|
||||
getDynamicTotal: state => {
|
||||
if (state.dynamicTotal === '') {
|
||||
return {}
|
||||
} else {
|
||||
return JSON.parse(state.dynamicTotal)
|
||||
}
|
||||
},
|
||||
// 选择语言
|
||||
getLanguage: state => {
|
||||
if (state.language === '') {
|
||||
return 'cn'
|
||||
} else {
|
||||
return state.language
|
||||
}
|
||||
},
|
||||
// 流程办理
|
||||
getHandleInfo: state => {
|
||||
if (state.handleInfo === '') {
|
||||
return {}
|
||||
} else {
|
||||
return JSON.parse(state.handleInfo)
|
||||
}
|
||||
},
|
||||
proLastDetail: state => {
|
||||
if (state.proLastDetail === '') {
|
||||
return null
|
||||
} else {
|
||||
return JSON.parse(state.proLastDetail)
|
||||
}
|
||||
},
|
||||
getProcessForm: state => {
|
||||
if (state.processForm !== '') {
|
||||
return JSON.parse(state.processForm)
|
||||
} else {
|
||||
return ''
|
||||
}
|
||||
},
|
||||
getProcessStandard: state => {
|
||||
if (state.processStandard !== '') {
|
||||
return JSON.parse(state.processStandard)
|
||||
} else {
|
||||
return ''
|
||||
}
|
||||
},
|
||||
getProcessState: state => {
|
||||
if (state.processState !== '') {
|
||||
return parseInt(state.processState)
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
},
|
||||
getMenuList: state => {
|
||||
if (state.menuList !== '') {
|
||||
return JSON.parse(state.menuList)
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
},
|
||||
getLastDetailMap: state => {
|
||||
if (state.lastDetailMap !== '') {
|
||||
return JSON.parse(state.lastDetailMap)
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
},
|
||||
getSearchInfoEO: state => {
|
||||
if (state.searchInfoEO !== '') {
|
||||
return JSON.parse(state.searchInfoEO)
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
},
|
||||
getDynamicsPage: state => {
|
||||
if (state.dynamicsPage !== '') {
|
||||
return JSON.parse(state.dynamicsPage)
|
||||
} else {
|
||||
return ''
|
||||
}
|
||||
},
|
||||
getWebSocketList: state => {
|
||||
if (state.webSocketMessageList !== '') {
|
||||
return state.webSocketMessageList
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
},
|
||||
getTheme: state => {
|
||||
if (state.theme !== '') {
|
||||
return state.theme
|
||||
} else {
|
||||
return config.theme
|
||||
}
|
||||
},
|
||||
getRoleModule: state => {
|
||||
if (state.roleModuleList !== '') {
|
||||
return JSON.parse(state.roleModuleList)
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
},
|
||||
// 切换资源库状态
|
||||
getTypeFlag: state => {
|
||||
if (state.typeFlag !== '') {
|
||||
return state.typeFlag
|
||||
} else {
|
||||
return ''
|
||||
}
|
||||
},
|
||||
getItemList: state => {
|
||||
if (state.standItemList !== '') {
|
||||
return JSON.parse(state.standItemList)
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
},
|
||||
getDetails: state => {
|
||||
if (state.processLastDetails !== '') {
|
||||
return JSON.parse(state.processLastDetails)
|
||||
} else {
|
||||
return ''
|
||||
}
|
||||
},
|
||||
isCollapse: state => {
|
||||
if (state.isCollapse === '') {
|
||||
return false
|
||||
} else {
|
||||
return eval(state.isCollapse)
|
||||
}
|
||||
},
|
||||
getLocalPro: state => {
|
||||
if (state.localPro !== '') {
|
||||
return JSON.parse(state.localPro)
|
||||
} else {
|
||||
return {}
|
||||
}
|
||||
},
|
||||
myBussStandardPlan: state => {
|
||||
if (state.myBussStandardPlan === '') {
|
||||
return null
|
||||
} else {
|
||||
return JSON.parse(state.myBussStandardPlan)
|
||||
}
|
||||
},
|
||||
rukuBaseInfo: state => {
|
||||
if (state.rukuBaseInfo === '') {
|
||||
return null
|
||||
} else {
|
||||
return JSON.parse(state.rukuBaseInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
-15
@@ -1,22 +1,17 @@
|
||||
/**
|
||||
* @author chuzhixin 1204505056@qq.com (不想保留author可删除)
|
||||
* @description 导入所有 vuex 模块,自动加入namespaced:true,用于解决vuex命名冲突,请勿修改。
|
||||
* @description: Vue状态管理器
|
||||
*/
|
||||
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
|
||||
import state from './state'
|
||||
import actions from './actions'
|
||||
import mutations from './mutations'
|
||||
import getters from './getters'
|
||||
Vue.use(Vuex)
|
||||
const files = require.context('./modules', false, /\.js$/)
|
||||
const modules = {}
|
||||
|
||||
files.keys().forEach((key) => {
|
||||
modules[key.replace(/(\.\/|\.js)/g, '')] = files(key).default
|
||||
export default new Vuex.Store({
|
||||
state,
|
||||
actions,
|
||||
mutations,
|
||||
getters
|
||||
})
|
||||
Object.keys(modules).forEach((key) => {
|
||||
modules[key]['namespaced'] = true
|
||||
})
|
||||
const store = new Vuex.Store({
|
||||
modules,
|
||||
})
|
||||
export default store
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
/**
|
||||
* @author chuzhixin 1204505056@qq.com (不想保留author可删除)
|
||||
* @description 异常捕获的状态拦截,请勿修改
|
||||
*/
|
||||
|
||||
const state = () => ({
|
||||
errorLogs: [],
|
||||
})
|
||||
const getters = {
|
||||
errorLogs: (state) => state.errorLogs,
|
||||
}
|
||||
const mutations = {
|
||||
addErrorLog(state, errorLog) {
|
||||
state.errorLogs.push(errorLog)
|
||||
},
|
||||
clearErrorLog: (state) => {
|
||||
state.errorLogs.splice(0)
|
||||
},
|
||||
}
|
||||
const actions = {
|
||||
addErrorLog({ commit }, errorLog) {
|
||||
commit('addErrorLog', errorLog)
|
||||
},
|
||||
clearErrorLog({ commit }) {
|
||||
commit('clearErrorLog')
|
||||
},
|
||||
}
|
||||
export default { state, getters, mutations, actions }
|
||||
@@ -1,52 +0,0 @@
|
||||
/**
|
||||
* @author chuzhixin 1204505056@qq.com (不想保留author可删除)
|
||||
* @description 路由拦截状态管理,目前两种模式:all模式与intelligence模式,其中partialRoutes是菜单暂未使用
|
||||
*/
|
||||
import { asyncRoutes, constantRoutes } from '@/router'
|
||||
import { getRouterList } from '@/api/router'
|
||||
import { convertRouter, filterAsyncRoutes } from '@/utils/handleRoutes'
|
||||
import { routes } from '@/config'
|
||||
|
||||
const state = () => ({
|
||||
routes: [],
|
||||
partialRoutes: [],
|
||||
})
|
||||
const getters = {
|
||||
routes: (state) => state.routes,
|
||||
partialRoutes: (state) => state.partialRoutes,
|
||||
}
|
||||
const mutations = {
|
||||
setRoutes(state, routes) {
|
||||
state.routes = constantRoutes.concat(routes)
|
||||
},
|
||||
setAllRoutes(state, routes) {
|
||||
state.routes = constantRoutes.concat(routes)
|
||||
},
|
||||
setPartialRoutes(state, routes) {
|
||||
state.partialRoutes = constantRoutes.concat(routes)
|
||||
},
|
||||
}
|
||||
const actions = {
|
||||
async setRoutes({ commit }, permissions) {
|
||||
//开源版只过滤动态路由permissions,admin不再默认拥有全部权限
|
||||
const finallyAsyncRoutes = await filterAsyncRoutes(
|
||||
[...asyncRoutes],
|
||||
permissions
|
||||
)
|
||||
commit('setRoutes', finallyAsyncRoutes)
|
||||
return finallyAsyncRoutes
|
||||
},
|
||||
async setAllRoutes({ commit }) {
|
||||
// let { data } = await getRouterList()
|
||||
let data = routes
|
||||
data.push({ path: '*', redirect: '/404', hidden: true })
|
||||
let accessRoutes = convertRouter(data)
|
||||
commit('setAllRoutes', accessRoutes)
|
||||
return accessRoutes
|
||||
},
|
||||
setPartialRoutes({ commit }, accessRoutes) {
|
||||
commit('setPartialRoutes', accessRoutes)
|
||||
return accessRoutes
|
||||
},
|
||||
}
|
||||
export default { state, getters, mutations, actions }
|
||||
@@ -1,75 +0,0 @@
|
||||
/**
|
||||
* @author chuzhixin 1204505056@qq.com (不想保留author可删除)
|
||||
* @description 所有全局配置的状态管理,如无必要请勿修改
|
||||
*/
|
||||
|
||||
import defaultSettings from '@/config'
|
||||
|
||||
const { tabsBar, logo, layout, header, themeBar } = defaultSettings
|
||||
const theme =
|
||||
JSON.parse(localStorage.getItem('vue-admin-beautiful-theme')) || ''
|
||||
const state = () => ({
|
||||
tabsBar: theme.tabsBar || tabsBar,
|
||||
logo,
|
||||
collapse: false,
|
||||
layout: theme.layout || layout,
|
||||
header: theme.header || header,
|
||||
device: 'desktop',
|
||||
themeBar,
|
||||
})
|
||||
const getters = {
|
||||
collapse: (state) => state.collapse,
|
||||
device: (state) => state.device,
|
||||
header: (state) => state.header,
|
||||
layout: (state) => state.layout,
|
||||
logo: (state) => state.logo,
|
||||
tabsBar: (state) => state.tabsBar,
|
||||
themeBar: (state) => state.themeBar,
|
||||
}
|
||||
const mutations = {
|
||||
changeLayout: (state, layout) => {
|
||||
if (layout) state.layout = layout
|
||||
},
|
||||
changeHeader: (state, header) => {
|
||||
if (header) state.header = header
|
||||
},
|
||||
changeTabsBar: (state, tabsBar) => {
|
||||
if (tabsBar) state.tabsBar = tabsBar
|
||||
},
|
||||
changeCollapse: (state) => {
|
||||
state.collapse = !state.collapse
|
||||
},
|
||||
foldSideBar: (state) => {
|
||||
state.collapse = true
|
||||
},
|
||||
openSideBar: (state) => {
|
||||
state.collapse = false
|
||||
},
|
||||
toggleDevice: (state, device) => {
|
||||
state.device = device
|
||||
},
|
||||
}
|
||||
const actions = {
|
||||
changeLayout({ commit }, layout) {
|
||||
commit('changeLayout', layout)
|
||||
},
|
||||
changeHeader({ commit }, header) {
|
||||
commit('changeHeader', header)
|
||||
},
|
||||
changeTabsBar({ commit }, tabsBar) {
|
||||
commit('changeTabsBar', tabsBar)
|
||||
},
|
||||
changeCollapse({ commit }) {
|
||||
commit('changeCollapse')
|
||||
},
|
||||
foldSideBar({ commit }) {
|
||||
commit('foldSideBar')
|
||||
},
|
||||
openSideBar({ commit }) {
|
||||
commit('openSideBar')
|
||||
},
|
||||
toggleDevice({ commit }, device) {
|
||||
commit('toggleDevice', device)
|
||||
},
|
||||
}
|
||||
export default { state, getters, mutations, actions }
|
||||
@@ -1,23 +0,0 @@
|
||||
/**
|
||||
* @author chuzhixin 1204505056@qq.com (不想保留author可删除)
|
||||
* @description 代码生成机状态管理
|
||||
*/
|
||||
|
||||
const state = () => ({
|
||||
srcCode: '',
|
||||
})
|
||||
const getters = {
|
||||
srcTableCode: (state) => state.srcCode,
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
setTableCode(state, srcCode) {
|
||||
state.srcCode = srcCode
|
||||
},
|
||||
}
|
||||
const actions = {
|
||||
setTableCode({ commit }, srcCode) {
|
||||
commit('setTableCode', srcCode)
|
||||
},
|
||||
}
|
||||
export default { state, getters, mutations, actions }
|
||||
@@ -1,112 +0,0 @@
|
||||
/**
|
||||
* @author chuzhixin 1204505056@qq.com (不想保留author可删除)
|
||||
* @description tabsBar多标签页逻辑,前期借鉴了很多开源项目发现都有个共同的特点很繁琐并不符合框架设计的初衷,后来在github用户hipi的启发下完成了重构,请勿修改
|
||||
*/
|
||||
|
||||
const state = () => ({
|
||||
visitedRoutes: [],
|
||||
})
|
||||
const getters = {
|
||||
visitedRoutes: (state) => state.visitedRoutes,
|
||||
}
|
||||
const mutations = {
|
||||
addVisitedRoute(state, route) {
|
||||
let target = state.visitedRoutes.find((item) => item.path === route.path)
|
||||
if (target) {
|
||||
if (route.fullPath !== target.fullPath) Object.assign(target, route)
|
||||
return
|
||||
}
|
||||
state.visitedRoutes.push(Object.assign({}, route))
|
||||
},
|
||||
delVisitedRoute(state, route) {
|
||||
state.visitedRoutes.forEach((item, index) => {
|
||||
if (item.path === route.path) state.visitedRoutes.splice(index, 1)
|
||||
})
|
||||
},
|
||||
delOthersVisitedRoute(state, route) {
|
||||
state.visitedRoutes = state.visitedRoutes.filter(
|
||||
(item) => item.meta.affix || item.path === route.path
|
||||
)
|
||||
},
|
||||
delLeftVisitedRoute(state, route) {
|
||||
let index = state.visitedRoutes.length
|
||||
state.visitedRoutes = state.visitedRoutes.filter((item) => {
|
||||
if (item.name === route.name) index = state.visitedRoutes.indexOf(item)
|
||||
return item.meta.affix || index <= state.visitedRoutes.indexOf(item)
|
||||
})
|
||||
},
|
||||
delRightVisitedRoute(state, route) {
|
||||
let index = state.visitedRoutes.length
|
||||
state.visitedRoutes = state.visitedRoutes.filter((item) => {
|
||||
if (item.name === route.name) index = state.visitedRoutes.indexOf(item)
|
||||
return item.meta.affix || index >= state.visitedRoutes.indexOf(item)
|
||||
})
|
||||
},
|
||||
delAllVisitedRoutes(state) {
|
||||
state.visitedRoutes = state.visitedRoutes.filter((item) => item.meta.affix)
|
||||
},
|
||||
updateVisitedRoute(state, route) {
|
||||
state.visitedRoutes.forEach((item) => {
|
||||
if (item.path === route.path) item = Object.assign(item, route)
|
||||
})
|
||||
},
|
||||
}
|
||||
const actions = {
|
||||
addVisitedRoute({ commit }, route) {
|
||||
commit('addVisitedRoute', route)
|
||||
},
|
||||
async delRoute({ dispatch, state }, route) {
|
||||
await dispatch('delVisitedRoute', route)
|
||||
return {
|
||||
visitedRoutes: [...state.visitedRoutes],
|
||||
}
|
||||
},
|
||||
delVisitedRoute({ commit, state }, route) {
|
||||
commit('delVisitedRoute', route)
|
||||
return [...state.visitedRoutes]
|
||||
},
|
||||
async delOthersRoutes({ dispatch, state }, route) {
|
||||
await dispatch('delOthersVisitedRoute', route)
|
||||
return {
|
||||
visitedRoutes: [...state.visitedRoutes],
|
||||
}
|
||||
},
|
||||
async delLeftRoutes({ dispatch, state }, route) {
|
||||
await dispatch('delLeftVisitedRoute', route)
|
||||
return {
|
||||
visitedRoutes: [...state.visitedRoutes],
|
||||
}
|
||||
},
|
||||
async delRightRoutes({ dispatch, state }, route) {
|
||||
await dispatch('delRightVisitedRoute', route)
|
||||
return {
|
||||
visitedRoutes: [...state.visitedRoutes],
|
||||
}
|
||||
},
|
||||
delOthersVisitedRoute({ commit, state }, route) {
|
||||
commit('delOthersVisitedRoute', route)
|
||||
return [...state.visitedRoutes]
|
||||
},
|
||||
delLeftVisitedRoute({ commit, state }, route) {
|
||||
commit('delLeftVisitedRoute', route)
|
||||
return [...state.visitedRoutes]
|
||||
},
|
||||
delRightVisitedRoute({ commit, state }, route) {
|
||||
commit('delRightVisitedRoute', route)
|
||||
return [...state.visitedRoutes]
|
||||
},
|
||||
async delAllRoutes({ dispatch, state }, route) {
|
||||
await dispatch('delAllVisitedRoutes', route)
|
||||
return {
|
||||
visitedRoutes: [...state.visitedRoutes],
|
||||
}
|
||||
},
|
||||
delAllVisitedRoutes({ commit, state }) {
|
||||
commit('delAllVisitedRoutes')
|
||||
return [...state.visitedRoutes]
|
||||
},
|
||||
updateVisitedRoute({ commit }, route) {
|
||||
commit('updateVisitedRoute', route)
|
||||
},
|
||||
}
|
||||
export default { state, getters, mutations, actions }
|
||||
@@ -1,108 +0,0 @@
|
||||
/**
|
||||
* @author chuzhixin 1204505056@qq.com (不想保留author可删除)
|
||||
* @description 登录、获取用户信息、退出登录、清除accessToken逻辑,不建议修改
|
||||
*/
|
||||
|
||||
import Vue from 'vue'
|
||||
import { getUserInfo, login, logout } from '@/api/user'
|
||||
import {
|
||||
getAccessToken,
|
||||
removeAccessToken,
|
||||
setAccessToken,
|
||||
} from '@/utils/accessToken'
|
||||
import { resetRouter } from '@/router'
|
||||
import { title, tokenName, routes } from '@/config'
|
||||
|
||||
const state = () => ({
|
||||
accessToken: getAccessToken(),
|
||||
username: '',
|
||||
avatar: '',
|
||||
permissions: [],
|
||||
})
|
||||
const getters = {
|
||||
accessToken: (state) => state.accessToken,
|
||||
username: (state) => state.username,
|
||||
avatar: (state) => state.avatar,
|
||||
permissions: (state) => state.permissions,
|
||||
}
|
||||
const mutations = {
|
||||
setAccessToken(state, accessToken) {
|
||||
state.accessToken = accessToken
|
||||
setAccessToken(accessToken)
|
||||
},
|
||||
setUsername(state, username) {
|
||||
state.username = username
|
||||
},
|
||||
setAvatar(state, avatar) {
|
||||
state.avatar = avatar
|
||||
},
|
||||
setPermissions(state, permissions) {
|
||||
state.permissions = permissions
|
||||
},
|
||||
}
|
||||
const actions = {
|
||||
setPermissions({ commit }, permissions) {
|
||||
commit('setPermissions', permissions)
|
||||
},
|
||||
async login({ commit }, userInfo) {
|
||||
// const { data } = await login(userInfo)
|
||||
// const accessToken = data[tokenName]
|
||||
const accessToken = 'test_20210420'
|
||||
if (accessToken) {
|
||||
commit('setAccessToken', accessToken)
|
||||
const hour = new Date().getHours()
|
||||
const thisTime =
|
||||
hour < 8
|
||||
? '早上好'
|
||||
: hour <= 11
|
||||
? '上午好'
|
||||
: hour <= 13
|
||||
? '中午好'
|
||||
: hour < 18
|
||||
? '下午好'
|
||||
: '晚上好'
|
||||
Vue.prototype.$baseNotify(`欢迎登录${title}`, `${thisTime}!`)
|
||||
} else {
|
||||
Vue.prototype.$baseMessage(
|
||||
`登录接口异常,未正确返回${tokenName}...`,
|
||||
'error'
|
||||
)
|
||||
}
|
||||
},
|
||||
async getUserInfo({ commit, state }) {
|
||||
// const { data } = await getUserInfo(state.accessToken)
|
||||
const data = {
|
||||
permissions: ['admin'],
|
||||
username: 'admin',
|
||||
'avatar|1': [
|
||||
'https://i.gtimg.cn/club/item/face/img/2/15922_100.gif',
|
||||
'https://i.gtimg.cn/club/item/face/img/8/15918_100.gif',
|
||||
],
|
||||
}
|
||||
if (!data) {
|
||||
Vue.prototype.$baseMessage('验证失败,请重新登录...', 'error')
|
||||
return false
|
||||
}
|
||||
let { permissions, username, avatar } = data
|
||||
if (permissions && username && Array.isArray(permissions)) {
|
||||
commit('setPermissions', permissions)
|
||||
commit('setUsername', username)
|
||||
commit('setAvatar', avatar)
|
||||
return permissions
|
||||
} else {
|
||||
Vue.prototype.$baseMessage('用户信息接口异常', 'error')
|
||||
return false
|
||||
}
|
||||
},
|
||||
async logout({ dispatch }) {
|
||||
await logout(state.accessToken)
|
||||
await dispatch('resetAccessToken')
|
||||
await resetRouter()
|
||||
},
|
||||
resetAccessToken({ commit }) {
|
||||
commit('setPermissions', [])
|
||||
commit('setAccessToken', '')
|
||||
removeAccessToken()
|
||||
},
|
||||
}
|
||||
export default { state, getters, mutations, actions }
|
||||
@@ -0,0 +1,276 @@
|
||||
/**
|
||||
* @description: mutations
|
||||
*/
|
||||
export default {
|
||||
// state退出重置
|
||||
logout (state) {
|
||||
for (let key in state) {
|
||||
if (key !== 'laws_urm' && key !== 'laws_prm') {
|
||||
state[key] = ''
|
||||
sessionStorage.clear()
|
||||
localStorage.removeItem('userInfo')
|
||||
localStorage.removeItem('token')
|
||||
localStorage.removeItem('userInfoModifyTime')
|
||||
localStorage.removeItem('menuList')
|
||||
localStorage.removeItem('JSESSIONID')
|
||||
}
|
||||
}
|
||||
},
|
||||
// 主题
|
||||
setTheme (state, theme) {
|
||||
state.theme = theme
|
||||
try {
|
||||
localStorage.theme = theme
|
||||
} catch (e) {}
|
||||
},
|
||||
// 设置token
|
||||
setToken (state, token) {
|
||||
state.token = token
|
||||
try {
|
||||
localStorage.setItem('token', token)
|
||||
} catch (e) {}
|
||||
},
|
||||
// 选择语言
|
||||
setLanguage (state, language) {
|
||||
state.language = language
|
||||
try {
|
||||
sessionStorage.language = language
|
||||
} catch (e) {}
|
||||
},
|
||||
// 流程办理
|
||||
setHandleInfo (state, handleInfo) {
|
||||
if (handleInfo) {
|
||||
state.handleInfo = handleInfo
|
||||
try {
|
||||
sessionStorage.handleInfo = handleInfo
|
||||
} catch (e) {}
|
||||
} else {
|
||||
state.handleInfo = ''
|
||||
try {
|
||||
sessionStorage.removeItem('handleInfo')
|
||||
} catch (e) {}
|
||||
}
|
||||
},
|
||||
// 设置当前操作的流程
|
||||
setProcess (state, process) {
|
||||
state.process = process
|
||||
try {
|
||||
sessionStorage.process = process
|
||||
} catch (e) {}
|
||||
},
|
||||
// 设置用户信息
|
||||
setUserInfo (state, userInfo) {
|
||||
const timeStamp = new Date().getTime().toString()
|
||||
const _USERINFO = JSON.parse(userInfo)
|
||||
_USERINFO.userId = _USERINFO.userId || _USERINFO.usId
|
||||
_USERINFO.userName = _USERINFO.userName || _USERINFO.uName
|
||||
state.userInfo = JSON.stringify(_USERINFO)
|
||||
state.userInfoModifyTime = timeStamp
|
||||
try {
|
||||
localStorage.setItem('userInfo', JSON.stringify(_USERINFO))
|
||||
localStorage.setItem('userInfoModifyTime', timeStamp)
|
||||
} catch (e) {}
|
||||
},
|
||||
// 登录超时
|
||||
isTimeOut (state) {
|
||||
state.isTimeOut = true
|
||||
},
|
||||
// 超时重置
|
||||
resetTime (state) {
|
||||
state.isTimeOut = false
|
||||
},
|
||||
// 记住密码
|
||||
rememberPwd (state, user) {
|
||||
state.laws_urm = user.username
|
||||
state.laws_prm = user.password
|
||||
try {
|
||||
localStorage.laws_urm = user.username
|
||||
localStorage.laws_prm = user.password
|
||||
} catch (e) {}
|
||||
},
|
||||
// 详情跳转记录
|
||||
setDetailMap (state, path) {
|
||||
state.detailMap = path
|
||||
try {
|
||||
sessionStorage.detailMap = path
|
||||
} catch (e) {}
|
||||
},
|
||||
// 详情跳转记录上一次
|
||||
setLastDetailMap (state, path) {
|
||||
state.lastDetailMap = path
|
||||
try {
|
||||
sessionStorage.lastDetailMap = path
|
||||
} catch (e) {}
|
||||
},
|
||||
// 保存动态搜索记录
|
||||
setDynamicSearchHistory (state, search) {
|
||||
state.dynamicSearch = search
|
||||
try {
|
||||
sessionStorage.dynamicSearch = search
|
||||
} catch (e) {}
|
||||
},
|
||||
// 保存未读动态
|
||||
setDynamicTotal (state, total) {
|
||||
state.dynamicTotal = JSON.stringify(total)
|
||||
try {
|
||||
sessionStorage.dynamicTotal = JSON.stringify(total)
|
||||
} catch (e) {}
|
||||
},
|
||||
// 流程表单暂存
|
||||
setProcessForm (state, processForm) {
|
||||
state.processForm = processForm
|
||||
try {
|
||||
sessionStorage.processForm = processForm
|
||||
} catch (e) {}
|
||||
},
|
||||
// 流程相关标准暂存
|
||||
setProcessStandard (state, processStandard) {
|
||||
state.processStandard = processStandard
|
||||
try {
|
||||
sessionStorage.processStandard = processStandard
|
||||
} catch (e) {}
|
||||
},
|
||||
// 流程步骤暂存
|
||||
setProcessState (state, processState) {
|
||||
state.processState = processState
|
||||
try {
|
||||
sessionStorage.processState = processState
|
||||
} catch (e) {}
|
||||
},
|
||||
// 保存菜单
|
||||
setMenu (state, menuList) {
|
||||
state.menuList = menuList
|
||||
try {
|
||||
localStorage.setItem('menuList', menuList)
|
||||
} catch (e) {}
|
||||
},
|
||||
// 高级检索暂存
|
||||
setSearchInfoEO (state, searchInfoEO) {
|
||||
state.searchInfoEO = searchInfoEO
|
||||
try {
|
||||
sessionStorage.searchInfoEO = searchInfoEO
|
||||
} catch (e) {}
|
||||
},
|
||||
// 我的动态暂存
|
||||
setDynamicsPage (state, dynamicsPage) {
|
||||
state.dynamicsPage = dynamicsPage
|
||||
try {
|
||||
sessionStorage.dynamicsPage = dynamicsPage
|
||||
} catch (e) {}
|
||||
},
|
||||
// 办理webSocket任务
|
||||
setWebSocketTask (state, taskId) {
|
||||
if (state.webSocketMessageList === '') {
|
||||
state.webSocketMessageList = []
|
||||
state.webSocketMessageList.push(taskId)
|
||||
} else {
|
||||
if (state.webSocketMessageList.indexOf(taskId) === -1) {
|
||||
state.webSocketMessageList.push(taskId)
|
||||
} else {
|
||||
state.webSocketMessageList.splice(state.webSocketMessageList.indexOf(taskId), 1)
|
||||
}
|
||||
}
|
||||
},
|
||||
// 存储JSESSIONID
|
||||
setJESSCookie (state, JSESSIONID) {
|
||||
state.JSESSIONID = JSESSIONID
|
||||
try {
|
||||
localStorage.setItem('JSESSIONID', JSESSIONID)
|
||||
} catch (e) {}
|
||||
},
|
||||
// 本地产品库查看存储数据
|
||||
setLocalProData (state, localData) {
|
||||
state.localPro = localData
|
||||
try {
|
||||
sessionStorage.localPro = localData
|
||||
} catch (e) {}
|
||||
},
|
||||
// 查询当前角色权限模块
|
||||
setRoleModule (state, roleModule) {
|
||||
state.roleModuleList = JSON.stringify(roleModule)
|
||||
try {
|
||||
sessionStorage.roleModuleList = JSON.stringify(roleModule)
|
||||
} catch (e) {}
|
||||
},
|
||||
setTypeFlag (state, path) {
|
||||
state.typeFlag = path
|
||||
try {
|
||||
sessionStorage.typeFlag = path
|
||||
} catch (e) {}
|
||||
},
|
||||
setStandItem (state, list) {
|
||||
state.standItemList = list
|
||||
try {
|
||||
sessionStorage.standItemList = list
|
||||
} catch (e) {}
|
||||
},
|
||||
setDetails (state, list) {
|
||||
state.processLastDetails = list
|
||||
try {
|
||||
sessionStorage.processLastDetails = list
|
||||
} catch (e) {}
|
||||
},
|
||||
toggleSideBar (state, collapse) {
|
||||
state.isCollapse = collapse
|
||||
try {
|
||||
sessionStorage.collapse = collapse
|
||||
} catch (e) {}
|
||||
},
|
||||
setMyBussStandardPlan (state, myBussStandardPlan) {
|
||||
if (myBussStandardPlan) {
|
||||
state.myBussStandardPlan = JSON.stringify(myBussStandardPlan)
|
||||
try {
|
||||
sessionStorage.myBussStandardPlan = JSON.stringify(myBussStandardPlan)
|
||||
} catch (e) {}
|
||||
} else {
|
||||
state.myBussStandardPlan = ''
|
||||
try {
|
||||
sessionStorage.removeItem('myBussStandardPlan')
|
||||
} catch (e) {}
|
||||
}
|
||||
},
|
||||
setPrcLastDetail (state, lastDetail) {
|
||||
if (lastDetail) {
|
||||
state.proLastDetail = lastDetail
|
||||
try {
|
||||
sessionStorage.proLastDetail = lastDetail
|
||||
} catch (e) {}
|
||||
} else {
|
||||
state.proLastDetail = ''
|
||||
try {
|
||||
sessionStorage.removeItem('proLastDetail')
|
||||
} catch (e) {}
|
||||
}
|
||||
},
|
||||
|
||||
// 完成任务
|
||||
finishTask(state, taskId) {
|
||||
const taskInfo = JSON.parse(state.handleInfo)
|
||||
const taskIds = taskInfo.taskIds.split(',')
|
||||
const taskIdList = taskIds
|
||||
taskIds.map((tId, index) => {
|
||||
if (taskId === tId || tId === '') {
|
||||
taskIdList.splice(index, 1)
|
||||
}
|
||||
})
|
||||
taskInfo.taskIds = taskIdList.join(',')
|
||||
state.handleInfo = JSON.stringify(taskInfo)
|
||||
try {
|
||||
sessionStorage.handleInfo = JSON.stringify(taskInfo)
|
||||
} catch (e) {}
|
||||
},
|
||||
// 入库基础信息
|
||||
SET_RUKU_BASEINFO(state, baseInfo) {
|
||||
if (baseInfo) {
|
||||
state.rukuBaseInfo = JSON.stringify(baseInfo)
|
||||
try {
|
||||
sessionStorage.rukuBaseInfo = JSON.stringify(baseInfo)
|
||||
} catch (e) {}
|
||||
} else {
|
||||
state.rukuBaseInfo = ''
|
||||
try {
|
||||
sessionStorage.removeItem('rukuBaseInfo')
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* @description: 全局状态
|
||||
*/
|
||||
let defaultTheme = ''
|
||||
let defaultToken = ''
|
||||
let process = ''
|
||||
let userInfo = ''
|
||||
let userInfoModifyTime = ''
|
||||
let lawsUrm = ''
|
||||
let lawsPrm = ''
|
||||
let detailMap = ''
|
||||
let dynamicSearch = ''
|
||||
let dynamicTotal = ''
|
||||
let processForm = ''
|
||||
let processStandard = ''
|
||||
let processState = ''
|
||||
let menuList = ''
|
||||
let lastDetailMap = ''
|
||||
let searchInfoEO = ''
|
||||
let dynamicsPage = ''
|
||||
let webSocketMessageList = ''
|
||||
let JSESSIONID = ''
|
||||
let localPro = ''
|
||||
let roleModuleList = ''
|
||||
let typeFlag = ''
|
||||
let standItemList = ''
|
||||
let processLastDetails = ''
|
||||
let language = '' // 国际化
|
||||
let isCollapse = ''
|
||||
let handleInfo = '' // 流程办理传递数据
|
||||
let myBussStandardPlan = ''
|
||||
let proLastDetail = '' // 流程结果详情
|
||||
let rukuBaseInfo = '' // 入库流程基础表单信息(后几步展示用)
|
||||
try {
|
||||
if (localStorage.theme) { defaultTheme = localStorage.theme }
|
||||
if (localStorage.token) { defaultToken = localStorage.token }
|
||||
if (sessionStorage.process) { process = sessionStorage.process }
|
||||
if (localStorage.userInfo) { userInfo = localStorage.userInfo }
|
||||
if (localStorage.userInfoModifyTime) { userInfoModifyTime = localStorage.userInfoModifyTime || '0' }
|
||||
if (localStorage.laws_urm) { lawsUrm = localStorage.laws_urm }
|
||||
if (localStorage.laws_prm) { lawsPrm = localStorage.laws_prm }
|
||||
if (sessionStorage.detailMap) { detailMap = sessionStorage.detailMap }
|
||||
if (sessionStorage.dynamicSearch) { dynamicSearch = sessionStorage.dynamicSearch }
|
||||
if (sessionStorage.dynamicTotal) { dynamicTotal = sessionStorage.dynamicTotal }
|
||||
if (sessionStorage.processForm) { processForm = sessionStorage.processForm }
|
||||
if (sessionStorage.processStandard) { processStandard = sessionStorage.processStandard }
|
||||
if (sessionStorage.processState) { processState = sessionStorage.processState }
|
||||
if (localStorage.menuList) { menuList = localStorage.menuList }
|
||||
if (sessionStorage.lastDetailMap) { lastDetailMap = sessionStorage.lastDetailMap }
|
||||
if (sessionStorage.searchInfoEO) { searchInfoEO = sessionStorage.searchInfoEO }
|
||||
if (sessionStorage.dynamicsPage) { searchInfoEO = sessionStorage.dynamicsPage }
|
||||
if (localStorage.JSESSIONID) { JSESSIONID = localStorage.JSESSIONID }
|
||||
if (sessionStorage.localPro) { localPro = sessionStorage.localPro }
|
||||
if (sessionStorage.roleModuleList) { roleModuleList = sessionStorage.roleModuleList }
|
||||
if (sessionStorage.typeFlag) { typeFlag = sessionStorage.typeFlag }
|
||||
if (sessionStorage.standItemList) { standItemList = sessionStorage.standItemList }
|
||||
if (sessionStorage.processLastDetails) { processLastDetails = sessionStorage.processLastDetails }
|
||||
if (sessionStorage.language) { language = sessionStorage.language }
|
||||
if (sessionStorage.isCollapse) { isCollapse = sessionStorage.isCollapse }
|
||||
if (sessionStorage.handleInfo) { handleInfo = sessionStorage.handleInfo }
|
||||
if (sessionStorage.myBussStandardPlan) { myBussStandardPlan = sessionStorage.myBussStandardPlan }
|
||||
if (sessionStorage.proLastDetail) { proLastDetail = sessionStorage.proLastDetail }
|
||||
if (sessionStorage.rukuBaseInfo) { rukuBaseInfo = sessionStorage.rukuBaseInfo }
|
||||
} catch (e) {}
|
||||
export default {
|
||||
theme: defaultTheme, // 主题
|
||||
token: defaultToken, // 登录标识
|
||||
process: process, // 待办流程
|
||||
userInfo: userInfo, // 用户信息
|
||||
userInfoModifyTime: userInfoModifyTime, // 用户信息更改时间
|
||||
isTimeOut: false, // 登录超时
|
||||
laws_urm: lawsUrm, // 用户名
|
||||
laws_prm: lawsPrm, // 密码
|
||||
detailMap: detailMap, // 查看详情路由记录
|
||||
dynamicSearch: dynamicSearch, // 动态搜索记录
|
||||
dynamicTotal: dynamicTotal, // 未读动态
|
||||
processForm: processForm, // 流程表单
|
||||
processStandard: processStandard, // 流程相关标准
|
||||
processState: processState, // 流程步骤
|
||||
menuList: menuList, // 菜单
|
||||
lastDetailMap: lastDetailMap, // 上一次的路由记录
|
||||
searchInfoEO: searchInfoEO, // 高级检索
|
||||
dynamicsPage: dynamicsPage, // 我的动态页码存储
|
||||
webSocketMessageList: webSocketMessageList, // webSocket任务列表
|
||||
JSESSIONID: JSESSIONID, // JSESSIONID(后台权限验证)
|
||||
localPro: localPro, // 本地产品库查看时存储数据
|
||||
roleModuleList: roleModuleList, // 本地产品库查看时存储数据
|
||||
typeFlag: typeFlag,
|
||||
standItemList: standItemList, // 标准团队模块暂存
|
||||
processLastDetails: processLastDetails, // 流程查流程数据暂存
|
||||
language: language, // 语言
|
||||
isCollapse, // 侧边栏收缩状态
|
||||
handleInfo: handleInfo, // 流程办理传递数据
|
||||
myBussStandardPlan,
|
||||
proLastDetail,
|
||||
rukuBaseInfo,
|
||||
}
|
||||
Reference in New Issue
Block a user