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

/**
 * 配送仓库新建/编辑
 * - 三证必填，其余证照/合同选填
 * - 联系人/手机号仅新建时展示，用于开通仓管理员
 * - 银行卡仍走独立报备入口
 */
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',
      formItemClass: 'col-span-6',
      dependencies: {
        show: false,
        triggerFields: ['id'],
      },
    },
    {
      component: 'VbenInput',
      componentProps: {
        placeholder: '请输入配送仓库名称',
      },
      fieldName: 'name',
      label: '仓库名称',
      rules: 'required',
    },
    {
      component: 'Textarea',
      componentProps: {
        placeholder: '请输入仓库介绍（选填）',
      },
      fieldName: 'introduce',
      label: '仓库介绍',
    },
    {
      component: 'VbenInput',
      componentProps: {
        placeholder: '联系人姓名（将作为仓管理员昵称）',
      },
      fieldName: 'contact_name',
      label: '联系人',
      rules: 'required',
      help: '新建时用于开通配送仓库管理员账号',
      dependencies: {
        // 仅新建展示；编辑改账号请走「配送仓管理员」菜单
        if({ id }: { id?: number | string }) {
          return !id;
        },
        triggerFields: ['id'],
      },
    },
    {
      component: 'VbenInput',
      componentProps: {
        placeholder: '手机号（仓管理员登录手机）',
      },
      fieldName: 'phone',
      label: '手机号',
      // 与后端 checkPhone 一致：必填 + 大陆 11 位号段
      rules: 'mobile',
      help: '默认初始密码 Xk123456@',
      dependencies: {
        if({ id }: { id?: number | string }) {
          return !id;
        },
        triggerFields: ['id'],
      },
    },
    {
      component: 'Avatar',
      fieldName: 'business_license_image',
      label: '营业执照',
      rules: 'required',
      formItemClass: 'col-span-4',
    },
    {
      component: 'Avatar',
      fieldName: 'drug_license_image',
      label: '药品经营许可证',
      rules: 'required',
      formItemClass: 'col-span-4',
    },
    {
      component: 'Avatar',
      fieldName: 'medical_device_license_image',
      label: '医疗器械经营许可证',
      rules: 'required',
      formItemClass: 'col-span-4',
    },
    {
      component: 'Avatar',
      fieldName: 'food_license_image',
      label: '食品经营许可证',
      formItemClass: 'col-span-4',
    },
    {
      component: 'Avatar',
      fieldName: 'pharmacist_certificate_image',
      label: '药师资格证',
      formItemClass: 'col-span-4',
    },
    {
      component: 'Avatar',
      fieldName: 'internet_drug_license_image',
      label: '互联网药品经营许可证',
      formItemClass: 'col-span-4',
    },
    {
      component: 'UploadOssFile',
      componentProps: {
        maxCount: 1,
      },
      fieldName: 'contract_attachment',
      label: '合同附件',
      formItemClass: 'col-span-12',
    },
    {
      component: 'RadioGroup',
      componentProps: {
        options: [
          { label: '禁用', value: 0 },
          { label: '启用', value: 1 },
        ],
      },
      fieldName: 'status',
      label: '状态',
      defaultValue: 1,
      formItemClass: 'col-span-6',
    },
  ],
  showDefaultActions: false,
};
