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 { customComponents } from '../../tool/build/core/formItemConfig';
export const tableData = [
  [
    { badName: '关门超时', happendNum: 40, evaNum: 1059 },
    { badName: '重复开门', happendNum: 27, evaNum: 89 },
    { badName: '启动异常', happendNum: 19, evaNum: 73 },
    { badName: '停梯异常', happendNum: 3, evaNum: 6 },
    { badName: '行梯异常', happendNum: 1, evaNum: 1 },
    { badName: '检修模式', happendNum: 1, evaNum: 1 },
    { badName: '电梯恢复自动运行模式', happendNum: 0, evaNum: 0 },
    { badName: '异常震动', happendNum: 0, evaNum: 0 },
    { badName: '关门异常', happendNum: 0, evaNum: 0 },
    { badName: '开门超时', happendNum: 0, evaNum: 0 },
    { badName: '拍击报警', happendNum: 0, evaNum: 0 },
    { badName: '关门不走梯', happendNum: 0, evaNum: 0 },
  ],
];
export const formSchemas: FormSchema[] = [
  {
    label: '物业单位',
    field: 'tenementName',
    required: false,
    component: 'Input',
  },
  {
    label: '维保单位',
    field: 'maintenanceName',
    required: false,
    component: 'Input',
  },
  {
    label: '品牌',
    field: 'brand',
    component: 'Select',
    componentProps: {
      options: getDictOptions('eva_brand'),
    },
  },
];

export const columns: BasicColumn[] = [
  {
    title: '品牌',
    dataIndex: 'brand',
    width: 80,
  },
  {
    title: '数量',
    dataIndex: 'brandTotal',
    width: 80,
  },
  {
    title: '占比',
    dataIndex: 'ratio',
    width: 80,
  },
];

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: '设备代码',
    field: 'deviceCode',
    required: false,
    component: 'Input',
  },
  {
    label: '电梯编号',
    field: 'elevatorNum',
    required: true,
    component: 'Input',
  },
  {
    label: '电梯名称',
    field: 'elevatorName',
    required: true,
    component: 'Input',
  },
  {
    label: '电梯地址',
    field: 'elevatorAddress',
    required: false,
    component: 'Input',
  },
  {
    label: '进口设备代理商',
    field: 'inputDevice',
    required: false,
    component: 'Input',
  },
  {
    label: '行政区域编号',
    field: 'areaCode',
    required: false,
    component: 'TreeSelect',
    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: 'ApiSelect',
    componentProps: {
      api: buildingInfoList,
      labelField: 'name',
      valueField: 'id',
      placeholder: '请选择楼宇',
      afterFetch: (res) => {
        return res.rows;
      },
    },
  },
  {
    label: '小区',
    field: 'houseId',
    required: false,

    component: 'ApiSelect',
    componentProps: {
      api: houseInfoList,
      labelField: 'name',
      valueField: 'id',
      placeholder: '请选择小区',
      afterFetch: (res) => {
        return res.rows;
      },
    },
  },
  {
    label: '使用场景',
    field: 'useScenario',
    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: '使用单位',
    field: 'employId',
    required: false,
    component: 'Input',
  },
  {
    label: '物业单位',
    field: 'tenementId',
    required: false,
    component: 'ApiSelect',
    componentProps: {
      api: infoList,
      labelField: 'name',
      valueField: 'id',
      placeholder: '请选择物业',
      afterFetch: (res) => {
        return res.rows;
      },
    },
  },
  {
    label: '维保单位',
    field: 'maintenanceId',
    required: false,
    component: 'ApiSelect',
    componentProps: {
      api: maintenanceInfoList,
      labelField: 'name',
      valueField: 'id',
      placeholder: '请选择维保单位',
      afterFetch: (res) => {
        return res.rows;
      },
    },
  },
  {
    label: '品牌',
    field: 'brand',
    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: 'kone（通力）', value: 8 },
        { label: '蒂森克虏伯', value: 9 },
      ],
    },
  },
  {
    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: false,
    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: true,
      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',
  },
  {
    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: false,
    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: [
        { label: '节能', value: 1 },
        { label: '非节能', value: 2 },
      ],
    },
  },
  {
    label: '基站楼层',
    field: 'fundationFloor',
    required: false,
    component: 'Input',
  },
  {
    label: '自动扶梯名义速度(m/s)',
    field: 'evaSpeed',
    required: false,
    component: 'InputNumber',
  },
  {
    label: '自动扶梯提升高度(m)',
    field: 'evaHeight',
    required: false,
    component: 'InputNumber',
  },
  {
    label: '自动扶梯倾斜角(度)',
    field: 'evaTrangle',
    required: false,
    component: 'InputNumber',
  },
  {
    label: '自动扶梯名义宽度(m)',
    field: 'evaWidth',
    required: false,
    component: 'InputNumber',
  },
  {
    label: '自动人行道名义速度(m/s)',
    field: 'autoEvaSpeed',
    required: false,
    component: 'InputNumber',
  },
  {
    label: '自动人行道使用区段长度(m)',
    field: 'autoEvaLength',
    required: false,
    component: 'InputNumber',
  },
  {
    label: '自动人行道倾斜角(度)',
    field: 'autoEvaTrangle',
    required: false,
    component: 'InputNumber',
  },
  {
    label: '	自动人行道名义宽度(m)',
    field: 'autoEvaWidth',
    required: false,
    component: 'InputNumber',
  },
  {
    label: '有无机房',
    field: 'hasComputerHouse',
    required: false,
    component: 'Select',
    defaultValue: '1',
    componentProps: {
      options: [
        { label: '有', value: 1 },
        { label: '无', value: 2 },
      ],
    },
  },
  {
    label: '备注',
    field: 'remark',
    required: true,
    component: 'InputTextArea',
  },
];
