/**
 * 全局常量配置
 */

/*角色标记*/
export const ROLE_CODE = {
  "ROLE_ADMIN": "ROLE_ADMIN", //管理员
  "ROLE_SUPPORT_MEMBER": "ROLE_SUPPORT_MEMBER", //后勤维修组人员
  "ROLE_SUPPORT_LEADER": "ROLE_SUPPORT_LEADER",
  "ROLE_TRAIN_AUDITOR": "ROLE_TRAIN_AUDITOR",
  "ROLE_RECRUIT_SECOND": "ROLE_RECRUIT_SECOND",
  "ROLE_RECRUIT": "ROLE_RECRUIT",
  "ROLE_TRAIN_MONEY_ARRIVED": "ROLE_TRAIN_MONEY_ARRIVED", //培训处项目申报审批人
};

/**
 * 流程类型
 */
export const PROC_DEF_KEY = {
  "TRAIN_PROJECT_MONEY_ARRIVED": "train_project_money_arrived",
  "TRAIN_PROJECT_APPROVAL": "train_project_approval",
  "ASSETS_TRANSFER": "assetsTransfer",
  "ASSET_INVALID": "asset_invalid",
  "process": "process",
  "processWander": "processWander",
};

/*当前学年*/
export const CURRENT_SCHOOL_YEAR = "2021-2022";

/*当前学期*/
export const CURRENT_SCHOOL_TERM = "2";

/**
 * 流程状态
 * 0: 等待部门审核
 * 10: 等待部门审批
 * 20: 审批通过
 * -10: 经办人修改
 * -20: 撤销申请
 */
export const BXSTATUS = {
  '0': '待审核',
  '10': '待审批',
  '20': '通过',
  '-10': '驳回修改',
  '-20': '撤销'
};

/**
 * 前端URL
 */
export const FRONT_URL = "https://zhxy.czjsy.com";

/**
 * 招生相关常量
 */

// 推送状态
export const PUSHED_STATUS_LIST = [
  { label: "未推送", value: "0" ,type: "danger"},
  { label: "已推送", value: "1" ,type: "success"},
];

// 录取通知书发放状态 
export const NOTICE_SEND_STATUS_LIST = [
  { label: "未发放", value: "0" },
  { label: "已发放", value: "1" }
];

// 缴费状态（使用字典 recruit_pay_status）
export const PAY_STATUS_LIST = [
  { label: "已缴费", value: "10" ,type: "success"},
  { label: "未缴费", value: "0" ,type: "danger"},
  { label: "部分缴费", value: "5" ,type: "warning"},
];

// 审核状态（使用字典 recruit_audit_status）
export const AUDIT_STATUS_LIST = [
  { label: "未录取", value: "-20" ,type: "danger"},
  { label: "待审核", value: "0" ,type: "warning"},
  { label: "已录取", value: "20" ,type: "success"},
];

// 市平台考试类型审核状态（使用字典 recruit_city_exam_type）
export const CITY_EXAM_TYPE_LIST = [
  { label: "待审核", value: "0" },
  { label: "通过", value: "1" },
  { label: "驳回", value: "2" }
];

// 宿舍范围状态（使用字典 recruit_dorm_range_status）
export const DORM_RANGE_STATUS_LIST = [
  { label: "待确认", value: "0" },
  { label: "范围内", value: "1" },
  { label: "范围外", value: "2" }
];

// 发送短信状态
export const SEND_STATUS_LIST = [
  { label: "未发送", value: "0" },
  { label: "已发送", value: "1" }
];

// 手动设置状态
export const MANUAL_SET_STATUS_LIST = [
  { label: "未设置", value: "0" },
  { label: "已设置", value: "1" }
];

// 住宿申请状态
export const DORM_APPLY_STATUS_LIST = [
  { label: "未通过", value: "0" },
  { label: "申请通过", value: "1" }
];

// 面试结果
export const INTERVIEW_DIC_LIST = [
  { label: "未面试", value: "0" ,type: "info",icon: "Document"},
  { label: "面试通过", value: "1" ,type: "success",icon: "CircleCheck"},
  { label: "面试未通过", value: "-1" ,type: "danger",icon: "CircleClose"},
];

// 招生资料审核状态（使用字典 recruit_zlsh，包含图标和颜色配置）
export const RECRUIT_MATERIAL_STATUS_LIST = [
  { label: "未填写", value: "0", type: "info", icon: "Document" },
  { label: "待审核", value: "1", type: "warning", icon: "Clock" },
  { label: "审核通过", value: "2", type: "success", icon: "CircleCheck" },
  { label: "审核驳回", value: "3", type: "danger", icon: "CircleClose" }
];

// 新市民材料上传状态（使用字典 recruit_new_city_material_status）
export const NEW_CITY_MATERIAL_STATUS_LIST = [
  { label: "未上传", value: "0" },
  { label: "已上传", value: "1" },
];

// 异动审核状态
export const TURNOVER_AUDIT_STATUS_LIST = [
  { label: "待审核", value: "1" ,type: "warning", icon: "Clock"},
  { label: "驳回", value: "2" ,type: "danger", icon: "CircleClose"},
  { label: "通过", value: "3" ,type: "success", icon: "CircleCheck"}
];


// 人事模块
// 专业审核状态选项（用于 AuditState 组件）, 学历学位审核状态选项
import type { StateOption } from '/@/components/AuditState/index.vue'
export const PROFESSIONAL_AUDIT_STATE_OPTIONS: StateOption[] = [
  { value: '1', label: '已通过', type: 'success', icon: 'fa-solid fa-circle-check', effect: 'dark' },
  { value: '-2', label: '已驳回', type: 'danger', icon: 'fa-solid fa-circle-xmark', effect: 'dark' },
  { value: '0', label: '待审核', type: 'warning', icon: 'fa-regular fa-clock', effect: 'light' },
  { value: '10', label: '部门通过', type: 'warning', icon: 'fa-regular fa-clock' ,effect:"dark" }
];

/**
 * 根据值从状态列表中获取配置项
 * @param statusList 状态列表
 * @param value 状态值
 * @returns 配置项
 */
export const getStatusConfig = (statusList: any[], value: string | number) => {
  return statusList.find(item => item.value === String(value));
};

/**
 * 获取报到状态配置（用于 ClickableTag）
 * 根据字典数据：0=未联系, 1=已经报到, 2=推迟报到, 3=放弃报到, 4=无法联系
 * @param statusList 报到状态字典列表
 * @param value 状态值
 * @param iconMap 图标映射对象，包含 CircleCheck, CircleClose, DocumentChecked, Warning, Clock
 * @returns 包含 label、type、icon 的配置对象
 */
export const getCheckInStatusConfig = (
  statusList: any[], 
  value: string,
  iconMap: {
    CircleCheck: any
    CircleClose: any
    DocumentChecked: any
    Warning: any
    Clock: any
  }
) => {
  const item = statusList.find((item: any) => item.value === value)
  if (!item) return null
  
  let type: 'success' | 'info' | 'warning' | 'danger' = 'info'
  let icon: any = null
  
  // 根据状态值设置类型和图标
  switch (value) {
    case '1': // 已经报到
      type = 'success'
      icon = iconMap.CircleCheck
      break
    case '2': // 推迟报到
      type = 'warning'
      icon = iconMap.Clock
      break
    case '3': // 放弃报到
      type = 'danger'
      icon = iconMap.CircleClose
      break
    case '4': // 无法联系
      type = 'danger'
      icon = iconMap.Warning
      break
    case '0': // 未联系
    default:
      type = 'info'
      icon = iconMap.DocumentChecked
      break
  }
  
  return {
    label: item.label,
    type,
    icon
  }
}

