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: 'dark', // 侧边栏, 折叠状态 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) } }) } } })