import { BasicColumn } from '@/components/Table';
import { FormSchema } from '@/components/Form';
import { houseInfoList } from '@/api/basicInfo/areaInfo/index';
import { infoList } from '@/api/basicInfo/tenement';
import { maintenanceInfoList } from '@/api/basicInfo/maintenance';
import { factoryInfoList } from '@/api/basicInfo/outputFactory';
import { buildingInfoList } from '@/api/basicInfo/buildingsInfo';
import { projectInfoList } from '@/api/basicInfo/projectsInfo';
import { getDictOptions } from '@/utils/dict';
import { useRender } from '@/hooks/component/useRender';
const { renderTag, renderDict } = useRender();
export const useMap = [
  { 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 formSchemas: FormSchema[] = [
  {
    label: '注册代码',
    field: 'registerCode',
    component: 'Input',
  },
  {
    label: '二维码编号',
    field: 'registerCode',
    component: 'Input',
  },
  {
    label: '电梯编号',
    field: 'elevatorNum',
    component: 'Input',
  },

  {
    label: '电梯名称',
    field: 'elevatorName',
    component: 'Input',
  },
  {
    label: '电梯地址',
    field: 'elevatorAddress',
    component: 'Input',
  },

  {
    label: '使用场景',
    field: 'useScenario',

    component: 'Select',
    componentProps: {
      options: getDictOptions('use_scenario'),
    },
  },
  {
    label: '使用单位',
    field: 'employName',
    component: 'Input',
  },
  {
    label: '物业单位',
    field: 'tenementName',
    required: false,
    component: 'Input',
  },
  {
    label: '维保单位',
    field: 'maintenanceName',
    required: false,
    component: 'Input',
  },
  // {
  //   label: '项目',
  //   field: 'projectId',

  //   component: 'ApiSelect',
  //   componentProps: {
  //     api: projectInfoList,
  //     labelField: 'name',
  //     valueField: 'id',
  //     placeholder: '请选择项目',
  //     afterFetch: (res) => {
  //       return res.rows;
  //     },
  //   },
  // },

  {
    label: '节能类型',
    field: 'energyType',
    component: 'Select',
    componentProps: {
      options: [
        { label: '节能', value: 1 },
        { label: '非节能', value: 2 },
      ],
    },
  },
  {
    label: '楼宇',
    field: 'buildingName',
    required: false,
    component: 'Input',
  },
  {
    label: '小区',
    field: 'houseName',
    required: false,
    component: 'Input',
  },
  {
    label: '品牌',
    field: 'brand',
    component: 'Select',
    componentProps: {
      options: getDictOptions('eva_brand'),
    },
  },
  {
    label: '投用日期起',
    field: 'startDate',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      format: 'YYYY-MM-DD ',
      valueFormat: 'YYYY-MM-DD',
    },
  },
  {
    label: '投用日期止',
    field: 'endDate',
    componentProps: {
      showTime: true,
      format: 'YYYY-MM-DD ',
      valueFormat: 'YYYY-MM-DD',
    },

    component: 'DatePicker',
  },
  {
    label: '超期未检',
    field: 'checkStateExt',
    component: 'Select',
    componentProps: {
      options: [
        { label: '是', value: '1' },
        { label: '否', value: '2' },
      ],
    },
  },
  {
    label: '超期未保',
    field: 'mainStateExt',
    component: 'Select',
    componentProps: {
      options: [
        { label: '是', value: '1' },
        { label: '否', value: '2' },
      ],
    },
  },
  {
    label: '设备代码',
    field: 'deviceCode',
    component: 'Input',
  },
  {
    label: '有无机房',
    field: 'computerHouse',
    component: 'Select',
    componentProps: {
      options: [
        { label: '有', value: '1' },
        { label: '无', value: '2' },
      ],
    },
  },
  {
    label: '行政区域',
    field: 'areaCode',
    component: 'Input',
    // componentProps: {
    //   treeData: [
    //     {
    //       label: '行政区域',
    //       value: '1',
    //       children: [
    //         {
    //           label: '湖北省',
    //           value: '1-1',
    //           children: [
    //             {
    //               label: '武汉市',
    //               value: '1-1-1',
    //               children: [
    //                 {
    //                   label: '江夏区',
    //                   value: '1-1-1-1',
    //                 },
    //               ],
    //             },
    //           ],
    //         },
    //       ],
    //     },
    //   ],
    // },
  },
];

export const columns: BasicColumn[] = [
  {
    title: '注册代码',
    dataIndex: 'registerCode',
  },
  {
    title: '设备代码',
    dataIndex: 'registerCode',
  },
  {
    title: '电梯编号',
    dataIndex: 'elevatorNum',
  },
  {
    title: '电梯名称',
    dataIndex: 'elevatorName',
  },
  {
    title: '电梯地址',
    dataIndex: 'elevatorAddress',
  },
  {
    title: '楼宇',
    dataIndex: 'buildingName',
  },
  {
    title: '小区',
    dataIndex: 'houseName',
  },
  {
    title: '使用场景',
    dataIndex: 'useScenario',
    customRender: ({ value }) => renderDict(value, 'use_scenario'),
  },
  {
    title: '物业单位',
    dataIndex: 'tenementName',
  },
  {
    title: '维保单位',
    dataIndex: 'maintenanceName',
  },
  {
    title: '品牌',
    dataIndex: 'brand',
    customRender: ({ value }) => renderDict(value, 'eva_brand'),
  },
  {
    title: '超期未检',
    dataIndex: 'checkStateExt',
  },
];

export const modalSchemas: FormSchema[] = [
  {
    label: '主键id',
    field: 'id',
    required: false,
    component: 'Input',
    show: false,
  },
  // {
  //   label: '项目',
  //   field: 'projectId',
  //   required: true,
  //   component: 'ApiSelect',
  //   componentProps: {
  //     api: projectInfoList,
  //     labelField: 'name',
  //     valueField: 'id',
  //     placeholder: '请选择项目',
  //     afterFetch: (res) => {
  //       return res.rows;
  //     },
  //   },
  // },
  {
    label: '注册代码',
    field: 'registerCode',
    required: false,
    component: 'Input',
  },
  {
    label: '第三方电梯id',
    field: 'eleId',
    required: false,
    component: 'Input',
  },
  {
    label: '项目',
    field: 'deptId',
    required: true,
    component: 'TreeSelect',
    helpMessage: ['注意绑定的角色要带相应的部门权限, 否则无法正常登录'],
  },
  {
    label: '设备代码',
    field: 'deviceCode',
    required: false,
    component: 'Input',
  },
  {
    label: '电梯编号',
    field: 'elevatorNum',
    required: true,
    component: 'Input',
  },
  {
    label: '电梯名称',
    field: 'elevatorName',
    required: true,
    component: 'Input',
  },
  {
    label: '电梯地址',
    field: 'elevatorAddress',
    required: true,
    component: 'Input',
  },
  {
    label: '进口设备代理商',
    field: 'inputDevice',
    required: false,
    component: 'Input',
  },
  {
    label: '行政区域编号',
    field: 'areaCode',
    required: false,
    component: 'Input',
    // componentProps: {
    //   treeData: [
    //     {
    //       label: '行政区域',
    //       value: '1',
    //       children: [
    //         {
    //           label: '湖北省',
    //           value: '1-1',
    //           children: [
    //             {
    //               label: '武汉市',
    //               value: '1-1-1',
    //               children: [
    //                 {
    //                   label: '江夏区',
    //                   value: '1-1-1-1',
    //                 },
    //               ],
    //             },
    //           ],
    //         },
    //       ],
    //     },
    //   ],
    // },
  },
  // {
  //   label: '楼宇',
  //   field: 'buildingId',
  //   required: false,
  //   component: 'Select',
  // },
  // {
  //   label: '楼宇名称',
  //   field: 'buildingName',
  //   required: false,
  //   show: false,
  //   component: 'Input',
  // },
  // {
  //   label: '小区',
  //   field: 'houseId',
  //   required: false,

  //   component: 'Select',
  // },
  // {
  //   label: '小区名称',
  //   field: 'houseName',
  //   required: false,
  //   show: false,
  //   component: 'Select',
  // },
  {
    label: '使用场景',
    field: 'useScenario',
    required: false,
    component: 'Select',
    componentProps: {
      options: getDictOptions('use_scenario'),
    },
  },
  {
    label: '使用单位',
    field: 'employId',
    required: false,
    component: 'Select',
  },
  {
    label: '使用单位名称',
    field: 'employName',
    required: false,
    component: 'Input',
    show: false,
  },
  {
    label: '物业单位',
    field: 'tenementId',
    required: false,
    component: 'Select',
  },
  {
    label: '物业单位mc',
    field: 'tenementName',
    required: false,
    component: 'Input',
    show: false,
  },
  {
    label: '维保单位',
    field: 'maintenanceId',
    required: false,
    component: 'Select',
  },
  {
    label: '维保单位mc',
    field: 'maintenanceName',
    required: false,
    component: 'Input',
    show: false,
  },
  {
    label: '品牌',
    field: 'brand',
    required: false,
    component: 'Select',
    componentProps: {
      options: getDictOptions('eva_brand'),
    },
  },
  {
    label: '型号',
    field: 'model',
    required: false,
    component: 'Input',
  },
  {
    label: '额定载重(kg)',
    field: 'load',
    required: false,
    component: 'InputNumber',
  },
  {
    label: '额定速度(m/s)',
    field: 'speed',
    required: false,
    component: 'InputNumber',
  },
  {
    label: '层站门数',
    field: 'standNum',
    required: false,
    component: 'Input',
  },
  {
    label: '控制方式',
    field: 'controlMode',
    required: true,
    component: 'Select',
    componentProps: {
      options: [
        { label: '按钮', value: 1 },
        { label: '信号', value: 2 },
        { label: '集选', value: 3 },
        { label: '群控', value: 4 },
      ],
    },
  },
  {
    label: '安装日期',
    field: 'installDate',
    required: true,
    component: 'DatePicker',
    componentProps: {
      showTime: false,
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD',
    },
  },
  {
    label: '使用登记证号',
    field: 'useNumber',
    required: false,
    component: 'Input',
  },
  {
    label: '经度',
    field: 'lng',
    required: false,
    component: 'Input',

    componentProps: { disabled: true, placeholder: '请点击经纬度选择按钮选择经纬度' },
  },
  {
    label: '纬度',
    field: 'lat',
    required: false,
    component: 'Input',
    componentProps: { disabled: true, placeholder: '请点击经纬度选择按钮选择经纬度' },
  },
  {
    label: '经纬度获取',
    field: '',
    required: false,
    slot: 'getLatLng',
  },
  {
    label: '质监二维码',
    field: 'quality',
    required: false,
    component: 'Input',
  },
  {
    label: '年检日期',
    field: 'annualDate',
    required: false,
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      format: 'YYYY-MM-DD ',
      valueFormat: 'YYYY-MM-DD',
    },
  },
  {
    label: '下次年检',
    field: 'nextAnnual',
    required: false,
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      format: 'YYYY-MM-DD ',
      valueFormat: 'YYYY-MM-DD',
    },
  },
  {
    label: '电梯类型',
    field: 'type',
    required: false,
    component: 'Select',
    componentProps: {
      options: [
        { 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' },
        { label: '货梯', value: 10 },
      ],
    },
  },
  {
    label: '使用状态',
    field: 'useState',
    required: true,
    component: 'Select',
    componentProps: {
      options: [
        { label: '待用', value: 1 },
        { label: '在用', value: 2 },
        { label: '停用', value: 3 },
      ],
    },
  },

  {
    label: '救援站点',
    field: 'rescue',
    required: false,
    component: 'ApiSelect',
    defaultValue: '1',
    componentProps: {
      // api: ()=>{},
      labelField: 'name',
      valueField: 'id',
      placeholder: '请选择救援站点',
      afterFetch: (res) => {
        return res.rows;
      },
    },
  },
  {
    label: '使用单位内部编码',
    field: 'innerCode',
    required: false,
    component: 'Input',
  },
  {
    label: '产权单位',
    field: 'propertyUnit',
    required: false,
    component: 'Input',
  },
  {
    label: '制造单位',
    field: 'manufactureUnit',
    required: false,
    component: 'Input',
  },
  {
    label: '制造单位统一社会信用代码',
    field: 'socialCreditCode',
    required: false,
    component: 'Input',
  },
  {
    label: '出厂编号',
    field: 'factoryNumber',
    required: false,
    component: 'Input',
  },
  {
    label: '安装单位',
    field: 'installUnit',
    required: false,
    component: 'Input',
  },
  {
    label: '检验机构',
    field: 'inspectionBody',
    required: false,
    component: 'Input',
  },
  {
    label: '特检码',
    field: 'specialCode',
    required: false,
    component: 'Input',
  },
  {
    label: '生产批次',
    field: 'productionBatch',
    required: false,
    component: 'Input',
  },
  {
    label: '出厂日期',
    field: 'leaveFactoryDate',
    required: false,
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      format: 'YYYY-MM-DD ',
      valueFormat: 'YYYY-MM-DD',
    },
  },
  {
    label: '生产厂家',
    field: 'manufacturerId',
    required: true,
    component: 'ApiSelect',
    componentProps: {
      api: factoryInfoList,
      labelField: 'name',
      valueField: 'id',
      placeholder: '请选择生产厂家',
      afterFetch: (res) => {
        return res.rows;
      },
    },
  },
  {
    label: '节能类型',
    field: 'energyType',
    required: false,
    component: 'Select',
    componentProps: {
      options: getDictOptions('energy_type'),
    },
  },
  {
    label: '基站楼层',
    field: 'fundationFloor',
    required: false,
    component: 'Input',
  },
 
 
 
  {
    label: '有无机房',
    field: 'isMachine',
    required: false,
    component: 'Select',
    defaultValue: 1,
    componentProps: {
      options: [
        { label: '有', value: 1 },
        { label: '无', value: 0 },
      ],
    },
  },
  {
    label: '备注',
    field: 'remark',
    required: true,
    component: 'InputTextArea',
  },
];

export const accessFormSchemas: FormSchema[] = [
  {
    label: '配件名称',
    field: 'registerCode',
    component: 'Input',
  },
  {
    label: '配件编号',
    field: 'registerCode',
    component: 'Input',
  },
];
export const accessColumns: BasicColumn[] = [
  {
    title: '配件名称',
    dataIndex: 'name',
  },
  {
    title: '配件编号',
    dataIndex: 'code',
  },
  {
    title: '配件规格',
    dataIndex: 'specs',
  },
  {
    title: '配件数量',
    dataIndex: 'number',
  },
  {
    title: '备注',
    dataIndex: 'remark',
  },
];
export const accessModalSchemas: FormSchema[] = [
  {
    label: '主键id',
    field: 'id',
    required: false,
    component: 'Input',
    show: false,
  },
  {
    label: '配件名称',
    field: 'name',
    required: false,
    component: 'Input',
  },
  {
    label: '配件编号',
    field: 'code',
    required: false,
    component: 'Input',
  },
  {
    label: '配件类别',
    field: 'classic',
    required: false,
    component: 'Select',
    componentProps: {
      options: [
        {
          label: '曳引机',
          value: 1,
        },
        {
          label: '控制柜',
          value: 2,
        },
        {
          label: '层门锁',
          value: 3,
        },
        {
          label: '层门',
          value: 4,
        },
        {
          label: '轿厢防意外移动保护系统',
          value: 5,
        },
        {
          label: '轿门锁',
          value: 6,
        },
        {
          label: 'IC卡装置',
          value: 7,
        },
        {
          label: '缓冲器',
          value: 8,
        },
        {
          label: '安全钳',
          value: 9,
        },
        {
          label: '限速器',
          value: 10,
        },
        {
          label: '轿厢上行超速保护装置',
          value: 11,
        },
        {
          label: '电子元件的安全电路',
          value: 12,
        },
        {
          label: '悬挂装置',
          value: 13,
        },
        {
          label: '钢丝绳',
          value: 14,
        },
      ],
    },
  },
  {
    label: '配件规格',
    field: 'specs',
    required: false,
    component: 'Input',
  },
  {
    label: '配件数量',
    field: 'number',
    required: false,
    component: 'InputNumber',
  },
  {
    label: '备注',
    field: 'remark',
    required: false,
    component: 'InputTextArea',
  },
];
export const energyModalSchemas: FormSchema[] = [
  {
    label: '主键id',
    field: 'id',
    required: false,
    component: 'Input',
    show: false,
  },

  {
    label: '节能停梯间隔(s) 多个;分隔',
    field: 'remark',
    required: false,
    component: 'InputTextArea',
    colProps: { span: 24 },
  },
];
