import type { VbenFormProps } from '#/adapter/form';
import {getStoreOption} from "#/views/system/store/api";

/**
 * 作废表单
 */
export const invalidatedForm: VbenFormProps = {
  wrapperClass: 'grid-cols-12', // 24栅格,
  commonConfig: {
    formItemClass: 'col-span-12',
    // 所有表单项
    componentProps: {
      class: 'w-full',
    },
  },
  // handleSubmit: onSubmit,
  layout: 'horizontal',
  schema: [
    {
      component: 'VbenInput',
      fieldName: 'id',
      label: 'ID',
      dependencies: {
        show: false,
        triggerFields: ['id'],
      },
      rules: 'required',
    },
    {
      component: 'Textarea',
      componentProps: {
        placeholder: '请输入作废原因',
      },
      fieldName: 'invalidated_reason',
      label: '作废原因',
      rules: 'required',
    },
  ],
  showDefaultActions: false,
};
/**
 * 结算表单
 */
export const settlementForm: VbenFormProps = {
  wrapperClass: 'grid-cols-12', // 24栅格,
  commonConfig: {
    formItemClass: 'col-span-12',
    // 所有表单项
    componentProps: {
      class: 'w-full',
    },
  },
  // handleSubmit: onSubmit,
  layout: 'horizontal',
  schema: [
    {
      component: 'ApiSelect',
      componentProps: {
        placeholder: '请选择',
        // 菜单接口转options格式
        afterFetch: (data: { id: number; name: string }[]) => {
          return data.map((item: any) => ({
            label: item.name,
            value: item.id,
          }));
        },
        api: getStoreOption,
      },
      // defaultValue: 0,
      fieldName: 'store_id',
      label: '诊所',
      rules: 'required',
    },
    {
      component: 'Avatar',
      componentProps: {
        placeholder: '请上传转账截图',
      },
      fieldName: 'url',
      label: '转账截图',
      rules: 'required',
    },
  ],
  showDefaultActions: false,
};
