import obj from '#/utils/obj'

export const stage_xiaoxue = 1
export const stage_chuzhong = 2
export const stage_gaozhong = 3
export const stage_map: any = {
  [stage_xiaoxue]: '小学',
  [stage_chuzhong]: '初中',
  [stage_gaozhong]: '高中',
}
export const stages = obj.map2options(stage_map)

// 年级
const grade_1 = 1
const grade_2 = 2
const grade_3 = 3
const grade_4 = 4
const grade_5 = 5
const grade_6 = 6
const grade_7 = 7
const grade_8 = 8
const grade_9 = 9
const grade_high_1 = 10
const grade_high_2 = 11
const grade_high_3 = 12
const xiaoxue_grades = [grade_1, grade_2, grade_3, grade_4, grade_5, grade_6]
const chuzhong_grades = [grade_7, grade_8, grade_9]
const gaozhong_grades = [grade_high_1, grade_high_2, grade_high_3]
export const grade_map: any = {
  [grade_1]: '一年级',
  [grade_2]: '二年级',
  [grade_3]: '三年级',
  [grade_4]: '四年级',
  [grade_5]: '五年级',
  [grade_6]: '六年级',
  [grade_7]: '七年级',
  [grade_8]: '八年级',
  [grade_9]: '九年级',
  [grade_high_1]: '高一',
  [grade_high_2]: '高二',
  [grade_high_3]: '高三',
}
export const grades = obj.map2options(grade_map)

export function getGradesByStage(stage: any) {
  stage = Number(stage)
  let grades = gaozhong_grades as any
  if (stage === stage_xiaoxue) {
    grades = xiaoxue_grades
  } else if (stage === stage_chuzhong) {
    grades = chuzhong_grades
  }
  const map = obj.filterKeys(grade_map, grades)
  return obj.map2options(map)
}

// 学科
const subject_chinese = {
  value: 1,
  label: '语文',
}
const subject_math = {
  value: 2,
  label: '数学',
}
const subject_english = {
  value: 3,
  label: '英语',
}
const subject_physics = {
  value: 4,
  label: '物理',
}
const subject_chemistry = {
  value: 5,
  label: '化学',
}
const subject_bio = {
  value: 6,
  label: '生物学',
}
const subject_politics = {
  value: 7,
  label: '政治（道法）',
}
const subject_history = {
  value: 8,
  label: '历史',
}
const subject_geo = {
  value: 9,
  label: '地理',
}
const subject_science = {
  value: 10,
  label: '科学',
}
const subject_history_society = {
  value: 11,
  label: '历史与社会',
}
const subject_info = {
  value: 12,
  label: '信息技术',
}
const subject_music = {
  value: 13,
  label: '音乐',
}
const subject_art = {
  value: 14,
  label: '美术',
}
export const subjects = [
  subject_chinese,
  subject_math,
  subject_english,
  subject_physics,
  subject_chemistry,
  subject_bio,
  subject_politics,
  subject_history,
  subject_geo,
  subject_science,
  subject_history_society,
  subject_info,
  subject_music,
  subject_art,
]
export const subject_map = obj.options2map(subjects)
const xiaoxue_subjects = [
  subject_chinese,
  subject_math,
  subject_english,
  subject_science,
  subject_politics,
]
const chuzhong_subjects = [
  subject_chinese,
  subject_math,
  subject_english,
  subject_physics,
  subject_chemistry,
  subject_bio,
  subject_politics,
  subject_history,
  subject_geo,
  subject_science,
  subject_history_society,
]
const gaozhong_subjects = [
  subject_chinese,
  subject_math,
  subject_english,
  subject_physics,
  subject_chemistry,
  subject_bio,
  subject_politics,
  subject_history,
  subject_geo,
  subject_info,
  subject_music,
  subject_art,
]
// // 获得真正的年级
// export function getRealGrade(grade: any) {
//   grade = Number(grade)
//   if (grade <= base_grade_high_3) {
//     return base_grade_map[grade]
//   }
//   return grade
// }

export function getStageByGrade(grade: any) {
  grade = Number(grade)
  if (gaozhong_grades.includes(grade)) {
    return stage_gaozhong
  }
  if (chuzhong_grades.includes(grade)) {
    return stage_chuzhong
  }
  return stage_xiaoxue
}

export function getSubjectsByStage(stage: any) {
  stage = Number(stage)
  if (stage === stage_xiaoxue) {
    return xiaoxue_subjects
  } else if (stage === stage_chuzhong) {
    return chuzhong_subjects
  } else {
    return gaozhong_subjects
  }
}
