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

import { STATUS_OPTIONS, VIP_TIER_GROUP_OPTIONS } from './constants';

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: 'VbenInput',
      fieldName: 'code',
      label: '等级编码',
      rules: 'required',
      componentProps: { placeholder: '如 V5 / BLACK_GOLD' },
    },
    {
      component: 'VbenInput',
      fieldName: 'name',
      label: '等级名称',
      rules: 'required',
      componentProps: { placeholder: '如铂金会员' },
    },
    {
      component: 'VbenSelect',
      fieldName: 'tier_group',
      label: '等级组',
      rules: 'selectRequired',
      formItemClass: 'col-span-6',
      componentProps: { options: VIP_TIER_GROUP_OPTIONS },
      defaultValue: 0,
    },
    {
      component: 'InputNumber',
      fieldName: 'level_weight',
      label: '权重',
      formItemClass: 'col-span-6',
      componentProps: { min: 0, max: 9999 },
      defaultValue: 0,
    },
    {
      component: 'Avatar',
      fieldName: 'badge_url',
      label: '等级徽标',
      defaultValue: '',
    },
    {
      component: 'InputNumber',
      fieldName: 'price',
      label: '标价',
      formItemClass: 'col-span-6',
      componentProps: { min: 0, precision: 2, placeholder: '0 表示免费' },
      defaultValue: 0,
    },
    {
      component: 'InputNumber',
      fieldName: 'sort',
      label: '排序',
      formItemClass: 'col-span-6',
      componentProps: { min: 0 },
      defaultValue: 0,
    },
    {
      component: 'Select',
      fieldName: 'permissions',
      label: 'VIP功能',
      help: '低等级勾选后，更高权重等级会自动补齐缺失功能',
      componentProps: {
        mode: 'multiple',
        allowClear: true,
        optionFilterProp: 'label',
        placeholder: '从功能字典多选（需先在 VIP功能字典 维护）',
        options: [],
      },
      defaultValue: [],
    },
    {
      component: 'VbenInput',
      fieldName: 'description',
      label: '说明',
      componentProps: { type: 'textarea', rows: 2 },
      defaultValue: '',
    },
    {
      component: 'VbenSelect',
      fieldName: 'status',
      label: '状态',
      formItemClass: 'col-span-6',
      componentProps: { options: STATUS_OPTIONS },
      defaultValue: 1,
    },
  ],
  showDefaultActions: false,
};
