import { FormConfig } from '@/types/basic-form';

/** 检查频次选项：每日/每周/每月/每季度/每半年/每年 */
export const CHECK_FREQUENCY_OPTIONS = [
  { label: '每日', value: '每日' },
  { label: '每周', value: '每周' },
  { label: '每月', value: '每月' },
  { label: '每季度', value: '每季度' },
  { label: '每半年', value: '每半年' },
  { label: '每年', value: '每年' },
];

/** 检查单模版类别选项（单选）：1-安全管理检查单 2-关键业务活动专项检查单 3-日常安全检查单 */
export const CHECKLIST_CATEGORY_OPTIONS = [
  { label: '安全管理检查单', value: '安全管理检查单' },
  { label: '关键业务活动专项检查单', value: '关键业务活动专项检查单' },
  { label: '日常安全检查单', value: '日常安全检查单' },
];

/** 区域检查计划新增/编辑表单配置（与截图字段顺序一致） */
export const AREA_CHECK_PLAN_FORM_CONFIG: FormConfig[] = [
  {
    prop: 'planName',
    label: '区域检查计划名称：',
    component: 'ElInput',
    componentProps: {
      placeholder: '输入区域检查计划名称',
    },
  },
  {
    prop: 'venueCategoryName',
    label: '检查类别：',
    slot: 'venueCategoryName',
  },
  {
    prop: 'checkVenue',
    label: '检查场所：',
    component: 'ElInput',
    componentProps: {
      placeholder: '输入检查场所',
    },
  },
  {
    prop: 'primaryResponsibleDeptName',
    label: '主责部门：',
    slot: 'primaryResponsibleDept', // 与新增物品领取记录页的部门下拉一致（el-cascader + getAllDepartments）
    componentProps: {
      placeholder: '请选择部门',
    },
  },
  {
    prop: 'selfCheckFrequency',
    label: '自查频次：',
    slot: 'selfCheckFrequency',
  },
  {
    prop: 'safetyEmergencyDeptName',
    label: '安全应急部门：',
    slot: 'safetyEmergencyDept', // 与新增物品领取记录页的部门下拉一致（el-cascader + getAllDepartments）
    componentProps: {
      placeholder: '请选择部门',
    },
  },
  {
    prop: 'safetyEmergencyCheckFrequency',
    label: '安全应急部检查频次：',
    slot: 'safetyEmergencyCheckFrequency',
  },
  {
    prop: 'hospitalLeaderDeptName',
    label: '院领导部门：',
    slot: 'hospitalLeaderDept', // 与新增物品领取记录页的部门下拉一致（el-cascader + getAllDepartments）
    componentProps: {
      placeholder: '请选择部门',
    },
  },
  {
    prop: 'hospitalLeaderCheckFrequency',
    label: '院领导检查频次：',
    slot: 'hospitalLeaderCheckFrequency',
  },
  {
    prop: 'categoryCode',
    label: '检查单模版类别：',
    component: 'ElSelect',
    componentProps: {
      placeholder: '选择检查单模版类别,单选',
      filterable: true,
      clearable: true,
      style: { width: '100%' },
    },
    selectOptions: [], // 由详情页 queryDictTypeDetail 注入，value=itemCode, label=itemValue
  },
  {
    prop: 'checklistTemplateName',
    label: '检查单模版名称：',
    component: 'ElSelect',
    componentProps: {
      placeholder: '选择检查单模版名称,单选',
      filterable: true,
      clearable: true,
      style: { width: '100%' },
    },
    selectOptions: [], // 由页面根据类别请求模版列表后注入
  },
  {
    prop: 'checkKeyContent',
    label: '检查重点内容：',
    component: 'ElInput',
    componentProps: {
      type: 'textarea',
      rows: 4,
      placeholder: '请输入检查重点内容',
      maxlength: 300,
      showWordLimit: true,
    },
  },
];

export const AREA_CHECK_PLAN_FORM_DATA: Record<string, unknown> = {
  planName: '',
  venueCategoryName: '',
  checkVenue: '',
  primaryResponsibleDeptId: null as number | null,
  primaryResponsibleDeptName: '',
  primaryResponsibleDeptCode: '',
  selfCheckFrequency: '',
  safetyEmergencyDeptId: null as number | null,
  safetyEmergencyDeptName: '',
  safetyEmergencyCheckFrequency: '',
  hospitalLeaderDeptId: null as number | null,
  hospitalLeaderDeptName: '',
  hospitalLeaderCheckFrequency: '',
  categoryName: '',
  categoryCode: '',
  checklistTemplateName: '',
  checkKeyContent: '',
};

export const AREA_CHECK_PLAN_FORM_RULES = {
  planName: [{ required: true, message: '请输入区域检查计划名称', trigger: 'blur' }],
  venueCategoryName: [{ required: true, message: '请输入检查类别', trigger: 'blur' }],
  checkVenue: [{ required: true, message: '请输入检查场所', trigger: 'blur' }],
  primaryResponsibleDeptName: [{ required: true, message: '请选择主责部门', trigger: 'change' }],
  selfCheckFrequency: [{ required: true, message: '请选择自查频次', trigger: 'change' }],
  safetyEmergencyDeptName: [{ required: true, message: '请选择安全应急部门', trigger: 'change' }],
  hospitalLeaderDeptName: [{ required: true, message: '请选择院领导部门', trigger: 'change' }],
  hospitalLeaderCheckFrequency: [{ required: true, message: '请选择院领导检查频次', trigger: 'change' }],
  categoryCode: [{ required: true, message: '请选择检查单模版类别', trigger: 'change' }],
  checklistTemplateName: [{ required: true, message: '请选择检查单模版名称', trigger: 'change' }],
  checkKeyContent: [{ required: true, message: '请输入检查重点内容', trigger: 'blur' }],
};
