hi-ucs/back/src/store/index.js

89 lines
2.6 KiB
JavaScript

/*
* @Author: hisense.wuhongjian
* @Date: 2022-07-05 12:53:03
* @LastEditors: hisense.wuhongjian
* @LastEditTime: 2022-08-23 16:37:05
* @Description: 告诉大家这是什么
*/
import Vue from 'vue'
import Vuex from 'vuex'
import cloneDeep from 'lodash/cloneDeep'
import user from './modules/user'
import http from '@/utils/request'
Vue.use(Vuex)
export default new Vuex.Store({
namespaced: true,
state: {
// 导航条, 布局风格, default(白色) / colorful(鲜艳)
navbarLayoutType: 'colorful',
// 侧边栏, 布局皮肤, default(白色) / dark(黑色)
sidebarLayoutSkin: 'default',
// 侧边栏, 折叠状态
sidebarFold: false,
// 侧边栏, 菜单
sidebarMenuList: [],
sidebarMenuActiveName: '',
// 内容, 是否需要刷新
contentIsNeedRefresh: false,
catalogueTree: [], // 目录对应的树形结构
// 内容, 标签页(默认添加首页)
contentTabs: [
// {
// ...window.SITE_CONFIG.contentTabDefault,
// name: 'home',
// title: 'home'
// }
],
contentTabsActiveName: 'home',
departmentSelects: [
{ label: '政法委', value: '政法委' },
{ label: '公安局', value: '公安局' },
{ label: '卫健委', value: '卫健委' },
{ label: '城市管理局', value: '城市管理局' },
{ label: '生态环境局', value: '生态环境局' },
{ label: '交通运输局', value: '交通运输局' }
]
},
modules: {
user
},
mutations: {
// 重置vuex本地储存状态
resetStore (state) {
Object.keys(state).forEach((key) => {
state[key] = cloneDeep(window.SITE_CONFIG.storeState[key])
})
},
setCatalogueTree (state, tree) {
state.catalogueTree = tree
},
setDepartmentSelects (state, list) {
state.departmentSelects = list
}
},
actions: {
init ({ dispatch }) {
dispatch('getCatalogueTree')
// dispatch('getDepartmentSelects')
},
getCatalogueTree ({ commit }) {
// http.get('bscatalogue/bscatalogue/page').then(res => {
// if (res.data.code === 0) {
// console.log(22222, res.data)
// commit('setCatalogueTree', res.data.data)
// }
// })
},
getDepartmentSelects ({ commit }) {
http.get('applyRecord/bsAbilityApplyRecord/page').then(({ data: res }) => {
if (res.code === 0) {
const selects = res.data.list.map(item => ({ label: item.applyDept, value: item.applyDept, data: item.id }))
commit('setDepartmentSelects', selects)
}
})
}
}
})