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

const nameTypeOptions = [
  { label: '官方全称', value: 1 },
  { label: '曾用名', value: 2 },
  { label: '别名', value: 3 },
  { label: '英文名称', value: 4 },
];

export const columns: BasicColumn[] = [
  {
    title: '学校ID',
    align: 'center',
    dataIndex: 'schoolId',
  },
  {
    title: '名称',
    align: 'center',
    dataIndex: 'name',
  },
  {
    title: '名称类型',
    align: 'center',
    dataIndex: 'nameType',
    customRender: ({ text }) => {
      const found = nameTypeOptions.find((o) => o.value === text || o.value === Number(text));
      return found?.label || text;
    },
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    label: '学校ID',
    field: 'schoolId',
    component: 'InputNumber',
    colProps: { span: 6 },
  },
  {
    label: '名称',
    field: 'name',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: '名称类型',
    field: 'nameType',
    component: 'Select',
    colProps: { span: 6 },
    componentProps: {
      options: nameTypeOptions,
    },
  },
];

export const formSchema: FormSchema[] = [
  {
    label: '学校ID',
    field: 'schoolId',
    component: 'InputNumber',
    required: true,
  },
  {
    label: '名称',
    field: 'name',
    component: 'Input',
    required: true,
  },
  {
    label: '名称类型',
    field: 'nameType',
    component: 'Select',
    required: true,
    componentProps: {
      options: nameTypeOptions,
    },
  },
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

export function getBpmFormSchema(_formData): FormSchema[] {
  return formSchema;
}

