gaoluyang
2026-11-05 971c936f801e76d94b2bd93457a32e3368531f5c
src/views/hrm/attendance/exception/data.ts
@@ -8,6 +8,18 @@
/** 表单类型 */
export type FormType = 'create' | 'detail';
/** 考勤异常类型,与后端 HrmAttendanceExceptionTypeEnum 保持一致 */
const EXCEPTION_TYPE_OPTIONS = [
  { label: '补卡', value: 1 },
  { label: '加班', value: 2 },
  { label: '出差', value: 3 },
];
/** 考勤异常类型名称 */
export function formatExceptionType(value?: number) {
  return EXCEPTION_TYPE_OPTIONS.find((item) => item.value === value)?.label ?? '-';
}
/** 新增考勤异常申请的表单 */
export function useFormSchema(formType: FormType): VbenFormSchema[] {
  return [
@@ -20,28 +32,23 @@
      },
    },
    {
      fieldName: 'date',
      label: '考勤日期',
      fieldName: 'exceptionDate',
      label: '异常日期',
      component: 'DatePicker',
      componentProps: {
        placeholder: '请选择考勤日期',
        placeholder: '请选择异常日期',
        valueFormat: 'YYYY-MM-DD',
        style: { width: '100%' },
      },
      rules: 'required',
    },
    {
      fieldName: 'exceptionType',
      fieldName: 'type',
      label: '异常类型',
      component: 'Select',
      componentProps: {
        placeholder: '请选择异常类型',
        options: [
          { label: '漏打卡', value: 1 },
          { label: '迟到', value: 2 },
          { label: '早退', value: 3 },
          { label: '其他', value: 4 },
        ],
        options: EXCEPTION_TYPE_OPTIONS,
      },
      rules: 'selectRequired',
    },
@@ -113,8 +120,14 @@
  return [
    { field: 'userName', title: '申请人', minWidth: 100 },
    { field: 'deptName', title: '部门', minWidth: 120 },
    { field: 'date', title: '考勤日期', width: 110 },
    { field: 'exceptionTypeName', title: '异常类型', width: 100 },
    { field: 'exceptionDate', title: '异常日期', width: 110 },
    {
      field: 'type',
      title: '异常类型',
      width: 100,
      formatter: ({ cellValue }: { cellValue: number }) =>
        formatExceptionType(cellValue),
    },
    { field: 'reason', title: '异常原因', minWidth: 200 },
    {
      field: 'status',