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

/**
 * 科室新增/编辑弹窗表单
 * pid 的选项来自接口（仅一级科室可作为父级），在 modal.vue 的 onOpenChange 里
 * 通过 formApi.updateSchema 动态注入，禁止在此写死
 */
export const modalFormProps: VbenFormProps = {
  wrapperClass: 'grid-cols-12',
  commonConfig: {
    formItemClass: 'col-span-12',
    // 所有表单项
    componentProps: {
      class: 'w-full',
    },
  },
  layout: 'horizontal',
  showDefaultActions: false,
  schema: [
    {
      component: 'VbenInput',
      fieldName: 'id',
      label: 'ID',
      dependencies: {
        show: false,
        triggerFields: ['id'],
      },
    },
    {
      component: 'VbenInput',
      componentProps: {
        placeholder: '请输入科室名称',
        maxlength: 50,
      },
      fieldName: 'name',
      label: '科室名称',
      rules: 'required',
    },
    {
      component: 'Select',
      componentProps: {
        placeholder: '请选择父级科室（不选则为一级科室）',
        options: [],
        showSearch: true,
        optionFilterProp: 'label',
      },
      defaultValue: 0,
      fieldName: 'pid',
      label: '父级科室',
      rules: 'selectRequired',
    },
    {
      component: 'VbenInput',
      componentProps: {
        placeholder: '拼音首拼（如：儿科=EK，可不填）',
        maxlength: 50,
      },
      fieldName: 'pinyin_simple',
      label: '拼音首拼',
    },
    {
      component: 'RadioGroup',
      componentProps: {
        options: [
          {
            label: '否',
            value: 0,
          },
          {
            label: '是',
            value: 1,
          },
        ],
      },
      defaultValue: 0,
      fieldName: 'feature',
      label: '特色专科',
      rules: 'required',
    },
  ],
};
