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

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

export const modalFormProps: VbenFormProps = {
  wrapperClass: 'grid-cols-12', // 24栅格,
  commonConfig: {
    formItemClass: 'col-span-6',
    // 所有表单项
    componentProps: {
      class: 'w-full',
    },
  },
  // handleSubmit: onSubmit,
  layout: 'horizontal',
  schema: [
    {
      component: 'VbenInput',
      fieldName: 'id',
      label: 'ID',
      dependencies: {
        show: false,
        triggerFields: ['id'],
      },
    },
    {
      component: 'VbenInput',
      componentProps: {
        placeholder: '请输入菜单标题',
      },
      fieldName: 'title',
      label: '菜单标题',
      rules: 'required',
    },
    {
      component: 'ApiTreeSelect',
      // 对应组件的参数
      componentProps: {
        childrenField: 'children',
        labelField: 'title',
        valueField: 'id',
        // 菜单接口
        api: getMenuTreeOption,
      },
      defaultValue: 0,
      fieldName: 'pid',
      label: '父级菜单',
      rules: 'required',
    },
    {
      component: 'VbenInput',
      componentProps: {
        placeholder: '请输入菜单图标',
      },
      fieldName: 'icon',
      label: '菜单图标',
      rules: 'required',
    },
    // {
    //   component: 'IconPicker',
    //   componentProps: {
    //     placeholder: '请输入菜单图标',
    //   },
    //   fieldName: 'icon',
    //   label: '菜单图标',
    //   rules: 'required',
    // },
    {
      component: 'VbenInput',
      componentProps: {
        placeholder: '请输入路由名称',
      },
      fieldName: 'name',
      label: '路由名称',
      rules: 'required',
    },
    {
      component: 'VbenInput',
      componentProps: {
        placeholder: '请输入访问路由',
      },
      fieldName: 'path',
      label: '访问路由',
      rules: 'required',
    },
    {
      component: 'InputNumber',
      componentProps: {
        placeholder: '请输入排序',
      },
      defaultValue: 0,
      fieldName: 'sort',
      label: '排序',
      rules: 'required',
    },
    {
      component: 'RadioGroup',
      componentProps: {
        options: [
          {
            label: '开启',
            value: 0,
          },
          {
            label: '关闭',
            value: 1,
          },
        ],
      },
      defaultValue: 1,
      fieldName: 'keep_alive',
      label: '缓存',
      rules: 'required',
    },
    {
      component: 'RadioGroup',
      componentProps: {
        options: [
          {
            label: '展示',
            value: 0,
          },
          {
            label: '隐藏',
            value: 1,
          },
        ],
      },
      defaultValue: 0,
      fieldName: 'hide_in_menu',
      label: '是否展示',
      rules: 'required',
    },
    {
      component: 'RadioGroup',
      componentProps: {
        options: [
          {
            label: '是',
            value: 0,
          },
          {
            label: '否',
            value: 1,
          },
        ],
      },
      defaultValue: 1,
      fieldName: 'affix_tab',
      label: '是否置顶',
      rules: 'required',
    },
    {
      component: 'VbenInput',
      componentProps: {
        placeholder: '请输入组件地址',
      },
      defaultValue: 'BasicLayout',
      fieldName: 'component',
      label: '组件地址',
    },
    {
      component: 'VbenInput',
      componentProps: {
        placeholder: '请输入重定向地址',
      },
      fieldName: 'redirect',
      label: '重定向地址',
    },
    {
      component: 'VbenInput',
      componentProps: {
        placeholder: '请输入携带参数',
      },
      fieldName: 'query',
      label: '携带参数',
    },
  ],
  showDefaultActions: false,
};
