import {
  MyBetaModalFormProps,
  MyProTableProps,
  renderTextHelper,
} from '@/common';
import {
  CompanySuppliersGradeEnum,
  CompanySuppliersSupplierTypeEnum,
} from '@/gen/Enums';
import { ProCard, ProDescriptions, ProTable } from '@ant-design/pro-components';
import { Image, Space } from 'antd';

export default function info(props: MyBetaModalFormProps) {
  const { item } = props;

  return (
    <Space direction="vertical" style={{ width: '100%' }} size="small">
      {/* 企业供应商 */}
      {item?.supplier_type ===
        CompanySuppliersSupplierTypeEnum.Enterprise.value && (
        <ProCard>
          <ProDescriptions bordered column={3}>
            <ProDescriptions.Item label="企业名称">
              {item?.name}
            </ProDescriptions.Item>
            <ProDescriptions.Item label="类型">
              <renderTextHelper.Tag
                Enums={CompanySuppliersSupplierTypeEnum}
                value={item?.supplier_type}
                key="supplier_type"
              />
            </ProDescriptions.Item>

            <ProDescriptions.Item label="企业法人">
              {item?.legal_person}
            </ProDescriptions.Item>

            {item?.supplier_type ===
              CompanySuppliersSupplierTypeEnum.Enterprise.value && (
              <ProDescriptions.Item label="注册资本">
                {item?.registered_capital}万
              </ProDescriptions.Item>
            )}
            <ProDescriptions.Item label="企业地址" span={2}>
              {item.province} {item.city || ''} {item.area || ''}
              {item.street || ''}
              {item.address || ''}
            </ProDescriptions.Item>
            <ProDescriptions.Item label="经营范围" span={3}>
              {item?.business_scope}
            </ProDescriptions.Item>
            <ProDescriptions.Item label="等级">
              <renderTextHelper.Tag
                Enums={CompanySuppliersGradeEnum}
                value={item?.grade}
                key="grade"
              />
            </ProDescriptions.Item>
            <ProDescriptions.Item label="上一次评级">
              {item?.grade_time?.substring(0, 10)}
            </ProDescriptions.Item>
            <ProDescriptions.Item label="黑名单">
              {item?.is_blacklisted ? '是' : '否'}
            </ProDescriptions.Item>
          </ProDescriptions>
        </ProCard>
      )}
      {/* 企业供应商 */}
      {item?.supplier_type ===
        CompanySuppliersSupplierTypeEnum.Enterprise.value && (
        <ProCard title="开票信息">
          <ProDescriptions bordered column={3}>
            <ProDescriptions.Item label="开票主体" span={2}>
              {item?.company_name}
            </ProDescriptions.Item>
            <ProDescriptions.Item label="一般纳税人">
              {item?.is_general_taxpayer ? '是' : '否'}
            </ProDescriptions.Item>
            <ProDescriptions.Item label="纳税人识别号" span={2}>
              {item?.tax_number}
            </ProDescriptions.Item>
            <ProDescriptions.Item label="开票电话">
              {item?.tax_phone}
            </ProDescriptions.Item>
            <ProDescriptions.Item label="银行账号" span={2}>
              {item?.tax_bank_account}
            </ProDescriptions.Item>
            <ProDescriptions.Item label="开户行">
              {item?.tax_bank_name}
            </ProDescriptions.Item>
            <ProDescriptions.Item label="开票地址" span={3}>
              {item?.tax_address}
            </ProDescriptions.Item>
          </ProDescriptions>
        </ProCard>
      )}
      {/* 企业供应商 */}
      {item?.supplier_type ===
        CompanySuppliersSupplierTypeEnum.Enterprise.value && (
        <ProCard title="联系人信息">
          <ProDescriptions bordered column={3}>
            <ProDescriptions.Item label="联系人">
              {item?.contact_name || '-'}
              {item?.contact_phone || '-'}
            </ProDescriptions.Item>
            <ProDescriptions.Item label="邮箱">
              {item?.contact_email || '-'}
            </ProDescriptions.Item>
            <ProDescriptions.Item label="备注">
              {item?.contact_remark || '-'}
            </ProDescriptions.Item>
          </ProDescriptions>
        </ProCard>
      )}
      {/* 个人供应商 */}
      {item?.supplier_type ===
        CompanySuppliersSupplierTypeEnum.Individual.value && (
        <ProCard title="基本信息">
          <ProDescriptions bordered column={3}>
            <ProDescriptions.Item label="类型">
              <renderTextHelper.Tag
                Enums={CompanySuppliersSupplierTypeEnum}
                value={item?.supplier_type}
                key="supplier_type"
              />
            </ProDescriptions.Item>
            <ProDescriptions.Item label="联系人">
              {item?.contact_name || '-'}
              {item?.contact_phone || '-'}
            </ProDescriptions.Item>
            <ProDescriptions.Item label="证件号码">
              {item?.tax_number}
            </ProDescriptions.Item>
          </ProDescriptions>
        </ProCard>
      )}
      <ProCard title="收款账号">
        <ProCard size="small">
          <ProTable
            {...MyProTableProps.props}
            search={false}
            toolBarRender={false}
            pagination={false}
            dataSource={props?.item?.bank_accounts}
            rowKey={(record, index) => record?.bank_accounts || index}
            size="small"
            columns={[
              {
                title: '开户名称',
                dataIndex: 'company_name',
              },
              {
                title: '开户银行',
                dataIndex: 'tax_bank_name',
              },
              {
                title: '银行账号',
                dataIndex: 'tax_bank_account',
              },
            ]}
          />
        </ProCard>
      </ProCard>
      <ProCard title="证件资料" size="small">
        <Image.PreviewGroup>
          <Space wrap>
            {props?.item?.certificates?.map((res: any, index: number) => (
              <Image
                key={`${res?.name}_${index}`}
                height={120}
                src={res?.url || ''}
                placeholder="证件资料"
              />
            ))}
          </Space>
        </Image.PreviewGroup>
      </ProCard>
    </Space>
  );
}
