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

import { getMenuTreeOption } from '#/views/system/menu/api';

export const codeGenerationForm: VbenFormProps = {
  wrapperClass: 'grid-cols-12', // 24栅格,
  commonConfig: {
    formItemClass: 'col-span-12',
    // 所有表单项
    componentProps: {
      class: 'w-full',
    },
  },
  // handleSubmit: onSubmit,
  layout: 'horizontal',
  schema: [
    {
      component: 'VbenInput',
      componentProps: {
        placeholder: '请输入类名',
      },
      fieldName: 'class_name',
      label: '类名',
      rules: 'required',
      formItemClass: 'col-span-6',
    },
    {
      component: 'VbenInput',
      componentProps: {
        placeholder: '请输入中文名称',
      },
      fieldName: 'class_comment',
      label: '中文名称',
      rules: 'required',
      formItemClass: 'col-span-6',
    },
    {
      component: 'IconPicker',
      componentProps: {
        placeholder: '请输入菜单图标',
      },
      fieldName: 'icon',
      label: '菜单图标',
      defaultValue: '',
      rules: 'required',
      formItemClass: 'col-span-6',
    },
    {
      component: 'InputNumber',
      componentProps: {
        placeholder: '请输入排序',
      },
      fieldName: 'sort',
      label: '排序',
      defaultValue: 9999,
      rules: 'required',
      formItemClass: 'col-span-6',
    },
    {
      component: 'ApiTreeSelect',
      // 对应组件的参数
      componentProps: {
        childrenField: 'children',
        labelField: 'title',
        valueField: 'id',
        // 菜单接口
        api: getMenuTreeOption,
      },
      defaultValue: 0,
      fieldName: 'pid',
      label: '父级菜单',
      formItemClass: 'col-span-6',
      rules: 'required',
    },
  ],
  showDefaultActions: false,
};
