import { MyBetaModalFormProps, MyButtons, renderTextHelper } from '@/common';

import {
  ContractsContractNatureEnum,
  ContractsSettlementModeEnum,
  ContractTemplatesIncomeExpenseTypeEnum,
} from '@/gen/Enums';
import { ProCard, ProDescriptions } from '@ant-design/pro-components';
import { useNavigate } from '@umijs/max';
import { Form, Space } from 'antd';

export default function Update(props: MyBetaModalFormProps) {
  const [form] = Form.useForm();
  const navigate = useNavigate();

  return (
    <>
      <Space direction="vertical" style={{ width: '100%' }}>
        <ProCard title="基本信息" size="small">
          <ProDescriptions size="small" column={2}>
            <ProDescriptions.Item label="合同名称" span={2}>
              {props?.item?.model?.name || '-'}
            </ProDescriptions.Item>

            <ProDescriptions.Item label="合同编号" span={2}>
              <Space>
                {props?.item?.model?.code || '-'}
                <MyButtons.View
                  title="查看详情"
                  key="configInfo"
                  onClick={() => {
                    navigate(
                      `/contract/contracts/show/${props?.item?.model?.id}`,
                    );
                  }}
                />
              </Space>
            </ProDescriptions.Item>
            <ProDescriptions.Item label="收支类型">
              <renderTextHelper.Tag
                Enums={ContractTemplatesIncomeExpenseTypeEnum}
                value={props?.item?.model?.income_expense_type}
              />
            </ProDescriptions.Item>
            <ProDescriptions.Item label="合同性质">
              <renderTextHelper.Tag
                Enums={ContractsContractNatureEnum}
                value={props?.item?.model?.contract_nature}
              />
            </ProDescriptions.Item>
            <ProDescriptions.Item label="合同类型">
              {props?.item?.model?.contract_type_name || '-'}
            </ProDescriptions.Item>
            <ProDescriptions.Item label="结算模式">
              <renderTextHelper.Tag
                Enums={ContractsSettlementModeEnum}
                value={props?.item?.model?.settlement_mode}
              />
            </ProDescriptions.Item>
            <ProDescriptions.Item label="合同金额">
              {props?.item?.model?.total_amount || '-'}
            </ProDescriptions.Item>
            <ProDescriptions.Item label="保证金金额">
              {props?.item?.model?.deposit_amount || '无'}
            </ProDescriptions.Item>
            <ProDescriptions.Item label="签约主体">
              {props?.item?.model?.sign_subject || '-'}
            </ProDescriptions.Item>

            <ProDescriptions.Item label="关联项目">
              {props?.item?.model?.project_name || '-'}
            </ProDescriptions.Item>

            <ProDescriptions.Item label="合同有效期" span={2}>
              {props?.item?.model?.start_time?.substring(0, 10)}至
              {props?.item?.model?.end_time?.substring(0, 10)}
            </ProDescriptions.Item>

            <ProDescriptions.Item label="申请人" span={2}>
              {props?.item?.model?.applicant?.name || '-'}
              {props?.item?.model?.applicant?.phone || '-'}
            </ProDescriptions.Item>
            <ProDescriptions.Item label="申请时间" span={2}>
              {props?.item?.created_at || '-'}
            </ProDescriptions.Item>
            <ProDescriptions.Item label="申请说明" span={2}>
              {props?.item?.model?.remark || '-'}
            </ProDescriptions.Item>
          </ProDescriptions>
        </ProCard>
      </Space>
    </>
  );
}
