import { BasicColumn } from '@/components/Table';
import { FormSchema } from '@/components/Form';
import { infoList } from '@/api/basicInfo/tenement';
import { maintenanceInfoList } from '@/api/basicInfo/maintenance';
import { projectInfoList } from '@/api/basicInfo/projectsInfo';
import { relevancyCodeList } from '@/api/codeManage/codeRelationShip';
import { blackBoxInfoList } from '@/api/blackBoxManage/blackBoxTim';
import { vidiconInfoList } from '@/api/netCamera/netCameraManage';

export const formSchemas: FormSchema[] = [
  {
    label: '注册代码',
    field: 'registerCode',
    component: 'Input',
  },
  {
    label: '电梯名称',
    field: 'elevatorName',
    component: 'Input',
  },
  {
    label: '电梯地址',
    field: 'elevatorAddress',
    component: 'Input',
  },
  {
    label: '物业单位',
    field: 'tenementName',
    component: 'Input',
  },
  {
    label: '维保单位',
    field: 'maintenanceName',
    component: 'Input',
  },
  // {
  //   label: '项目',
  //   field: 'projectId',
  //   component: 'ApiSelect',
  //   componentProps: {
  //     api: projectInfoList,
  //     labelField: 'name',
  //     valueField: 'id',
  //     placeholder: '请选择项目',
  //     afterFetch: (res) => {
  //       return res.rows;
  //     },
  //   },
  // },
  {
    label: '是否在线',
    field: 'isLine',
    component: 'Select',
    componentProps: {
      options: [
        { label: '是', value: 1 },
        { label: '否', value: 0 },
      ],
    },
  },
  {
    label: '是否关联黑匣子',
    field: 'isBlackBox',
    component: 'Select',
    componentProps: {
      options: [
        { label: '是', value: 1 },
        { label: '否', value: 0 },
      ],
    },
  },

  {
    label: '是否关联网络摄像机',
    field: 'isCamera',
    component: 'Select',
    componentProps: {
      options: [
        { label: '是', value: 1 },
        { label: '否', value: 0 },
      ],
    },
  },
];

export const columns: BasicColumn[] = [
  {
    title: '主键id',
    dataIndex: 'id',
    ifShow: false,
  },
  {
    title: '注册代码',
    dataIndex: 'registerCode',
  },
  {
    title: '电梯名称',
    dataIndex: 'elevatorName',
  },
  {
    title: '电梯地址',
    dataIndex: 'elevatorAddress',
  },
  {
    title: '物业单位',
    dataIndex: 'tenementName',
  },
  {
    title: '维保单位',
    dataIndex: 'maintenanceName',
  },
  {
    title: '项目',
    dataIndex: 'deptName',
  },
  // {
  //   title: '设备编号',
  //   dataIndex: 'deviceCode',
  // },
  {
    title: '关联二维码',
    dataIndex: 'qrCode',
  },
  {
    title: '关联黑匣子',
    dataIndex: 'blackBoxCode',
  },
  // {
  //   title: '关联梯截屏',
  //   dataIndex: 'screenCode',
  // },

  {
    title: '关联网络摄像机',
    dataIndex: 'cameraCode',
  },
  // {
  //   title: '最后在线时间起止',
  //   dataIndex: 'finallyTime',
  // },

  // {
  //   title: '关联黑匣子',
  //   dataIndex: 'isBlackBox',
  // },
  // {
  //   title: '关联广告屏',
  //   dataIndex: 'isScreen',
  // },
  // {
  //   title: '关联网络摄像机',
  //   dataIndex: 'isCamera',
  // },
  // {
  //   title: '关联梯米',
  //   dataIndex: 'isTimmy',
  // },
  // {
  //   title: '关联二维码',
  //   dataIndex: 'isQrcode',
  // },
];

export const modalSchemas: FormSchema[] = [
  {
    label: '主键id',
    field: 'id',
    required: false,
    component: 'Input',
    show: false,
  },
  {
    label: '项目',
    field: 'deptId',
    required: false,
    component: 'TreeSelect',
    helpMessage: ['注意绑定的角色要带相应的部门权限, 否则无法正常登录'],
  },
  {
    label: '注册代码',
    field: 'registerCode',
    required: true,
    component: 'Input',
  },
  {
    label: '二维码编号',
    field: 'qrCode',
    required: true,
    component: 'Input',
  },
  {
    label: '电梯名称',
    field: 'elevatorName',
    required: true,
    component: 'Input',
  },
  {
    label: '电梯地址',
    field: 'elevatorAddress',
    required: true,
    component: 'Input',
  },
  {
    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: 'deptId',
  //   required: true,
  //   component: 'TreeSelect',
  //   helpMessage: ['注意绑定的角色要带相应的部门权限, 否则无法正常登录'],
  // },
  {
    label: '设备编号',
    field: 'deviceCode',
    required: true,
    component: 'Input',
  },
  {
    label: '最后在线时间',
    field: 'finallyTime',
    required: true,
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
  },
  // {
  //   label: '组织',
  //   field: 'organizationId',
  //   required: false,
  //   component: 'Input',
  // },
  {
    label: '是否关联黑匣子',
    field: 'isBlackBox',
    required: false,
    component: 'Select',
    componentProps: {
      options: [
        { label: '是', value: 1 },
        { label: '否', value: 0 },
      ],
    },
  },

  {
    label: '是否关联网络摄像机',
    field: 'isCamera',
    required: false,
    component: 'Select',
    componentProps: {
      options: [
        { label: '是', value: 1 },
        { label: '否', value: 0 },
      ],
    },
  },
  {
    label: '是否关联梯米',
    field: 'isTimmy',
    required: false,
    component: 'Select',
    componentProps: {
      options: [
        { label: '是', value: 1 },
        { label: '否', value: 0 },
      ],
    },
  },
  {
    label: '是否关联二维码',
    field: 'isQrcode',
    required: false,
    component: 'Select',
    componentProps: {
      options: [
        { label: '是', value: 1 },
        { label: '否', value: 0 },
      ],
    },
  },
];
export const modalRelationSchemas: FormSchema[] = [
  {
    label: '主键id',
    field: 'id',
    required: false,
    component: 'Input',
    show: false,
  },
  {
    label: '关联二维码',
    field: 'qrCode',
    required: true,
    component: 'ApiSelect',
    componentProps: {
      api: relevancyCodeList,
      labelField: 'qrCode',
      valueField: 'id',
      placeholder: '请选择关联二维码',
      afterFetch: (res) => {
        return res.rows;
      },
    },
  },
  {
    label: '关联黑匣子TIM',
    field: 'blackBoxCode',
    required: true,
    component: 'ApiSelect',
    componentProps: {
      api: blackBoxInfoList,
      labelField: 'deviceName',
      valueField: 'id',
      placeholder: '请选择黑匣子TIM',
      afterFetch: (res) => {
        return res.rows;
      },
    },
  },
  {
    label: '关联网络摄像机',
    field: 'cameraCode',
    required: true,
    component: 'ApiSelect',
    componentProps: {
      api: vidiconInfoList,
      labelField: 'channelName',
      valueField: 'id',
      placeholder: '请选择网络摄像机',
      afterFetch: (res) => {
        return res.rows;
      },
    },
  },
  {
    label: '关联梯载屏',
    field: 'screenCode',
    required: false,
    component: 'ApiSelect',
    componentProps: {
      labelField: 'name',
      valueField: 'id',
      placeholder: '请选择关联梯载屏',
      afterFetch: (res) => {
        return res.rows;
      },
    },
  },
];
