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

import {
  EPL_TRANSFER_ACCOUNT_TYPE_OPTIONS,
  USE_TYPE_TRANSFER,
} from './constants';

export const bankCardReportFormProps: 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: 'store_id',
      label: '门店ID',
      dependencies: { show: false, triggerFields: ['store_id'] },
    },
    {
      component: 'VbenInput',
      fieldName: 'only_remark',
      label: '仅备注',
      dependencies: { show: false, triggerFields: ['only_remark'] },
    },
    {
      component: 'VbenInput',
      fieldName: 'report_status',
      label: '报备状态',
      dependencies: { show: false, triggerFields: ['report_status'] },
    },
    {
      component: 'VbenInput',
      fieldName: 'use_type',
      label: '报备卡用途',
      defaultValue: USE_TYPE_TRANSFER,
      dependencies: { show: false, triggerFields: ['use_type'] },
    },
    {
      component: 'VbenInput',
      componentProps: {
        disabled: true,
        placeholder: '转账卡（useType=2）',
      },
      fieldName: 'use_type_display',
      label: '报备卡用途',
      defaultValue: '转账卡（useType=2）',
      dependencies: {
        show: (values) => !values.only_remark,
        triggerFields: ['only_remark'],
      },
    },
    {
      component: 'VbenInput',
      componentProps: { placeholder: '请输入开户人姓名' },
      fieldName: 'bank_user_name',
      label: '开户人姓名',
      rules: 'required',
      dependencies: {
        show: (values) => !values.only_remark,
        triggerFields: ['only_remark'],
      },
    },
    {
      component: 'VbenInput',
      componentProps: { placeholder: '请输入银行卡号' },
      fieldName: 'bank_card',
      label: '银行卡号',
      rules: 'required',
      dependencies: {
        show: (values) => !values.only_remark,
        triggerFields: ['only_remark'],
      },
    },
    {
      component: 'VbenInput',
      componentProps: {
        placeholder: '转账卡必填，参考易票联银行名称规范',
      },
      fieldName: 'bank_name',
      label: '开户银行名称',
      rules: 'required',
      dependencies: {
        show: (values) => !values.only_remark,
        triggerFields: ['only_remark'],
      },
    },
    {
      component: 'RadioGroup',
      componentProps: {
        options: EPL_TRANSFER_ACCOUNT_TYPE_OPTIONS,
      },
      fieldName: 'account_type',
      label: '账户类型',
      rules: 'required',
      defaultValue: '2',
      dependencies: {
        show: (values) => !values.only_remark,
        triggerFields: ['only_remark'],
      },
    },
    {
      component: 'VbenInput',
      componentProps: {
        placeholder: '对公/授权对公账户必填；其他卡号非 62 开头必填',
      },
      fieldName: 'bank_no',
      label: '银联行号',
      dependencies: {
        show: (values) => !values.only_remark,
        triggerFields: ['only_remark', 'account_type'],
      },
    },
    {
      component: 'VbenInput',
      componentProps: {
        placeholder: '选填；对公/授权对公填营业执照号，法人/授权个人填身份证号',
      },
      fieldName: 'cert_no',
      label: '证件号码',
      dependencies: {
        show: (values) => !values.only_remark,
        triggerFields: ['only_remark', 'account_type'],
      },
    },
    {
      component: 'UploadOssFile',
      componentProps: {
        maxCount: 1,
      },
      fieldName: 'attachment',
      label: '合同附件',
      rules: 'required',
      dependencies: {
        show: (values) => {
          if (values.only_remark) {
            return false;
          }
          if (!values.id) {
            return true;
          }
          return [3, 4].includes(Number(values.report_status ?? 0));
        },
        triggerFields: ['only_remark', 'id', 'report_status'],
      },
    },
    {
      component: 'VbenInput',
      componentProps: { placeholder: '备注' },
      fieldName: 'remark',
      label: '备注',
    },
    {
      component: 'VbenInput',
      componentProps: { placeholder: '摘要' },
      fieldName: 'summary',
      label: '摘要',
    },
  ],
  showDefaultActions: false,
};
