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

export function getBasicColumns(): BasicColumn[] {
  return [
    {
      title: '测站类型',
      dataIndex: 'd_name',
      key: 'd_name',
    },
    {
      title: '遥测站码',
      dataIndex: 'ycstcd',
      key: 'ycstcd',
    },
    {
      title: '预报站码',
      dataIndex: 'ybstcd',
      key: 'ybstcd',
    },
    {
      title: '站名',
      dataIndex: 'stnm',
      key: 'stnm',
    },
    // {
    //   title: '排序',
    //   dataIndex: 'ordern',
    //   key: 'ordern',
    // },
    {
      title: '阀值',
      dataIndex: 'maxvalue',
      key: 'maxvalue',
    },
    
  ];
}
export const tenantFormSchema: FormSchema[] = [
  {
    field: 'd_name',
    label: '测站类型',
    component: 'ApiSelect',
    colProps: { span: 22 },
    required: true,
    show: false,
    componentProps: {
      api: getStationType,
      labelField: 'd_name',
      valueField: 'd_type',
      resultField: 'data',
    },
  },
  {
    field: 'ordern',
    label: '测站类型',
    component: 'Input',
    colProps: { span: 22 },
    required: true,
    show: false,
  },
  {
    field: 'd_type',
    label: '测站类型',
    component: 'ApiSelect',
    colProps: { span: 22 },
    required: true,
    componentProps: ({ formActionType }) => {
      const { setFieldsValue } = formActionType;
      return{
        api: getStationType,
      labelField: 'd_name',
      valueField: 'd_type',
      resultField: 'data',
      onChange: (e, item) => {
        setFieldsValue({d_name:item.label});
      },
      }
    },
  },
  {
    field: 'ycstcd',
    label: '遥测站码',
    component: 'InputNumber',
    colProps: { span: 22 },
    required: true,
    componentProps: {
      maxLength: 30,
    },
  },
  {
    field: 'ybstcd',
    label: '预报站码',
    component: 'InputNumber',
    colProps: { span: 22 },
    required: true,
    componentProps: {
      maxLength: 30,
    },
  },
  {
    field: 'stnm',
    label: '站名',
    component: 'Input',
    colProps: { span: 22 },
    required: true,
    componentProps: {
      maxLength: 30,
    },
  },
  {
    field: 'maxvalue',
    label: '阀值',
    component: 'InputNumber',
    colProps: { span: 22 },
    required: true,
    componentProps: {
      maxLength: 30,
    },
  },
  
];
