// store变量
let state = {
  subjectList:JSON.parse(localStorage.getItem('student_subjectList') || '[]'),//顶部筛选的科目列表
  subjectCode:'',//顶部筛选的科目
  subjectName:'',//顶部筛选的科目名称
  gradesList:JSON.parse(localStorage.getItem('student_gradesList') || '[]'),//顶部筛选的年级列表
  levelCode:localStorage.getItem('student_level_code'),  //当前学段  
};
// 同步
let mutations = {
  //设置筛选数据  
  SetFilterSubjectCode(state, item) {
    state.subjectCode = item.subjectCode;
    state.subjectName=item.subjectName;
  },

  // 设置科目列表，同时写入localStorage
  SetSubjectList(state, list) {
    state.subjectList = list
    // 存入本地存储
    localStorage.setItem('student_subjectList', JSON.stringify(list))
  },
  // 设置年级列表，同时写入localStorage
  SetGradesList(state, list) {
    state.gradesList = list
    // 存入本地存储
    localStorage.setItem('student_gradesList', JSON.stringify(list))
  },
  // 设置当前学段，同时本地存储
  SetLevelCode(state,code){
    state.levelCode = code
    localStorage.setItem('student_level_code', code)
  }
};
// 异步
let actions = {

};

export default {
  namespaced: true,
  state,
  mutations,
  actions,
};
