export const FORM_RULES = {
  trainingPlanName: [{ required: true, message: '教育培训计划名称', trigger: 'blur' }],
  categoryName: [{ required: true, message: '请输入分类名称', trigger: 'change' }],
  trainingContent: [{ required: true, message: '请输入培训名称（内容）', trigger: 'blur' }],
  trainingObject: [{ required: true, message: '请输入培训对象', trigger: 'blur' }],
  trainingCount: [{ required: true, message: '请输入培训人数', trigger: 'blur' }],
  trainingTime: [{ required: true, message: '请输入培训时间', trigger: 'blur' }],
  trainingMethod: [{ required: true, message: '请输入培训方式', trigger: 'blur' }],
  assessmentMethod: [{ required: true, message: '请输入考核方式', trigger: 'blur' }],
  responsibleDeptIds: [{ required: true, type: 'array', message: '请选择培训责任部门', trigger: 'change' }],
  studyHours: [
    { required: true, message: '请输入学时', trigger: 'blur' },
    { type: 'number', message: '学时必须为数字', trigger: 'blur' },
  ],
};

export const IssueWorkPlanFormRules = {
  responsibleDeptIds: [{ required: true, message: '请选择培训责任部门', trigger: 'change' }],
  groupId: [
    {
      required: true,
      validator(_rule, value, callback) {
        const empty =
          value === '' || value === null || value === undefined || (Array.isArray(value) && value.length === 0);
        if (empty) callback(new Error('请选择计划执行部门分组'));
        else callback();
      },
      trigger: 'change',
    },
  ],
  startTime: [{ required: true, message: '请选择计划开始日期', trigger: 'change' }],
  endTime: [{ required: true, message: '请选择计划结束日期', trigger: 'change' }],
};
