import { BasicColumn } from '@/components/Table';
import { FormSchema } from '@/components/Form';
import { projectInfoList } from '@/api/basicInfo/projectsInfo';

export const formSchemas: FormSchema[] = [
  {
    label: '组织',
    field: 'organizationId',
    component: 'ApiSelect',
    componentProps: {
      api: projectInfoList,
      labelField: 'name',
      valueField: 'id',
      placeholder: '请选择项目',
      afterFetch: (res) => {
        return res.rows;
      },
    },
  },

  {
    label: '单位名称',
    field: 'name',
    component: 'Input',
  },
];

export const columns: BasicColumn[] = [
  {
    title: '主键id',
    dataIndex: 'id',
    ifShow: false,
  },

  {
    title: '单位名称',
    dataIndex: 'name',
  },
  {
    title: '单位地址',
    dataIndex: 'address',
  },

  {
    title: '联系人',
    dataIndex: 'contacts',
  },
  {
    title: '联系电话',
    dataIndex: 'phone',
  },

  {
    title: '组织',
    dataIndex: 'organizationId',
  },
];

export const modalSchemas: FormSchema[] = [
  {
    label: '主键id',
    field: 'id',
    required: false,
    component: 'Input',
    show: false,
  },

  {
    label: '项目',
    field: 'deptId',
    required: true,
    component: 'TreeSelect',
    helpMessage: ['注意绑定的角色要带相应的部门权限, 否则无法正常登录'],
  },
  {
    label: '单位名称',
    field: 'name',
    required: true,
    component: 'Input',
  },
  {
    label: '单位编号',
    field: 'code',
    required: true,
    component: 'Input',
  },
  {
    label: '单位地址',
    field: 'address',
    required: true,
    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: 'contacts',
    required: true,
    component: 'Input',
  },
  {
    label: '联系电话',
    field: 'phone',
    required: true,
    component: 'Input',
  },
  {
    label: '组织机构代码',
    field: 'institutionCode',
    required: false,
    component: 'Input',
  },
  {
    label: '电梯安全管理员',
    field: 'safetyManager',
    required: false,
    component: 'Input',
  },
  {
    label: '管理员手机',
    field: 'managerPhone',
    required: false,
    component: 'Input',
  },
  {
    label: '备注',
    field: 'remark',
    required: false,
    component: 'Input',
  },
];
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 },
  },
];
