import type { VbenFormProps } from '#/adapter/form';

import { MEDICAL_RECORD_FIELD_OPTIONS, STATUS_OPTIONS } from './constants';

/** 词条表单 */
export function buildEntryFormProps(): VbenFormProps {
  return {
    wrapperClass: 'grid-cols-12',
    commonConfig: {
      formItemClass: 'col-span-12',
      componentProps: { class: 'w-full' },
    },
    layout: 'horizontal',
    schema: [
      {
        component: 'VbenInput',
        fieldName: 'id',
        label: 'ID',
        dependencies: { show: false, triggerFields: ['id'] },
      },
      {
        component: 'VbenSelect',
        fieldName: 'field_code',
        label: '所属字段',
        rules: 'selectRequired',
        componentProps: { options: MEDICAL_RECORD_FIELD_OPTIONS },
      },
      {
        component: 'VbenInput',
        fieldName: 'title',
        label: '词条名称',
        rules: 'required',
        componentProps: { placeholder: '列表展示名称' },
      },
      {
        component: 'VbenInput',
        fieldName: 'content',
        label: '词条正文',
        componentProps: { type: 'textarea', rows: 4, placeholder: '选中后写入文本区' },
        defaultValue: '',
      },
      {
        component: 'VbenInput',
        fieldName: 'remark',
        label: '临床意义',
        componentProps: { placeholder: '可选' },
        defaultValue: '',
      },
      {
        component: 'InputNumber',
        fieldName: 'sort',
        label: '排序',
        formItemClass: 'col-span-6',
        componentProps: { min: 0 },
        defaultValue: 0,
      },
      {
        component: 'VbenSelect',
        fieldName: 'status',
        label: '状态',
        formItemClass: 'col-span-6',
        componentProps: { options: STATUS_OPTIONS },
        defaultValue: 1,
      },
    ],
    showDefaultActions: false,
  };
}
