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


// 诊所管理表单配置
// 注意：已移除类型选择字段，固定为type=0（诊所类型）
export const modalFormProps: VbenFormProps = {
  wrapperClass: 'grid-cols-12', // 24栅格,
  commonConfig: {
    formItemClass: 'col-span-12',
    // 所有表单项
    componentProps: {
      class: 'w-full',
    },
  },
  // handleSubmit: onSubmit,
  layout: 'horizontal',
  schema: [
    // {
    //   fieldName: 'baseinfo',
    //   component: 'Divider',
    //   label: '基础信息',
    //   formItemClass: 'col-span-12',
    //   componentProps: {},
    //   hideLabel: true,
    //   renderComponentContent: () => {
    //     return {
    //       default: () => {
    //         return '基础信息';
    //       },
    //     };
    //   },
    // },
    {
      component: 'VbenInput',
      fieldName: 'id',
      label: 'ID',
      formItemClass: 'col-span-6',
      dependencies: {
        show: false,
        triggerFields: ['id'],
      },
    },
    {
      component: 'Divider',
      fieldName: '',
      label: '',
      rules: 'required',
      hideLabel: true,
      renderComponentContent: () => {
        return {
          default: () => {
            return '基础信息';
          },
        };
      },
    },
    {
      component: 'Avatar',
      formItemClass: 'col-span-6',
      fieldName: 'see_rate',
      label: '公章',
    },
    {
      component: 'VbenInput',
      formItemClass: 'col-span-6',
      componentProps: {
        placeholder: '请输入诊所昵称',
      },
      fieldName: 'name',
      label: '诊所名称',
      rules: 'required',
    },
    {
      component: 'VbenInput',
      formItemClass: 'col-span-6',
      componentProps: {
        placeholder: '请输入诊所ERP ID',
      },
      fieldName: 'erp_id',
      label: 'ERP ID',
      rules: 'required',
    },
    {
      component: 'VbenInput',
      formItemClass: 'col-span-6',
      componentProps: {
        placeholder: '请输入诊所 MES ID',
      },
      fieldName: 'mes_id',
      label: 'MES ID',
    },
    {
      component: 'Input',
      fieldName: 'type',
      dependencies: {
        show: false,
        triggerFields: ['id'],
      },
      defaultValue: 0,
    },
    // 注意：已移除门店类型选择字段，因为诊所管理固定为type=0
    {
      // 是否包邮（单选）
      component: 'RadioGroup',
      formItemClass: 'col-span-6',
      componentProps: {
        options: [
          { label: '不包邮', value: 0 },
          { label: '包邮', value: 1 },
        ],
        placeholder: '是否包邮',
      },
      fieldName: 'is_shipping_free',
      label: '是否包邮',
      rules: 'required',
    },
    {
      component: 'RadioGroup',
      formItemClass: 'col-span-6',
      componentProps: {
        options: [
          { label: '关闭', value: 0 },
          { label: '开启', value: 1 },
        ],
      },
      fieldName: 'enable_order_price_percent_adjust',
      label: '订单打折/涨幅',
      defaultValue: 0,
    },
    {
      // 诊所类型（单选）
      component: 'RadioGroup',
      formItemClass: 'col-span-6',
      componentProps: {
        options: [
          { label: '西医诊所', value: 1 },
          { label: '中医诊所', value: 2 },
        ],
        placeholder: '诊所类型',
      },
      fieldName: 'clinic_type',
      label: '诊所类型',
      rules: 'required',
      defaultValue: 2, // 默认中医诊所
    },
    {
      // 是否订阅价格波动（单选，新增和编辑时都显示）
      component: 'RadioGroup',
      formItemClass: 'col-span-6',
      componentProps: {
        options: [
          { label: '订阅价格波动', value: 0 }, // 0 表示订阅
          { label: '不订阅价格波动', value: 1 }, // 1 表示不订阅
        ],
        placeholder: '是否订阅价格波动',
      },
      fieldName: 'subscribe_price_change',
      label: '是否订阅价格波动',
      defaultValue: 0, // 默认订阅
      rules: 'required',
    },
    {
      component: 'VbenInput',
      formItemClass: 'col-span-6',
      componentProps: {
        placeholder: '请输入诊所联系人姓名',
      },
      fieldName: 'contact',
      label: '联系人姓名',
      rules: 'required',
    },
    {
      component: 'VbenInput',
      formItemClass: 'col-span-6',
      componentProps: {
        placeholder: '请输入诊所联系人手机号',
      },
      fieldName: 'mobile',
      label: '联系人手机号',
      // 与后端 checkPhone 一致：必填 + 大陆 11 位号段
      rules: 'mobile',
    },
    {
      // 编辑时可选：同步修改诊所管理员后台登录手机号
      component: 'Switch',
      formItemClass: 'col-span-12',
      fieldName: 'sync_admin_phone',
      label: '同步管理员登录号',
      defaultValue: false,
      componentProps: {
        checkedChildren: '是',
        unCheckedChildren: '否',
      },
      help: '勾选后，保存时将同步修改诊所管理员后台登录手机号（需已开通后台）',
      dependencies: {
        show: (values) => values.id != null,
        triggerFields: ['id'],
      },
    },
    {
      component: 'PromoterPicker',
      formItemClass: 'col-span-6',
      fieldName: 'code',
      label: '业务员',
      rules: 'required',
    },
    {
      component: 'TimePicker',
      formItemClass: 'col-span-6',
      componentProps: {
        placeholder: '请选择开始营业时间',
        format: 'HH:mm', // 确保格式与你需要的一致
      },
      fieldName: 'start_time',
      label: '开始营业时间',
      rules: 'required',
    },
    {
      component: 'TimePicker',
      formItemClass: 'col-span-6',
      componentProps: {
        placeholder: '请选择结束营业时间',
        format: 'HH:mm', // 确保格式与你需要的一致
      },
      fieldName: 'end_time',
      label: '结束营业时间',
      rules: 'required',
    },
    {
      component: 'RegionAddressPicker',
      fieldName: 'address',
      label: '省市区',
      rules: 'required',
    },
    {
      component: 'Textarea',
      componentProps: {
        placeholder: '请选择结束营业时间',
        // format: 'HH:MM', // 确保格式与你需要的一致
      },
      fieldName: 'position',
      label: '详细地址',
      rules: 'required',
    },
    {
      component: 'UploadImage',
      fieldName: 'url',
      label: '轮播图',
      rules: 'required',
      // dependencies: {
      //   show: (values) => {
      //     return values.id == null;
      //   },
      //   triggerFields: ['id'],
      // },
      componentProps: {
        maxCount: 9,
      },
    },
    {
      component: 'Divider',
      fieldName: '',
      label: 'x',
      rules: 'required',
      hideLabel: true,
      renderComponentContent: () => {
        return {
          default: () => {
            return '销售比例信息';
          },
        };
      },
    },
    {
      component: 'InputNumber',
      formItemClass: 'col-span-6',
      componentProps: {
        placeholder: '请输入中药采购价比例',
      },
      fieldName: 'z_buy_percent',
      label: '中药采购价比例',
      rules: 'required',
      suffix: () => '%',
      defaultValue: 100,
    },
    {
      component: 'InputNumber',
      formItemClass: 'col-span-6',
      componentProps: {
        placeholder: '请输入中药销售比例',
      },
      fieldName: 'z_sale_percent',
      label: '中药销售比例',
      rules: 'required',
      suffix: () => '%',
      defaultValue: 100,
    },
    // {
    //   component: 'VbenInput',
    //   formItemClass: 'col-span-6',
    //   componentProps: {
    //     placeholder: '请输入颗粒药采购价比例',
    //   },
    //   fieldName: 'g_bug_percent',
    //   label: '颗粒药采购价比例',
    //   rules: 'required',
    // },
    // {
    //   component: 'VbenInput',
    //   formItemClass: 'col-span-6',
    //   componentProps: {
    //     placeholder: '请输入颗粒药销售比例',
    //   },
    //   fieldName: 'g_sale_percent',
    //   label: '颗粒药销售比例',
    //   rules: 'required',
    // },
  ],
  showDefaultActions: false,
};
