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

/** 设备类别选项（设备类别名称） */
export const DEVICE_CATEGORY_OPTIONS = [
  { label: 'GC2', value: 1 },
  { label: '机动工艺车辆', value: 2 },
];

/** 设备种类选项（设备种类名称） */
export const DEVICE_TYPE_OPTIONS = [
  { label: '压力容器', value: 1 },
  { label: '固定式压力容器', value: 2 },
  { label: '压力管道', value: 3 },
];

// 特种设备设施 - 基础表单配置（新增/编辑可用，查看时外层禁用）
export const SPECIAL_EQUIPMENT_FORM_CONFIG: FormConfig[] = [
  {
    prop: 'deviceId',
    label: '设备ID：',
    component: 'ElInput',
    componentProps: {
      placeholder: '',
    },
  },
  {
    prop: 'assetId',
    label: '设备固资ID：',
    component: 'ElInput',
    componentProps: {
      placeholder: '',
    },
  },
  {
    prop: 'deviceName',
    label: '设备名称：',
    component: 'ElInput',
    componentProps: {
      placeholder: '',
    },
  },
  {
    prop: 'useUnit',
    label: '使用单位：',
    component: 'ElInput',
    componentProps: {
      placeholder: '',
    },
  },
  {
    prop: 'categoryId',
    label: '设备类别：',
    component: 'ElSelect',
    componentProps: {
      placeholder: '请选择设备类别',
      clearable: true,
      style: { width: '100%' },
    },
    selectOptions: DEVICE_CATEGORY_OPTIONS,
  },
  {
    prop: 'typeId',
    label: '设备种类：',
    component: 'ElSelect',
    componentProps: {
      placeholder: '请选择设备种类',
      clearable: true,
      style: { width: '100%' },
    },
    selectOptions: DEVICE_TYPE_OPTIONS,
  },
  {
    prop: 'registerCode',
    label: '注册代码：',
    component: 'ElInput',
    componentProps: {
      placeholder: '',
    },
  },
  {
    prop: 'licenseNo',
    label: '使用证号：',
    component: 'ElInput',
    componentProps: {
      placeholder: '',
    },
  },
  {
    prop: 'deviceCode',
    label: '设备编码：',
    component: 'ElInput',
    componentProps: {
      placeholder: '',
    },
  },
  {
    prop: 'safeLocation',
    label: '安全地点：',
    component: 'ElInput',
    componentProps: {
      placeholder: '',
    },
  },
  {
    prop: 'useDepartment',
    label: '使用部门：',
    slot: 'useDepartment',
  },
  {
    prop: 'responsibilityDeptId',
    label: '责任部门：',
    slot: 'responsibilityDept',
  },
  {
    prop: 'responsiblePerson',
    label: '责任人：',
    component: 'ElInput',
    componentProps: {
      placeholder: '',
    },
  },
  {
    prop: 'jobNo',
    label: '工号：',
    component: 'ElInput',
    componentProps: {
      placeholder: '',
    },
  },
  {
    prop: 'factoryNo',
    label: '出厂编号：',
    component: 'ElInput',
    componentProps: {
      placeholder: '',
    },
  },
  {
    prop: 'productionDate',
    label: '生产日期：',
    component: 'ElDatePicker',
    componentProps: {
      type: 'date',
      valueFormat: 'YYYY-MM-DD',
      placeholder: '请选择生产日期',
    },
  },
  {
    prop: 'startUseDate',
    label: '启用日期：',
    component: 'ElDatePicker',
    componentProps: {
      type: 'date',
      valueFormat: 'YYYY-MM-DD',
      placeholder: '请选择启用日期',
    },
  },
  {
    prop: 'inspectionCycle',
    label: '检测周期(天)：',
    component: 'ElInputNumber',
    componentProps: {
      min: 1,
      precision: 0,
      controlsPosition: 'right',
    },
  },
  {
    prop: 'useYears',
    label: '使用年限(年)：',
    component: 'ElInputNumber',
    componentProps: {
      min: 1,
      precision: 0,
      controlsPosition: 'right',
    },
  },
  {
    prop: 'inspectionTime',
    label: '检测时间：',
    component: 'ElDatePicker',
    componentProps: {
      type: 'date',
      valueFormat: 'YYYY-MM-DD',
      placeholder: '请选择检测时间',
    },
  },
  {
    prop: 'deviceStatus',
    label: '设备状态：',
    slot: 'deviceStatus',
  },
  // {
  //   prop: 'nextInspectionDate',
  //   label: '下次检测时间：',
  //   component: 'ElDatePicker',
  //   componentProps: {
  //     type: 'date',
  //     valueFormat: 'YYYY-MM-DD',
  //     placeholder: '请选择下次检测时间',
  //   },
  // },
];

export const SPECIAL_EQUIPMENT_FORM_DATA = {
  deviceId: '',
  assetId: '',
  deviceName: '',
  useUnit: '',
  categoryId: undefined as number | undefined,
  typeId: undefined as number | undefined,
  registerCode: '',
  licenseNo: '',
  deviceCode: '',
  safeLocation: '',
  useDepartment: '',
  responsibilityDeptId: undefined as number | undefined,
  responsiblePerson: '',
  jobNo: '',
  factoryNo: '',
  productionDate: '',
  startUseDate: '',
  inspectionCycle: undefined as number | undefined,
  useYears: undefined as number | undefined,
  inspectionTime: '',
  deviceStatus: 1,
  nextInspectionDate: '',
};

export const SPECIAL_EQUIPMENT_FORM_RULES = {
  deviceId: [{ required: true, message: '设备ID不能为空', trigger: 'blur' }],
  assetId: [{ required: true, message: '设备固资ID不能为空', trigger: 'blur' }],
  deviceName: [{ required: true, message: '设备名称不能为空', trigger: 'blur' }],
  useUnit: [{ required: true, message: '使用单位不能为空', trigger: 'blur' }],
  categoryId: [{ required: true, message: '请选择设备类别', trigger: 'change' }],
  typeId: [{ required: true, message: '请选择设备种类', trigger: 'change' }],
  registerCode: [{ required: true, message: '注册代码不能为空', trigger: 'blur' }],
  licenseNo: [{ required: true, message: '使用证号不能为空', trigger: 'blur' }],
  // deviceCode: [{ required: true, message: '设备编码不能为空', trigger: 'blur' }],
  safeLocation: [{ required: true, message: '安全地点不能为空', trigger: 'blur' }],
  useDepartment: [{ required: true, message: '请选择使用部门', trigger: 'change' }],
  responsibilityDeptId: [{ required: true, message: '请选择责任部门', trigger: 'change' }],
  responsiblePerson: [{ required: true, message: '责任人不能为空', trigger: 'blur' }],
  jobNo: [{ required: true, message: '工号不能为空', trigger: 'blur' }],
  // factoryNo: [{ required: true, message: '出厂编号不能为空', trigger: 'blur' }],
  // productionDate: [{ required: true, message: '请选择生产日期', trigger: 'change' }],
  startUseDate: [{ required: true, message: '请选择启用日期', trigger: 'change' }],
  inspectionCycle: [{ required: true, message: '检测周期不能为空', trigger: 'blur' }],
  useYears: [{ required: true, message: '使用年限不能为空', trigger: 'blur' }],
  inspectionTime: [{ required: true, message: '请选择检测时间', trigger: 'change' }],
  deviceStatus: [{ required: true, message: '请选择设备状态', trigger: 'change' }],
  // nextInspectionDate: [{ required: true, message: '请选择下次检测时间', trigger: 'change' }],
};


