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',
  },
  {
    label: '联系人',
    field: 'contacts',
    component: 'Input',
  },
  {
    label: '联系电话',
    field: 'contactsPhone',
    component: 'Input',
  },
];

export const columns: BasicColumn[] = [
  {
    title: '主键id',
    dataIndex: 'id',
    ifShow: false,
  },
  // {
  //   title: '组织',
  //   dataIndex: 'organizationId',
  // },
  {
    title: '单位名称',
    dataIndex: 'name',
  },
  {
    title: '联系人',
    dataIndex: 'contacts',
  },
  {
    title: '联系电话',
    dataIndex: 'contactsPhone',
  },
  {
    title: '行政区域',
    dataIndex: 'areaCode',
  },
  {
    title: '地址',
    dataIndex: 'address',
  },
];

export const modalSchemas: FormSchema[] = [
  {
    label: '主键id',
    field: 'id',
    required: false,
    component: 'Input',
    show: false,
  },
  {
    label: '项目',
    field: 'deptId',
    required: true,
    component: 'TreeSelect',
    helpMessage: ['注意绑定的角色要带相应的部门权限, 否则无法正常登录'],
  },
  {
    label: '单位编码',
    field: 'code',
    required: true,
    component: 'Input',
  },
  {
    label: '单位名称',
    field: 'name',
    required: true,
    component: 'Input',
  },
  {
    label: '联系人',
    field: 'contacts',
    required: true,
    component: 'Input',
  },
  {
    label: '联系电话',
    field: 'contactsPhone',
    required: true,
    component: 'Input',
  },
  {
    label: '行政区域',
    field: 'areaCode',
    required: false,
    component: 'TreeSelect',
    componentProps: {
      treeData: [
        {
          label: '行政区域',
          value: '100000',
          children: [
            {
              label: '湖北省',
              value: '420000',
              children: [
                {
                  label: '武汉市',
                  value: '420100',
                  children: [
                    {
                      label: '江夏区',
                      value: '420115',
                    },
                  ],
                },
              ],
            },
          ],
        },
      ],
    },
  },
  {
    label: '地址',
    field: 'address',
    required: true,
    component: 'Input',
  },
];
