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

const IsPadEnum = [
  { title: '否', value: 'NO' },
  { title: '是', value: 'YES' },
]

export const columns: BasicColumn[] = [
  {
    title: '机型名称',
    dataIndex: 'name',
    width: 100,
    slots: { customRender: 'name' }
  },
  {
    title: '厂家',
    dataIndex: 'manufacturer',
    width: 100,
  },
  {
    title: '系统',
    dataIndex: 'operationSystem',
    width: 100,
  },
  {
    title: '版本',
    dataIndex: 'version',
    width: 70,
  },
  {
    title: '是否Pad',
    dataIndex: 'isPad',
    width: 60,
    customRender: ({ text }) => {
      const option: any = IsPadEnum.find(item => item.value === text)
      return option ? option.title : text
    }
  },
  {
    title: '创建人',
    dataIndex: 'editorName',
    width: 80,
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 100,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'name',
    label: '机型名称',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    field: 'manufacturer',
    label: '厂家',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    field: 'isPad',
    label: '是否Pad',
    component: 'Select',
    componentProps: {
      options: [
        { label: '否', value: 'NO' },
        { label: '是', value: 'YES' },
      ],
    },
    colProps: { span: 8 },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'name',
    label: '机型名称',
    required: true,
    component: 'Input',
  },
  {
    field: 'manufacturer',
    label: '厂家',
    required: false,
    component: 'Input',
  },
  {
    field: 'operationSystem',
    label: '系统',
    required: true,
    component: 'Input',
  },
  {
    field: 'version',
    label: '版本',
    required: false,
    component: 'Input',
  },
  {
    field: 'isPad',
    label: '是否Pad',
    component: 'RadioButtonGroup',
    defaultValue: 'NO',
    componentProps: {
      options: [
        { label: '否', value: 'NO' },
        { label: '是', value: 'YES' },
      ],
    },
  },
];
