/**
 * 测评管理相关类型定义
 */

// 基础实体类
export interface BaseEntity {
  id?: string | number;
  createBy?: string;
  createTime?: string;
  updateBy?: string;
  updateTime?: string;
  remark?: string;
}

// 查询参数
export interface EvaluationQuery {
  pageNum?: number;
  pageSize?: number;
  evaluationName?: string;
  grade?: string;
  position?: string;
  positionType?: string;
  switchStatus?: string | number;
  businessStatus?: string | number;
  onlineStatus?: string | number;
  thirdExamInfoId?: string | number;
  keyword?: string;
  level?: string;
  status?: string;
  priceRange?: string;
  createTime?: any;
}

// 测评能力配置项
export interface AbilityItem {
  id?: string | number;
  abilityName: string;
  thirdExamInfoId?: string | number;
  thirdExamName?: string;
  thirdExamTime?: number;
  thirdExamPassMark?: number;
  thirdExamTotalScore?: number;
  thirdExamLink?: string;
}

// 测评视图对象（与后端 ExamEvaluationVo 保持完全一致）
export interface EvaluationVO extends BaseEntity {
  id?: string | number;
  evaluationName: string;
  grade: string;
  position: string;         // 岗位名称（冗余字符串）
  positionId?: string | number; // 关联岗位ID
  positionName?: string;     // 岗位名称（查询视图中显示）
  positionCategoryId?: string;
  positionCategoryName?: string;
  positionType: string;
  detail?: string;
  tags?: string;
  price: number;
  switchStatus: string;
  businessStatus: string;
  onlineStatus: string;
  onlineStartTime?: string;
  onlineEndTime?: string;
  salesVolume?: number;
  passRate?: string;
  mainImage?: number | string;
  mainImageUrl?: string;
  galleryImages?: string;
  galleryImageUrls?: string;
  delFlag?: string;
  // 多能力配置字段（建议存储为 JSON 字符串）
  abilityConfigs?: AbilityItem[] | string;
  // 第三方试卷字段（保留用于兼容单试卷模式）
  thirdExamName?: string;
  thirdExamInfoId?: string | number;
  thirdExamLink?: string;
  thirdExamTime?: number;
  thirdExamTotalScore?: number;
  thirdExamPassMark?: number;
  thirdExamStartTime?: string;
  thirdExamEndTime?: string;
  // 兼容旧代码
  name?: string;
  examName?: string;
}

// 测评表单对象
export interface EvaluationForm {
  id?: string | number;
  evaluationName: string;
  grade: string;
  position: string;
  positionId?: string | number;
  positionType: string;
  detail?: string;
  tags?: string | string[]; // 表单内部使用数组，提交时转为字符串
  price: number;
  switchStatus?: string;
  businessStatus?: string;
  onlineStatus?: string;
  onlineTimeRange?: string[];
  onlineStartTime?: string | null;
  onlineEndTime?: string | null;
  salesVolume?: number;
  passRate?: string;
  mainImage?: number | string;
  galleryImages?: string;
  remark?: string;
  // 多能力配置
  abilityConfigs: AbilityItem[];
  // 第三方试卷字段（保留兼容）
  thirdExamName?: string;
  thirdExamInfoId?: string | number;
  thirdExamLink?: string;
  thirdExamTime?: number;
  thirdExamTotalScore?: number;
  thirdExamPassMark?: number;
  thirdExamStartTime?: string;
  thirdExamEndTime?: string;
}

// 第三方考试信息（来自考试星API）
export interface ThirdPartyExam {
  examId?: string | number;
  examInfoId?: string | number;
  examName?: string;
  name?: string;
  examDescription?: string;
  duration?: number;
  examTime?: number;
  questionCount?: number;
  category?: string;
  difficulty?: string;
  status?: number;
  createTime?: string;
  examLink?: string;
  examTotalScore?: number;
  passMark?: number;
  passPercent?: string;
  examStartTime?: string;
  examEndTime?: string;
  examClass?: string;
  examType?: string;
  examineeRealNums?: number;  // 参考人数
  [key: string]: any;
}

// 批量操作参数
export interface BatchOperationParams {
  ids: (string | number)[];
}

// 状态更新参数
export interface StatusUpdateParams {
  status: number;
}

// 测评申请记录视图对象
export interface EvaluationApplyRecordVO {
  id: string | number;
  evaluationId: string | number;
  evaluationName: string;
  studentId: string | number;
  applyStatus: string;
  finalResult: string;
  statusText: string;
  statusType: string;
  scheduleStartTime: string;
  deadlineTime: string;
  finishedTime: string;
  createTime: string;
}

// 学员测评详情结果（对接考试星10000接口）
export interface EvaluationDetailResultVO {
  evaluationName: string;
  abilityDetails: AbilityDetailItem[];
}

export interface AbilityDetailItem {
  abilityName: string;
  examInfoId?: number;
  examName?: string;
  passMark?: number;
  totalScore?: number;
  records: ExamRecord[];
  total: number;
}

export interface ExamRecord {
  userId: string;
  examId: number;
  examName: string;
  examStartTime: string;
  examEndTime: string;
  examTime: number; // 分钟
  startTime: string;
  commitTime: string | null;
  score: string;
  isPass: number; // 1=及格, 0=不及格, -1=未知
  times: number;  // 作答次数
  examResultsId: number;
  examStyleName: string;
}

// 同步参数
export interface SyncParams {
  companyId?: string | number;
  employeeId?: string | number;
}
