import { BasicColumn } from '/@/components/Table/src/types/table';
import { FormSchema } from '/@/components/Form';

export function getBasicColumns(): BasicColumn[] {
  return [
    {
      title: '测站类型',
      dataIndex: 'dtype',
      key: 'dtype',
    },
    {
      title: '遥测数据库表名',
      dataIndex: 'yctablename',
      key: 'yctablename',
    },
    {
      title: '遥测站码字段',
      dataIndex: 'ycstnm',
      key: 'ycstnm',
    },
    {
      title: '遥测站码字段类型',
      dataIndex: 'ycstcdtype',
      key: 'ycstcdtype',
    },
    {
      title: '遥测时间字段',
      dataIndex: 'yctimename',
      key: 'yctimename',
    },
    {
      title: '遥测值字段',
      dataIndex: 'ycvaluename',
      key: 'ycvaluename',
    },
    {
      title: '预报数据库表名',
      dataIndex: 'ybtablename',
      key: 'ybtablename',
    },
    {
      title: '预报站码字段',
      dataIndex: 'ybstnm',
      key: 'ybstnm',
    },
    {
      title: '预报站码字段类型',
      dataIndex: 'ybstcdtype',
      key: 'ybstcdtype',
    },
    {
      title: '预报时间字段',
      dataIndex: 'ybtimename',
      key: 'ybtimename',
    },
    {
      title: '预报值字段',
      dataIndex: 'ybvaluename',
      key: 'ybvaluename',
    },
    {
      title: '序号',
      dataIndex: 'ordern',
      key: 'ordern',
    },
  ];
}
export const tenantFormSchema: FormSchema[] = [
  {
    field: 'dtype',
    label: '测站类型',
    component: 'Input',
    colProps: { span: 22 },
    required: true,
    componentProps: {
      maxLength: 30,
      max: 30,
      disabled: true,
    },
  },
  {
    field: 'yctablename',
    label: '遥测数据库表名',
    component: 'Input',
    colProps: { span: 22 },
    required: true,
    componentProps: {
      maxLength: 30,
      max: 30,
    },
    dynamicRules: () => {
      return [
        {
          required: true,
          validator: (_, value) => {
            if (/[\u4E00-\u9FA5]/g.test(value) || /^[0-9]+.?[0-9]*$/g.test(value)) {
              return Promise.reject('只可输入字母、不能输入汉字!');
            }
            return Promise.resolve();
          },
        },
      ];
    },
  },
  {
    field: 'ycstnm',
    label: '遥测站码字段',
    component: 'Input',
    colProps: { span: 22 },
    required: true,
    componentProps: {
      maxLength: 30,
      max: 30,
    },
    dynamicRules: () => {
      return [
        {
          required: true,
          validator: (_, value) => {
            if (/[\u4E00-\u9FA5]/g.test(value) || /^[0-9]+.?[0-9]*$/g.test(value)) {
              return Promise.reject('只可输入字母、不能输入汉字!');
            }
            return Promise.resolve();
          },
        },
      ];
    },
  },
  {
    field: 'ycstcdtype',
    label: '遥测站码字段类型',
    component: 'Input',
    colProps: { span: 22 },
    required: true,
    componentProps: {
      maxLength: 30,
      max: 30,
    },
    dynamicRules: () => {
      return [
        {
          required: true,
          validator: (_, value) => {
            if (/[\u4E00-\u9FA5]/g.test(value) || /^[0-9]+.?[0-9]*$/g.test(value)) {
              return Promise.reject('只可输入字母、不能输入汉字!');
            }
            return Promise.resolve();
          },
        },
      ];
    },
  },
  {
    field: 'yctimename',
    label: '遥测时间字段',
    component: 'Input',
    colProps: { span: 22 },
    required: true,
    componentProps: {
      maxLength: 30,
      max: 30,
    },
    dynamicRules: () => {
      return [
        {
          required: true,
          validator: (_, value) => {
            if (/[\u4E00-\u9FA5]/g.test(value) || /^[0-9]+.?[0-9]*$/g.test(value)) {
              return Promise.reject('只可输入字母、不能输入汉字!');
            }
            return Promise.resolve();
          },
        },
      ];
    },
  },
  {
    field: 'ycvaluename',
    label: '遥测值字段',
    component: 'Input',
    colProps: { span: 22 },
    required: true,
    componentProps: {
      maxLength: 30,
      max: 30,
    },
    dynamicRules: () => {
      return [
        {
          required: true,
          validator: (_, value) => {
            if (/[\u4E00-\u9FA5]/g.test(value) || /^[0-9]+.?[0-9]*$/g.test(value)) {
              return Promise.reject('只可输入字母、不能输入汉字!');
            }
            return Promise.resolve();
          },
        },
      ];
    },
  },
  {
    field: 'ybtablename',
    label: '预报数据库表名',
    component: 'Input',
    colProps: { span: 22 },
    required: true,
    componentProps: {
      maxLength: 30,
      max: 30,
    },
    dynamicRules: () => {
      return [
        {
          required: true,
          validator: (_, value) => {
            if (/[\u4E00-\u9FA5]/g.test(value) || /^[0-9]+.?[0-9]*$/g.test(value)) {
              return Promise.reject('只可输入字母、不能输入汉字!');
            }
            return Promise.resolve();
          },
        },
      ];
    },
  },
  {
    field: 'ybstnm',
    label: '预报站码字段',
    component: 'Input',
    colProps: { span: 22 },
    required: true,
    componentProps: {
      maxLength: 30,
      max: 30,
    },
    dynamicRules: () => {
      return [
        {
          required: true,
          validator: (_, value) => {
            if (/[\u4E00-\u9FA5]/g.test(value) || /^[0-9]+.?[0-9]*$/g.test(value)) {
              return Promise.reject('只可输入字母、不能输入汉字!');
            }
            return Promise.resolve();
          },
        },
      ];
    },
  },
  {
    field: 'ybstcdtype',
    label: '预报站码字段类型',
    component: 'Input',
    colProps: { span: 22 },
    required: true,
    componentProps: {
      maxLength: 30,
      max: 30,
    },
    dynamicRules: () => {
      return [
        {
          required: true,
          validator: (_, value) => {
            if (/[\u4E00-\u9FA5]/g.test(value) || /^[0-9]+.?[0-9]*$/g.test(value)) {
              return Promise.reject('只可输入字母、不能输入汉字!');
            }
            return Promise.resolve();
          },
        },
      ];
    },
  },
  {
    field: 'ybtimename',
    label: '预报时间字段',
    component: 'Input',
    colProps: { span: 22 },
    required: true,
    componentProps: {
      maxLength: 30,
      max: 30,
    },
    dynamicRules: () => {
      return [
        {
          required: true,
          validator: (_, value) => {
            if (/[\u4E00-\u9FA5]/g.test(value) || /^[0-9]+.?[0-9]*$/g.test(value)) {
              return Promise.reject('只可输入字母、不能输入汉字!');
            }
            return Promise.resolve();
          },
        },
      ];
    },
  },
  {
    field: 'ybvaluename',
    label: '预报值字段',
    component: 'Input',
    colProps: { span: 22 },
    required: true,
    componentProps: {
      maxLength: 30,
      max: 30,
    },
    dynamicRules: () => {
      return [
        {
          required: true,
          validator: (_, value) => {
            if (/[\u4E00-\u9FA5]/g.test(value) || /^[0-9]+.?[0-9]*$/g.test(value)) {
              return Promise.reject('只可输入字母、不能输入汉字!');
            }
            return Promise.resolve();
          },
        },
      ];
    },
  },
  {
    field: 'ordern',
    label: '序号',
    component: 'InputNumber',
    colProps: { span: 22 },
    required: true,
    componentProps: {
      maxLength: 30,
      max: 30,
      disabled: true,
    },
  },
];
