import { BasicColumn, FormSchema } from '/@/components/Table';
import { getTown } from '/@/api/common/api';

export const columns: BasicColumn[] = [
  {
    title: '评审机构',
    dataIndex: 'psjg',
  },
  {
    title: '联系人',
    dataIndex: 'lxr',
  },
  {
    title: '手机号码',
    dataIndex: 'lxdh',
  },
  {
    title: '邮箱',
    dataIndex: 'email',
  },
  {
    title: '邮编',
    dataIndex: 'yzbm',
  },
  {
    title: '登陆账户',
    dataIndex: 'userLogin',
  }
];


export const searchFormSchema: FormSchema[] = [
  {
    label: '行政区(市)',
    field: 'xzqy',
    component: 'ApiSelect',
    componentProps: ({ formModel, formActionType }) => {
      return {
        api: getTown,
        params: 440000, // 行政区划编码
        labelField: 'name',
        valueField: 'id',
      };
    },
  },
  {
    label: '评审机构',
    field: 'psjg',
    component: 'Input',
  },
  {
    label: '手机号码',
    field: 'lxdh',
    component: 'Input',
  },
  {
    label: '登陆账户',
    field: 'userLogin',
    component: 'Input',
  },
];

export const formSchema: formSchema[] = [
  {
    label: '主键',
    field: 'id',
    component: 'Input',
    ifShow:false,
  },
  {
    label: '评审机构',
    field: 'psjg',
    component: 'Input',
    required:true,
  },
  {
    label: '行政区(市)',
    field: 'xzqy',
    component: 'ApiSelect',
    required:true,
    componentProps: ({ formModel, formActionType }) => {
      return {
        api: getTown,
        params: 440000, // 行政区划编码
        labelField: 'name',
        valueField: 'id',
      };
    },
  },
  {
    label: '联系人',
    field: 'lxr',
    required:true,
    component: 'Input',
  },
  {
    label: '手机号码',
    field: 'lxdh',
    required:true,
    component: 'Input',
    rules: [{ required: false, message: '请输入正确的手机号', pattern: /^1[3456789]\d{9}$/ }],
  },
  {
    label: '传真',
    field: 'fax',
    required:true,
    component: 'Input',
  },
  {
    label: '邮箱',
    field: 'email',
    required:true,
    component: 'Input',
    rules: [{ required: false, message: '请输入正确的邮箱', pattern: /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/ }],
  },
  {
    label: '邮箱编码',
    required:true,
    field: 'yzbm',
    component: 'Input',
  },
]
