personnelConfig.data.ts 3.24 KB

import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Form/index';
// 动态生成年份选项
const generateYearOptions = () => {
  const currentYear = new Date().getFullYear();
  const years: { label: string; value: string }[] = [];
  
  for (let i = -2; i <= 5; i++) {
    const year = currentYear + i;
    years.push({
      label: `${year}年`,
      value: year.toString(),
    });
  }
  
  return years;
};
// 常量定义
const yearOptions = generateYearOptions();
const monthOptions = [
  { label: '1月', value: '1' },
  { label: '2月', value: '2' },
  { label: '3月', value: '3' },
  { label: '4月', value: '4' },
  { label: '5月', value: '5' },
  { label: '6月', value: '6' },
  { label: '7月', value: '7' },
  { label: '8月', value: '8' },
  { label: '9月', value: '9' },
  { label: '10月', value: '10' },
  { label: '11月', value: '11' },
  { label: '12月', value: '12' },
];
export const columns: BasicColumn[] = [
  {
    title: '年份',
    dataIndex: 'year',
    width: 100,
    align: 'center',
  },
  {
    title: '月份',
    dataIndex: 'month',
    width: 100,
    align: 'center',
  },
  {
    title: '日历天数',
    dataIndex: 'calendarDays',
    width: 120,
    align: 'center',
  },
  {
    title: '工作日',
    dataIndex: 'workDays',
    width: 100,
    align: 'center',
  },
  {
    title: '计薪日',
    dataIndex: 'salaryDays',
    width: 100,
    align: 'center',
  },
  {
    title: '法定日',
    dataIndex: 'legalHolidays',
    width: 100,
    align: 'center',
  }
];
export const searchFormSchema: FormSchema[] = [
  {
    field: 'settingValue',
    label: '年份',
    component: 'Select',
    componentProps: {
      options: yearOptions,
    },
    defaultValue: new Date().getFullYear().toString(),
    colProps: { span: 6 },
  },
  {
    field: 'settingType',
    label: '',
    component: 'Input',
    defaultValue: '60',
    show: false,
  },
  {
    field: 'month',
    label: '月份',
    component: 'Select',
    componentProps: {
      options: monthOptions,
    },
    colProps: { span: 6 },
  },
];
export const formSchema: FormSchema[] = [
  {
    field: 'year',
    label: '年份',
    required: true,
    component: 'Select',
    componentProps: {
      options: yearOptions,
    },
  },
  {
    field: 'month',
    label: '月份',
    required: true,
    component: 'Select',
    componentProps: {
      options: monthOptions,
    },
  },
  {
    field: 'calendarDays',
    label: '日历天数',
    required: true,
    component: 'InputNumber',
    componentProps: {
      min: 28,
      max: 31,
      style: {
        width: '100%',
      },
    },
  },
  {
    field: 'workDays',
    label: '工作日',
    required: true,
    component: 'InputNumber',
    componentProps: {
      min: 0,
      max: 31,
      style: {
        width: '100%',
      },
    },
  },
  {
    field: 'salaryDays',
    label: '计薪日',
    required: true,
    component: 'InputNumber',
    componentProps: {
      min: 0,
      max: 31,
      style: {
        width: '100%',
      },
    },
  },
  {
    field: 'legalHolidays',
    label: '法定日',
    required: true,
    component: 'InputNumber',
    componentProps: {
      min: 0,
      max: 31,
      style: {
        width: '100%',
      },
    },
  },
];