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

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: 'tenementName',
    component: 'Input',
  },

  {
    label: '维保单位',
    field: 'maintenanceName',
    component: 'Input',
  },
];
import { useRender } from '@/hooks/component/useRender';
const { renderTag, renderDict } = useRender();
export const columns: BasicColumn[] = [
  {
    title: '主键id',
    dataIndex: 'id',
    ifShow: false,
  },
  {
    title: '故障编号',
    dataIndex: 'faultCode',
  },
  {
    title: '故障名称',
    dataIndex: 'faultName',
  },
  {
    title: '终端编号',
    dataIndex: 'deviceCode',
  },
  {
    title: '注册代码',
    dataIndex: 'registerCode',
  },
  {
    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',
  },
  {
    title: '故障状态',
    dataIndex: 'state',
  },
];

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