import { defineStore } from "pinia";
import { ref, computed } from "vue";
// 分析相关 状态存储
export interface FilterObject {
  subjectCode: string;
  subjectName: string;
  subjectId: string;
  subjectGroupType: number;
  isTotal: boolean;
  subjectGroupCodes: string;
  schoolId: string;
  schoolLevel: string;
  schoolGroupId: string;
  schoolGroupName: string | null;
  schoolName: string | null;
  schoolGroupNames: string;
  registrationType: string;
  registrationName: string | null;
  registrationGroupId: string;
  statusGroupNames: string;
  scoreType: string;
  classType: string;
  classIdCode: string;
  classLevel: string | number;
  classGroupId: string;
  classGroupName: string;
  classGroupNames: string[];
}
//用户相关的状态管理
export const useAnalysisStore = defineStore("analysis", () => {
  const filterObject = ref<FilterObject>(
    JSON.parse(localStorage.getItem("filterObject") || "{}"),
  );

  // 新增：设置公共参数
  function setFilterObject(info: FilterObject) {
    filterObject.value = info;
    // 同步存储到 localStorage，确保持久化
    localStorage.setItem("filterObject", JSON.stringify(info));
  }

  return {
    filterObject,
    setFilterObject,
  };
});
