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

export const modalFormProps: VbenFormProps = {
  wrapperClass: 'grid-cols-12', // 24栅格,
  commonConfig: {
    formItemClass: 'col-span-12',
    // 所有表单项
    componentProps: {
      class: 'w-full',
    },
  },
  // handleSubmit: onSubmit,
  layout: 'horizontal',
  schema: [
    {
      component: 'UploadImage',
      fieldName: 'url',
      label: '图片',
      rules: 'required',
      componentProps: {
        maxCount: 5,
      },
    },
  ],
  showDefaultActions: false,
};
export const salespersonModalFormProps: 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',
      formItemClass: 'col-span-6',
      dependencies: {
        show: false,
        triggerFields: ['id'],
      },
    },
    {
      component: 'Input',
      fieldName: 'phone',
      label: '手机号',
      rules: 'required',
      componentProps: {
        minLength: 11,
      },
    },
    {
      component: 'Input',
      fieldName: 'nick_name',
      label: '名称',
      rules: 'required',
    },
    {
      component: 'RadioGroup',
      fieldName: 'split_type',
      label: '分成类型',
      rules: 'required',
      componentProps: {
        placeholder: '请选择',
        options: [
          {
            label: '元',
            value: 0,
          },
          {
            label: '百分比（%）',
            value: 1,
          },
        ],
      },
      defaultValue: 0,
    },
    {
      component: 'InputNumber',
      fieldName: 'split',
      label: '分成比例（%）',
      componentProps: {
        min: 0,
        max: 100,
        precision: 2,
        class: 'w-full',
      },
      dependencies: {
        show(values) {
          return Number(values?.split_type) === 1;
        },
        rules(values) {
          return Number(values?.split_type) === 1 ? 'required' : '';
        },
        triggerFields: ['split_type'],
      },
    },
    {
      component: 'Divider',
      fieldName: 'tcm_divider',
      label: '中药推广分成',
      formItemClass: 'col-span-12',
    },
    {
      component: 'InputNumber',
      fieldName: 'tcm_split',
      label: '中药分成（%）',
      componentProps: {
        min: 0,
        max: 100,
        precision: 2,
        class: 'w-full',
        placeholder: '0 表示不分成',
      },
      defaultValue: 0,
    },
    {
      component: 'RadioGroup',
      fieldName: 'tcm_base_type',
      label: '中药分成基数',
      componentProps: {
        options: [
          { label: '药店利润', value: 0 },
          { label: '处方总价', value: 1 },
        ],
      },
      defaultValue: 0,
      dependencies: {
        show(values) {
          return Number(values?.tcm_split ?? 0) > 0;
        },
        triggerFields: ['tcm_split'],
      },
    },
  ],
  showDefaultActions: false,
};
