import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';

export const columns: BasicColumn[] = [
  {
    title: '接口名称',
    dataIndex: 'jkmc',
  },
  {
    title: '接口地址',
    dataIndex: 'jkdz',
  },
  {
    title: '接口状态',
    dataIndex: 'jkStatus',
    customRender: ({ text }) => {
      if (text === 1) {
        return '开启';
      } else {
        return '关闭';
      }
    },
  },
  {
    title: '创建时间',
    dataIndex: 'tsamp',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    label: '接口名称',
    field: 'jkmc',
    component: 'Input',
  },
  {
    label: '接口状态',
    field: 'jkStatus',
    component: 'Select',
    componentProps: {
      options: [
        { label: '开启', value: 1 },
        { label: '关闭', value: 0 },
      ],
    },
  },
];

export const formSchema: FormSchema[] = [
  // TODO 主键隐藏字段，目前写死为ID
  { label: '', field: 'id', component: 'Input', show: false },
  {
    label: '接口名称',
    field: 'jkmc',
    component: 'Input',
    required: true,
  },
  {
    label: '接口地址',
    field: 'jkdz',
    component: 'Input',
    required: true,
  },
  {
    label: '接口状态',
    field: 'jkStatus',
    component: 'RadioGroup',
    defaultValue: 1,
    componentProps: {
      options: [
        { label: '开启', value: 1 },
        { label: '关闭', value: 0 },
      ],
    },
    required: true,
  },
];

export const formKeySchema: FormSchema[] = [
  {
    label: '行政区code',
    field: 'code',
    component: 'Input',
    required: true,
  },
];
