import { BasicColumn } from '@/components/Table';
import { FormSchema } from '@/components/Form';
import { getDictOptions } from '@/utils/dict';
import { useRender } from '@/hooks/component/useRender';

export const formSchemas: FormSchema[] = [
  {
    label: '工作类型',
    field: 'workType',
    component: 'Select',
    componentProps: {
      options: getDictOptions('sys_work_type'),
    },
    defaultValue:'3'
  },
  {
    label: '维保类型',
    field: 'maintanceType',
    component: 'Select',
    componentProps: {
      options: getDictOptions('sys_maintance_type'),
    },
  },
  {
    label: '电梯编号',
    field: 'elevatorNum',
    component: 'Input',
  },
  {
    label: '二维码编号',
    field: 'qrCode',
    component: 'Input',
  },
  {
    label: '电梯名称',
    field: 'elevatorName',
    component: 'Input',
  },
  {
    label: '电梯地址',
    field: 'elevatorAddress',
    component: 'Input',
  },
  {
    label: '物业单位',
    field: 'maintenance',
    component: 'Input',
  },
  {
    label: '维保单位',
    field: 'maintenance',
    component: 'Input',
  },

  {
    label: '创建时间',
    field: 'createdTime',
    component: 'Input',
  },

  {
    label: '状态',
    field: 'state',
    component: 'Select',
    componentProps: {
      options: getDictOptions('workinfo_status'),
    },
  },

  {
    label: '超期维保状态',
    field: 'exceedStatus',
    component: 'Select',
    componentProps: {
      options: getDictOptions('sys_exceed_status'),
    },
  },
];

const { renderDict } = useRender();
export const columns: BasicColumn[] = [
  {
    title: '主键id',
    dataIndex: 'id',
    ifShow: false,
  },
  {
    title: '工作类型',
    dataIndex: 'workType',
    customRender: ({ value }) => renderDict(value, 'sys_work_type'),
  },
  {
    title: '电梯编号',
    dataIndex: 'elevatorNum',
  },
  {
    title: '二维码编号',
    dataIndex: 'qrCode',
  },
  {
    title: '电梯名称',
    dataIndex: 'elevatorName',
  },
  {
    title: '电梯地址',
    dataIndex: 'elevatorAddress',
  },

  {
    title: '创建时间',
    dataIndex: 'createdTime',
  },

  {
    title: '状态',
    dataIndex: 'state',
    customRender: ({ value }) => renderDict(value, 'workinfo_status'),
  },

  {
    title: '描述',
    dataIndex: 'description',
  },
];

export const modalSchemas: FormSchema[] = [
  {
    label: '主键id',
    field: 'id',
    required: false,
    component: 'Input',
    show: false,
  },
  {
    label: '工作类型',
    field: 'workType',
    required: false,
    component: 'Select',
    componentProps: {
      options: getDictOptions('sys_work_type'),
    },
  },
  {
    label: '电梯编号',
    field: 'elevatorNum',
    required: false,
    component: 'Input',
  },
  {
    label: '二维码编号',
    field: 'qrCode',
    required: false,
    component: 'Input',
  },
  {
    label: '电梯名称',
    field: 'elevatorName',
    required: false,
    component: 'Input',
  },
  {
    label: '电梯地址',
    field: 'elevatorAddress',
    required: false,
    component: 'Input',
  },
  {
    label: '维保单位',
    field: 'maintenance',
    required: false,
    component: 'Input',
  },
  {
    label: '发布人',
    field: 'publisher',
    required: false,
    component: 'Input',
  },
  {
    label: '创建时间',
    field: 'createdTime',
    required: false,
    component: 'Input',
  },
  {
    label: '期望时间',
    field: 'expectTime',
    required: false,
    component: 'Input',
  },
  {
    label: '截止时间',
    field: 'deadline',
    required: false,
    component: 'Input',
  },
  {
    label: '被困人数',
    field: 'trapNum',
    required: false,
    component: 'Input',
  },
  {
    label: '受伤人数',
    field: 'injuredNum',
    required: false,
    component: 'Input',
  },
  {
    label: '死亡人数',
    field: 'dieNum',
    required: false,
    component: 'Input',
  },
  {
    label: '故障原因',
    field: 'faultCause',
    required: false,
    component: 'Input',
  },
  {
    label: '原因分析',
    field: 'reason',
    required: false,
    component: 'Input',
  },
  {
    label: '事件等级',
    field: 'level',
    required: false,
    component: 'Input',
  },
  {
    label: '其它',
    field: 'other',
    required: false,
    component: 'Input',
  },
  {
    label: '状态',
    field: 'state',
    required: false,
    component: 'Select',
    componentProps: {
      options: getDictOptions('workinfo_status'),
    },
  },
  {
    label: '协同工作人员',
    field: 'collaborator',
    required: false,
    component: 'Input',
  },
  {
    label: '签名状态',
    field: 'signatureState',
    required: false,
    component: 'Input',
  },
  {
    label: '描述',
    field: 'description',
    required: false,
    component: 'Input',
  },
  {
    label: '附件',
    field: 'attachment',
    required: false,
    component: 'Input',
  },
  {
    label: '操作记录',
    field: 'operatingRecord',
    required: false,
    component: 'Input',
  },
  {
    label: '维保类型',
    field: 'maintanceType',
    required: false,
    component: 'Select',
    componentProps: {
      options: getDictOptions('sys_maintance_type'),
    },
  },
  {
    label: '超期维保状态',
    field: 'exceedStatus',
    required: false,
    component: 'Select',
    componentProps: {
      options: getDictOptions('sys_exceed_status'),
    },
  },
];

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

export const evaColumns: BasicColumn[] = [
  {
    title: '电梯名称',
    dataIndex: 'elevatorName',
  },
];

export const modalEvaSchemas: FormSchema[] = [
  {
    label: '工作类型',
    field: 'workType',
    required: false,
    component: 'Select',
    defaultValue: '3',
    componentProps: {
      options: getDictOptions('sys_work_type'),
      disabled:true
    },
  },
  {
    label: '期望时间',
    field: 'expectTime',
    required: true,
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD',
    },
  },
];
