import { BasicColumn } from '@/components/Table';
import { FormSchema } from '@/components/Form';
import { maintenanceInfoList } from '@/api/basicInfo/maintenance';
import { TRUE_RIGHT } from '@/utils/lib/commonMap';
import { renderDict } from '@/views/system/config/config.data';
import { getDictOptions } from '@/utils/dict';

export const formSchemas: FormSchema[] = [
  {
    label: '单位名称',
    field: 'unitName',
    component: 'Input',
  },

  {
    label: '员工类型',
    field: 'employeeType',
    component: 'Select',
    componentProps: {
      options: getDictOptions('employ_type'),
    },
  },

  {
    label: '手机号',
    field: 'phone',
    component: 'Input',
  },
  {
    label: '手机端用户名',
    field: 'phoneName',
    component: 'Input',
  },
  {
    label: '语音通知手机号',
    field: 'voicePhone',
    component: 'Input',
  },
  {
    label: '故障短信通知手机号',
    field: 'faultPhone',
    component: 'Input',
  },

  {
    label: '身份证号',
    field: 'idNumber',
    component: 'Input',
  },
];

export const columns: BasicColumn[] = [
  {
    title: '主键id',
    dataIndex: 'id',
    ifShow: false,
  },
  {
    title: '手机端用户名',
    dataIndex: 'phoneName',
  },
  {
    title: '头像',
    dataIndex: 'photo',
  },
  {
    title: '单位类型',
    dataIndex: 'unitType',
    customRender: ({ value }) => renderDict(value, 'sys_unit_type'),
  },
  {
    title: '关联单位',
    dataIndex: 'relevancyUnit',
  },
  {
    title: '员工类型',
    dataIndex: 'employeeType',
    customRender: ({ value }) => renderDict(value, 'employ_type'),
  },
  {
    title: '故障短信推送状态',
    dataIndex: 'isFault',
    customRender: ({ value }) => renderDict(value, 'common_open_close'),
  },
  {
    title: '语音通知状态',
    dataIndex: 'isVoice',
    customRender: ({ value }) => renderDict(value, 'common_open_close'),
  },
  {
    title: '关联项目',
    dataIndex: 'relevancyProject',
  },
  {
    title: '手机号',
    dataIndex: 'phone',
  },
 
  {
    title: '语音通知手机号',
    dataIndex: 'voicePhone',
  },
  {
    title: '故障短信通知手机号',
    dataIndex: 'faultPhone',
  },

  {
    title: '身份证号',
    dataIndex: 'idNumber',
  },
  // {
  //   title: '特种设备作业人员证书',
  //   dataIndex: 'credential',
  // },
];

export const modalSchemas: FormSchema[] = [
  {
    label: '主键id',
    field: 'id',
    required: false,
    component: 'Input',
    show: false,
  },
  {
    label: '单位类型',
    field: 'unitType',
    required: true,
    component: 'Select',
    componentProps: {
      options: getDictOptions('sys_unit_type'),
    },
  },
  // {
  //   label: '关联单位',
  //   field: 'relevancyUnit',
  //   required: true,
  //   component: 'ApiSelect',
  //   componentProps: {
  //     api: maintenanceInfoList,
  //     labelField: 'name',
  //     valueField: 'id',
  //     placeholder: '请选择维保单位',
  //     afterFetch: (res) => {
  //       return res.rows;
  //     },
  //   },
  // },
  {
    label: '关联单位',
    field: 'relevancyId',
    required: false,
    component: 'Select',

  },
  {
    label: '关联单位mc',
    field: 'relevancyUnit',
    required: false,
    component: 'Input',
    show: false,
  },
  {
    label: '员工类型',
    field: 'employeeType',
    required: true,
    component: 'Select',
    componentProps: {
      options: getDictOptions('employ_type'),
    },
  },
  {
    label: '关联项目',
    field: 'relevancyProject',
    required: true,
    component: 'Input',
  },
  {
    label: '作业人员证书编号',
    field: 'credentialNum',
    required: true,
    component: 'Input',
  },
  {
    label: '劳动合同生效日',
    field: 'contractStart',
    required: true,
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD',
    },
  },
  {
    label: '劳动合同截止日',
    field: 'contractEnd',
    required: true,
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD',
    },
  },
  {
    label: '手机号',
    field: 'phone',
    required: true,
    component: 'Input',
  },
  {
    label: '手机端用户名',
    field: 'phoneName',
    required: true,
    component: 'Input',
  },
  {
    label: '语音通知手机号',
    field: 'voicePhone',
    required: true,
    component: 'Input',
  },
  {
    label: '故障短信通知手机号',
    field: 'faultPhone',
    required: true,
    component: 'Input',
  },
  {
    label: '是否推送故障短信',
    field: 'isFault',
    required: true,
    component: 'Select',
    componentProps: {
      options: TRUE_RIGHT,
    },
  },
  {
    label: '是否配置语音通知',
    field: 'isVoice',
    required: true,
    component: 'Select',
    componentProps: {
      options: TRUE_RIGHT,
    },
  },
  {
    label: '是否接受行为提醒',
    field: 'isBehaviorRemind',
    required: true,
    component: 'Select',
    componentProps: {
      options: TRUE_RIGHT,
    },
  },
  {
    label: '是否开启免打扰',
    field: 'isDisturb',
    required: true,
    component: 'Select',
    componentProps: {
      options: TRUE_RIGHT,
    },
  },
  {
    label: '关注全部电梯',
    field: 'isAllElevator',
    required: true,
    component: 'Select',
    componentProps: {
      options: TRUE_RIGHT,
    },
  },
  {
    label: '身份证号',
    field: 'idNumber',
    required: true,
    component: 'Input',
  },
  {
    label: '特种设备作业人员证书',
    field: 'credential',
    required: true,
    component: 'ImageUpload',
  },
  {
    label: '头像',
    field: 'photo',
    required: true,
    component: 'ImageUpload',
  },
];

export const formEvaSchemas: FormSchema[] = [
  {
    label: '电梯名称',
    field: 'elevatorName',
    component: 'Input',
  },

  {
    label: '维保单位',
    field: 'maintenanceName',
    component: 'Input',
  },
];

export const evaColumns: BasicColumn[] = [
  {
    title: '主键id',
    dataIndex: 'id',
    ifShow: false,
  },
  {
    title: '电梯编号',
    dataIndex: 'elevatorNum',
  },
  {
    title: '电梯名称',
    dataIndex: 'elevatorName',
  },
  {
    title: '电梯地址',
    dataIndex: 'elevatorAddress',
  },
  {
    title: '维保单位',
    dataIndex: 'maintenanceName',
  },
];
