import { BasicColumn } from '@/components/Table';
import { FormSchema } from '@/components/Form';
import { getDictOptions } from '@/utils/dict';
import { useRender } from '@/hooks/component/useRender';
const { renderTag, renderDict } = useRender();
export const formSchemas: FormSchema[] = [
  {
    label: '故障编号',
    field: 'faultCode',
    component: 'Input',
  },
  {
    label: '故障名称',
    field: 'faultName',
    component: 'Input',
  },
  {
    label: '注册代码',
    field: 'registerCode',
    component: 'Input',
  },
  {
    label: '终端编号',
    field: 'terminalCode',
    component: 'Input',
  },
  {
    label: '电梯编号',
    field: 'elevatorNum',
    component: 'Input',
  },
  {
    label: '电梯名称',
    field: 'elevatorName',
    component: 'Input',
  },
  {
    label: '发生时间起',
    field: 'happenTimeStart',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
  },
  {
    label: '发生时间起',
    field: 'happenTimeEnd',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
  },

  {
    label: '故障来源',
    field: 'source',
    component: 'Select',
    componentProps: {
      options: getDictOptions('fault_resource'),
    },
  },

  {
    label: '物业单位',
    field: 'floor',
    component: 'Input',
  },
  {
    label: '物业单位',
    field: 'propertyName',
    component: 'Input',
  },
  {
    label: '维保单位',
    field: 'maintainName',
    component: 'Input',
  },
];

export const columns: BasicColumn[] = [
  {
    title: '主键id',
    dataIndex: 'id',
    ifShow: false,
  },
  {
    title: '故障编号',
    dataIndex: 'faultCode',
  },
  {
    title: '故障名称',
    dataIndex: 'faultName',
  },
  {
    title: '终端编号_',
    dataIndex: 'deviceCode',
  },
  {
    title: '电梯编号',
    dataIndex: 'elevatorNum',
  },
  {
    title: '电梯名称',
    dataIndex: 'elevatorName',
  },
  {
    title: '发生时间',
    dataIndex: 'happenTime',
  },
  {
    title: '确认时间',
    dataIndex: 'recoverTime',
  },
  {
    title: '故障来源',
    dataIndex: 'source',
    customRender: ({ value }) => renderDict(value, 'fault_resource'),
  },
  {
    title: '楼层',
    dataIndex: 'floor',
  },
  {
    title: '故障图片',
    dataIndex: 'picture',
    key: 'picture',
  },
  // {
  //   title: '故障状态',
  //   dataIndex: 'state',
  // },
];

export const modalSchemas: FormSchema[] = [
  {
    label: '主键id',
    field: 'id',
    required: false,
    component: 'Input',
    show: false,
  },
  {
    label: '故障编号',
    field: 'faultCode',
    required: true,
    component: 'Input',
  },
  {
    label: '故障名称',
    field: 'faultName',
    required: true,
    component: 'Input',
  },
  {
    label: '终端编号',
    field: 'terminalCode',
    required: true,
    component: 'Input',
  },
  {
    label: '电梯编号',
    field: 'elevatorNum',
    required: true,
    component: 'Input',
  },
  {
    label: '电梯名称',
    field: 'elevatorName',
    required: true,
    component: 'Input',
  },
  {
    label: '发生事件',
    field: 'happenTime',
    required: true,
    component: 'Input',
  },
  {
    label: '确认时间',
    field: 'recoverTime',
    required: true,
    component: 'Input',
  },
  {
    label: '故障来源',
    field: 'source',
    required: true,
    component: 'Select',
    componentProps: {
      options: getDictOptions('fault_resource'),
    },
  },
  {
    label: '楼层',
    field: 'floor',
    required: true,
    component: 'Input',
  },
  {
    label: '故障图片',
    field: 'picture',
    required: true,
    component: 'ImageUpload',
  },
  // {
  //   label: '故障状态',
  //   field: 'state',
  //   required: true,
  //   component: 'Input',
  // },
  {
    label: '确认人',
    field: 'affirmPeople',
    required: true,
    component: 'Input',
  },
  {
    label: '故障原因',
    field: 'cause',
    required: true,
    component: 'Input',
  },
  {
    label: '原因分析',
    field: 'causeAnalyse',
    required: true,
    component: 'Input',
  },
  {
    label: '故障说明',
    field: 'explain',
    required: true,
    component: 'Input',
  },
  {
    label: '视频地址',
    field: 'videoAddress',
    required: true,
    component: 'Input',
  },
];
