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

import { getDeliveryWarehouseOption } from '#/views/system/delivery-warehouse/api';

export const formOptions: VbenFormProps = {
  collapsed: false,
  schema: [
    {
      component: 'ApiSelect',
      componentProps: {
        allowClear: true,
        showSearch: true,
        filterOption: (input: string, option: any) =>
          option?.label.toLowerCase().indexOf(input.toLowerCase()) >= 0,
        afterFetch: (data: { id: number; name: string }[]) =>
          data.map((item: any) => ({
            label: item.name,
            value: item.id,
          })),
        api: getDeliveryWarehouseOption,
        placeholder: '请选择配送仓库',
      },
      fieldName: 'warehouse_id',
      label: '配送仓库',
    },
    {
      component: 'VbenInput',
      componentProps: {
        placeholder: '输入药品ID',
      },
      fieldName: 'drug_id',
      label: '药品ID',
    },
  ],
  showCollapseButton: true,
  submitButtonOptions: {
    content: '查询',
  },
  submitOnChange: true,
  submitOnEnter: false,
};
