import Vue  from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

export default new Vuex.Store({
                                  state:     {
                                      stcount:        0,
                                      tenantCode:     '',
                                      auth:           '',
                                      guide:          '',
                                      replaceContent: '',
                                      replaceIcon:    '',//个人头像
                                      showScore:      true,
                                      showModel:      false,
                                      ksStatus:       null,
                                      lxId:           '',
                                      treeStatus:     {
                                          // 结构试类
                                          key:          '',
                                          expandedKeys: [],
                                      },
                                      kaoshiReplyPg:  null,
                                      lxReplyPg:      null,
                                      pageCache:      null,
                                      pic:            {
                                          scoreImg:    `${process.env.BASE_URL}img/client/c-score.png`,
                                          lianxiImg: require(`@/assets/images/default/defaultLianxi.jpg`),
                                          zhengshuImg: `${process.env.BASE_URL}img/client/c-certificate.png`,
                                          kechengImg:  require(`@/assets/images/default/defaultKecheng.jpg`),
                                          headerImg:   '',
                                      },
                                      ThemeColorObj:  null,
                                      formula:        {},
                                      kechengDagang: {
                                          scrollTop:      null,
                                          needScroll:     null
                                      },

                                  },
                                  getters:   {
                                      getNeedScroll(state) {
                                          return state.kechengDagang.needScroll;
                                      },
                                      getScrollTop(state) {
                                          return state.kechengDagang.scrollTop;
                                      },
                                      getFormula(state) {
                                          return state.formula;
                                      },
                                      getThemeColor(state) {
                                          return (level = 0) => state.ThemeColorObj[`${level}`];
                                      },
                                      getShowScore(state) {
                                          return state.showScore;
                                      },
                                      getShowModel(state) {
                                          return state.showModel;
                                      },
                                      getAuth(state) {
                                          return state.auth;
                                      },
                                      getGuide(state) {
                                          return state.guide;
                                      },
                                      getTenantCode(state) {
                                          return state.tenantCode;
                                      },
                                      getKsId(state) {
                                          return state.ksId;
                                      },
                                      getLxId(state) {
                                          return state.lxId;
                                      },
                                      getNoticeId(state) {
                                          return state.noticeId;
                                      },
                                      getHisId(state) {
                                          return state.hisId;
                                      },
                                      getCreateTime(state) {
                                          return state.createTime;
                                      },
                                      getKaoshiReplyPg(state) {
                                          return state.kaoshiReplyPg;
                                      },
                                      getlxReplyPg(state) {
                                          return state.lxReplyPg;
                                      },
                                      getReplaceContext(state) {
                                          return state.replaceContent;
                                      },
                                      //个人头像
                                      getReplaceIcon(state) {
                                          return state.replaceIcon;
                                      },
                                      getTreeStatus(state) {
                                          return state.treeStatus;
                                      },
                                      getPageData(state, payload) {
                                          return state.pageCache;
                                      },
                                      getScoreImg(state) {
                                          return state.pic.scoreImg;
                                      },
                                      getLianxiImg(state) {
                                          return state.pic.lianxiImg;
                                      },
                                      getZhengshuImg(state) {
                                          return state.pic.zhengshuImg;
                                      },
                                      getKechengImg(state) {
                                          return state.pic.kechengImg;
                                      },
                                      getHeaderImg(state) {
                                          return state.pic.headerImg;
                                      },
                                      getCache(state) {
                                          return state.pageCache;
                                      },
                                  },
                                  mutations: {
                                      setNeedScroll(state, payload) {
                                          state.kechengDagang.needScroll = payload
                                      },
                                      setScrollTop(state, payload) {
                                          state.kechengDagang.scrollTop = payload
                                      },
                                      setFormula(state, payload) {
                                          state.formula = payload.formula;
                                      },
                                      stincrement(state) {
                                          state.stcount = state.stcount + 3;
                                      },
                                      setAuth(state, payload) {
                                          state.auth = payload.auth;
                                      },
                                      setGuide(state, payload) {
                                          state.guide = payload.guide;
                                      },
                                      setTenantCode(state, payload) {
                                          state.tenantCode = payload.tenantCode;
                                      },
                                      setKsStatus(state, payload) {
                                          state.ksStatus = payload.ksStatus;
                                      },
                                      setLxId(state, payload) {
                                          state.lxId = payload.lxId;
                                      },
                                      setNoticeId(state, payload) {
                                          state.noticeId = payload.noticeId;
                                      },
                                      setCreateTime(state, payload) {
                                          state.createTime = payload.createTime;
                                      },
                                      setHisId(state, payload) {
                                          state.hisId = payload.hisId;
                                      },
                                      setKaoshiReplyPg(state, payload) {
                                          state.kaoshiReplyPg = payload.kaoshiReplyPg;
                                      },

                                      clearKaoshiReplyPg(state, payload) {
                                          state.kaoshiReplyPg = null;
                                      },
                                      setlxReplyPg(state, payload) {
                                          state.lxReplyPg = payload.lxReplyPg;
                                      },
                                      SYSTEMCONFIG(state, data) {
                                          state.replaceContent = data;
                                      },
                                      //个人头像
                                      USERICON(state, data) {
                                          state.replaceIcon = data;
                                      },
                                      CHANGESHOWSCORE(state, payload) {
                                          state.showScore = payload.data;
                                      },
                                      SETMODELSTATUS(state, payload) {
                                          state.showModel = payload.data;
                                      },
                                      SETTREESTATUS(state, payload) {
                                          state.treeStatus = payload;
                                      },
                                      // 主题颜色数组
                                      SETTHEMECOLOROBJ(state, payload) {
                                          state.ThemeColorObj = payload;
                                      },
                                      setCache(state, payload) {
                                          state.pageCache = payload.data;
                                      },
                                  },
                                  actions:   {
                                      setSystemConfig({ commit }, data) {
                                          commit('SYSTEMCONFIG', data);
                                      },
                                      //个人头像
                                      setUserIcon({ commit }, data) {
                                          commit('USERICON', data);
                                      },
                                      // 主题颜色数组
                                      setThemeColorObj({ commit }, data) {
                                          commit('SETTHEMECOLOROBJ', data);
                                      },
                                  },
                              });

