attendance.data.ts 5.03 KB
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { h } from 'vue';

// 本地实现审核状态文本转换函数
function getAttendanceStatusText(status: number): string {
  switch (status) {
    case 0:
      return '待审核';
    case 10:
      return '已审核';
    case 20:
      return '已驳回';
    default:
      return '未创建';
  }
}

// 安全获取数据的函数,如果数据不存在则返回默认值
function safeGet(obj: any, key: string, defaultValue: any = '') {
  if (!obj) return defaultValue;
  return obj[key] !== undefined ? obj[key] : defaultValue;
}

// 简化列定义,移除可能导致渲染问题的customRender配置
export const columns: BasicColumn[] = [
  {
    title: '昵称',
    dataIndex: 'nickName',
    width: 120,
  },
  {
    title: '姓名',
    dataIndex: 'chineseName',
    width: 120,
  },
  {
    title: '角色',
    dataIndex: 'roleName',
    width: 120,
  },
  {
    title: '部门',
    dataIndex: 'deptName',
    width: 120,
  },
  {
    title: '公司',
    dataIndex: 'companyName',
    width: 150,
  },
  {
    title: '考勤组',
    dataIndex: 'monthlyAttendanceName',
    width: 120,
  },
  {
    title: '计薪日',
    dataIndex: 'payDay',
    width: 100,
  },
  {
    title: '工作日',
    dataIndex: 'monthlyWorkingDay',
    width: 100,
  },
  {
    title: '实际出勤小时',
    dataIndex: 'attendanceDays',
    width: 120,
  },
  {
    title: '请假',
    dataIndex: 'leaveDays',
    width: 100,
  },
  {
    title: '本月调休',
    dataIndex: 'compensatoryLeaveDays',
    width: 100,
  },
  {
    title: '本月存休',
    dataIndex: 'storageLeaveDays',
    width: 100,
  },
  {
    title: '全部上班时间',
    dataIndex: 'workHours',
    width: 120,
  },
  {
    title: '上月存休',
    dataIndex: 'lastMonthLeaveDays',
    width: 100,
  },
  {
    title: '累计存休',
    dataIndex: 'totalStorageLeaveDays',
    width: 100,
  },
  {
    title: '审核状态',
    dataIndex: 'attendanceStatus',
    width: 100,
    customRender: ({ text }) => {
      return getAttendanceStatusText(text);
    },
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'nickName',
    label: '昵称',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    field: 'chineseName',
    label: '姓名',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    field: 'deptName',
    label: '部门',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    field: 'dateTime',
    label: '统计月份',
    component: 'DatePicker',
    componentProps: {
      picker: 'month',
      valueFormat: 'YYYY-MM',
    },
    required: true,
    colProps: { span: 8 },
  },
  
];

export const formSchema: FormSchema[] = [
  {
    field: 'id',
    label: 'ID',
    component: 'Input',
    show: false,
  },
  {
    field: 'chineseName',
    label: '姓名',
    required: true,
    component: 'Input',
    componentProps: {
      disabled: true, 
    },
  },
  {
    field: 'nickName',
    label: '昵称',
    required: true,
    component: 'Input',
    componentProps: {
      disabled: true, 
    },
  },
  {
    field: 'deptName',
    label: '部门',
    required: true,
    component: 'Input',
    componentProps: {
      disabled: true, 
    },
  },
  {
    field: 'companyName',
    label: '公司',
    required: true,
    component: 'Input',
    componentProps: {
      disabled: true, 
    },
  },
  {
    field: 'monthlyAttendanceId',
    label: '考勤组ID',
    component: 'Input',
    show: false,
  },
  {
    field: 'monthlyAttendanceName',
    label: '考勤组',
    required: true,
    component: 'Input',
  },
  {
    field: 'payDay',
    label: '计薪日',
    required: true,
    component: 'InputNumber',
    componentProps: {
      disabled: true, 
    },
  },
  {
    field: 'monthlyWorkingDay',
    label: '工作日',
    required: true,
    component: 'InputNumber',
    componentProps: {
      disabled: true, 
    },
  },
  {
    field: 'attendanceDays',
    label: '实际出勤小时',
    required: true,
    component: 'InputNumber',
    componentProps: {
      min: 0,
    },
  },
  {
    field: 'leaveDays',
    label: '请假',
    required: true,
    component: 'InputNumber',
    componentProps: {
      min: 0,
    },
  },
  {
    field: 'compensatoryLeaveDays',
    label: '本月调休',
    required: true,
    component: 'InputNumber',
    componentProps: {
      min: 0,
    },
  },
  {
    field: 'storageLeaveDays',
    label: '本月存休',
    required: true,
    component: 'InputNumber',
    componentProps: {
      min: 0,
    },
  },
  {
    field: 'lastMonthLeaveDays',
    label: '上月存休',
    required: true,
    component: 'InputNumber',
    componentProps: {
      min: 0,
    },
  },
  {
    field: 'totalStorageLeaveDays',
    label: '累计存休',
    required: true,
    component: 'InputNumber',
    componentProps: {
      min: 0,
    },
  },
  {
    field: 'workHours',
    label: '全部上班时间',
    required: true,
    component: 'InputNumber',
    componentProps: {
      min: 0,
    },
  },
];