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

import { getDrugCategoriesTree, getZoneOptions } from '../api';

export const modalFormProps: VbenFormProps = {
  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: 'ApiSelect',
      componentProps: {
        api: getZoneOptions,
        labelField: 'title',
        valueField: 'id',
        placeholder: '请选择所属专区',
      },
      fieldName: 'zone_id',
      formItemClass: 'col-span-12',
      label: '所属专区',
      rules: 'required',
    },
    {
      component: 'VbenInput',
      componentProps: {
        placeholder: '请输入分类名称',
      },
      fieldName: 'category_name',
      formItemClass: 'col-span-12',
      label: '分类名称',
      rules: 'required',
    },
    {
      component: 'ApiTreeSelect',
      componentProps: {
        childrenField: 'children',
        labelField: 'category_name',
        valueField: 'id',
        api: getDrugCategoriesTree,
        placeholder: '请选择父级分类（不选则为顶级）',
        allowClear: true,
        treeDefaultExpandAll: true,
      },
      defaultValue: 0,
      fieldName: 'parent_id',
      formItemClass: 'col-span-12',
      label: '父级分类',
    },
    {
      component: 'InputNumber',
      componentProps: {
        placeholder: '请输入排序值，数值越小越靠前',
        min: 0,
        max: 9999,
      },
      defaultValue: 0,
      fieldName: 'sort',
      formItemClass: 'col-span-12',
      label: '排序',
    },
  ],
  showDefaultActions: false,
};

