import { rulesHelper } from '@/common';
import { ProColumns, ProFormColumnsType } from '@ant-design/pro-components';

type ReturnType = ProColumns<any, 'text'> & ProFormColumnsType<any, 'text'>;
type PropsType = { required?: boolean } & ReturnType;

export const JinGangAreaOptions = [
  {
    label: '房屋缴费',
    value: '0',
  },
  {
    label: '新增工单',
    value: '1',
  },
  {
    label: '任务中心',
    value: '2',
  },
  {
    label: '打卡考勤',
    value: '3',
  },
  {
    label: '水印相机',
    value: '4',
  },
  {
    label: '客户管理',
    value: '5',
  },
  {
    label: '住户登记',
    value: '6',
  },
  {
    label: '仪表抄表',
    value: '7',
  },
  {
    label: '催缴记录',
    value: '8',
  },
  {
    label: '项目公告',
    value: '9',
  },
];

export const JinGangArea = {
  JinGangAreaSelect(props?: PropsType): ReturnType {
    const {
      title = '选择按钮',
      key = 'path',
      required = false,
      hideInTable = true,
      ...rest
    } = props ?? {};

    return {
      title: title,
      key: key,
      valueType: 'select',
      hideInTable: hideInTable,
      formItemProps: { ...(required ? rulesHelper.text : {}) },
      ...rest,
      fieldProps: {
        options: JinGangAreaOptions,
        showSearch: true,
        fieldNames: {
          label: 'label',
          value: 'value',
        },
        ...rest?.fieldProps,
      },
    };
  },
};
