import {
  MyButtons,
  MyFormItems,
  MyModalFormProps,
  MyPageContainer,
  rulesHelper,
} from '@/common';
import ModalsResourceSelectList from '@/components/ModalsResourceSelectList';
import { SelectContract } from '@/components/SelectContract';
import { Apis } from '@/gen/Apis';
import {
  CompanySuppliersCounterpartyEnum,
  ContractPeoplesSignPartyEnum,
  ContractsContractNatureEnum,
  ContractsSettlementModeEnum,
  ContractTemplatesIncomeExpenseTypeEnum,
  ResourceTypesCategoryEnum,
} from '@/gen/Enums';
import { BetaSchemaForm, ProCard } from '@ant-design/pro-components';
import { useNavigate } from '@umijs/max';
import { Form, message, Space, Steps } from 'antd';
import dayjs from 'dayjs';
import { useState } from 'react';
import MySubmitApproval from '../modals/SubmitApproval';
// import SubmitReview from '../modals/SubmitReview';
import { IsDepositEnum } from './reducer';

export default function Index({ title = '新增合同' }) {
  const [form] = Form.useForm();
  const navigate = useNavigate();
  const [selectedRow, setSelectedRow] = useState<any>({});
  const [contractId, setContractId] = useState<number>(0);
  const [submitModalVisible, setSubmitModalVisible] = useState<boolean>(false);
  const [currentStep, setCurrentStep] = useState<number>(0);
  const [contractData, setContractData] = useState<any>({});

  const onSave = (data: any) => {
    const contractDataToSave = {
      ...data,
      // sign_department: data.organization?.[data.organization?.length - 1] || '',
      is_deposit: data.is_deposit
        ? IsDepositEnum[data.is_deposit as keyof typeof IsDepositEnum].value
        : 'false',
      start_time: dayjs(data.contract_time?.[0]).format('YYYY-MM-DD'),
      end_time: dayjs(data.contract_time?.[1]).format('YYYY-MM-DD'),
      code: data?.code || '',
    };
    Apis.Contract.Contracts.Store(contractDataToSave)
      .then((res: any) => {
        const contractId = res?.data?.id;
        if (contractId) {
          setContractId(contractId);
          setContractData({
            ...contractDataToSave,
            id: contractId,
            name: data?.name,
            code: data?.code || '',
          });
          setCurrentStep(1);
          message.success('保存成功');
        }
      })
      .catch(() => false);
  };

  const totalBillSeparableAmount = () => {
    return parseFloat(
      (
        parseFloat(contractData?.total_amount) -
        parseFloat(contractData?.total_bill_amount || 0)
      ).toFixed(2),
    );
  };

  const handleBillsSubmit = async (values: any) => {
    return new Promise((resolve) => {
      let year_month = '';
      let year_month_is = false;
      let total_bill_amount = totalBillSeparableAmount();
      let taotal_amount = 0;
      if (
        total_bill_amount <= 0 &&
        contractData?.settlement_mode === 'LumpSumContract'
      ) {
        message.warning('没有多余金额可生成账单！');
        resolve(false);
        return;
      }
      values?.bills?.forEach((res: any) => {
        if (values?.payee === values?.payer) {
          year_month_is = true;
          message.warning('收款方和付款方不能相同');
          resolve(false);
          return false;
        }
        res.payee = values?.payee;
        res.payer = values?.payer;
        if (year_month_is) return;
        if (res?.year_month === year_month) {
          year_month_is = true;
          message.warning('不能选择相同年月');
          resolve(false);
          return false;
        }
        year_month = res?.year_month;
        // 处理不同类型的year_month值
        let year, month;
        if (res?.year_month) {
          if (typeof res.year_month === 'string') {
            const k = res.year_month.split('-');
            year = k[0];
            month = k[1] ? parseInt(k[1]) : 0;
          } else if (typeof res.year_month.format === 'function') {
            // 处理dayjs/moment对象
            year = res.year_month.format('YYYY');
            month = parseInt(res.year_month.format('MM'));
          } else if (res.year_month.getFullYear) {
            // 处理Date对象
            year = res.year_month.getFullYear().toString();
            month = res.year_month.getMonth() + 1;
          } else {
            year = '';
            month = 0;
          }
        } else {
          year = '';
          month = 0;
        }
        res.year = year;
        res.month = month;
        if (contractData?.settlement_mode === 'LumpSumContract') {
          taotal_amount += parseFloat(res?.amount);
        }
      });
      if (
        contractData?.settlement_mode === 'LumpSumContract' &&
        taotal_amount !== total_bill_amount
      ) {
        message.warning(`账单¥${total_bill_amount}，拆分错误！`);
        resolve(false);
        return;
      }
      if (year_month_is) {
        resolve(false);
        return;
      }
      if (contractData?.settlement_mode === 'OpenContract') {
        //开口合同
        Apis.Contract.ContractBills.BatchStore({
          ...values,
          contracts_id: contractData?.id,
        })
          .then(() => {
            message.success('提交成功');
            resolve(true);
          })
          .catch(() => {
            resolve(false);
          });
      } else if (
        total_bill_amount > 0 &&
        contractData?.settlement_mode === 'LumpSumContract'
      ) {
        if (taotal_amount <= total_bill_amount) {
          Apis.Contract.ContractBills.BatchStore({
            ...values,
            contracts_id: contractData?.id,
          })
            .then(() => {
              message.success('提交成功');
              resolve(true);
            })
            .catch(() => {
              resolve(false);
            });
        } else {
          message.warning('可拆分金额不够！');
          resolve(false);
        }
      } else {
        resolve(false);
      }
    });
  };

  return (
    <MyPageContainer
      title={
        <Space
          style={{ cursor: 'pointer' }}
          onClick={() => {
            navigate(-1);
          }}
        >
          {title}
        </Space>
      }
      enableTabs={false}
      tabKey="charge-standards-create"
      tabLabel={title}
    >
      <ProCard>
        <div style={{ width: 1200, minHeight: '83vh', margin: '0 auto' }}>
          <Steps
            current={currentStep}
            items={[
              {
                title: '合同信息',
                description: '填写合同基本信息',
              },
              {
                title: '账单设置',
                description: '生成合同账单',
              },
            ]}
            style={{ marginBottom: 30 }}
          />

          {/* 第一步：合同信息填写 */}
          {currentStep === 0 && (
            <BetaSchemaForm<ApiTypes.Contract.Contracts.Store>
              {...MyModalFormProps.props}
              title={title}
              // 基础表单
              layoutType="form"
              width="800px"
              layout="horizontal"
              labelCol={{ span: 4 }}
              wrapperCol={{ span: 20 }}
              labelAlign="left"
              form={form}
              submitter={{
                render: () => {
                  const values = form.getFieldsValue();
                  const incomeExpenseType = values?.income_expense_type;
                  return [
                    incomeExpenseType !== 'None' && (
                      <MyButtons.Default
                        key="Review"
                        size="middle"
                        type="primary"
                        onClick={() => {
                          // 先保存合同，然后显示提审弹窗
                          form?.validateFields().then(() => {
                            onSave(values);
                          });
                        }}
                        title="下一步"
                      />
                    ),
                    incomeExpenseType === 'None' && (
                      <MyButtons.Default
                        key="DirectSubmit"
                        size="middle"
                        type="primary"
                        onClick={() => {
                          // 先保存合同，然后显示提审弹窗
                          const values = form.getFieldsValue();
                          values?.peoples?.forEach((res: any) => {
                            res.company_suppliers_id =
                              res?.counterparty?.split('：')?.[0];
                          });
                          form?.validateFields().then(() => {
                            // 调用保存合同的API
                            Apis.Contract.Contracts.Store({
                              ...values,
                              sign_department:
                                values.organization?.[
                                  values.organization?.length - 1
                                ],
                              is_deposit: values.is_deposit
                                ? IsDepositEnum[
                                    values.is_deposit as keyof typeof IsDepositEnum
                                  ].value
                                : false,
                              start_time: dayjs(
                                values.contract_time?.[0],
                              ).format('YYYY-MM-DD'),
                              end_time: dayjs(values.contract_time?.[1]).format(
                                'YYYY-MM-DD',
                              ),
                              asset_projects_id: values.asset_projects_id,
                            })
                              .then((res: any) => {
                                const id = res.data.id;
                                setContractId(id);
                                setSubmitModalVisible(true);
                              })
                              .catch((error) => {
                                if (error !== '未获取到合同ID') {
                                  message.error('操作失败，请重试');
                                }
                              });
                          });
                        }}
                        title="保存并提审"
                      />
                    ),
                  ];
                },
              }}
              onFinish={async (values: any) => {
                onSave(values);
              }}
              columns={[
                {
                  valueType: 'divider',
                  fieldProps: {
                    orientation: 'left',
                    children: '基本信息',
                  },
                },
                MyFormItems.EnumRadio({
                  key: 'income_expense_type',
                  title: '收支类型',
                  valueEnum: ContractTemplatesIncomeExpenseTypeEnum,
                  colProps: { span: 12 },
                  formItemProps: {
                    ...rulesHelper.text,
                    labelCol: { span: 8 },
                    wrapperCol: { span: 16 },
                  },
                  fieldProps: {
                    buttonStyle: 'solid',
                    onChange: () => {
                      // 切换计量单位时清空计费模式
                      form.setFieldValue('settlement_mode', undefined);
                      form.setFieldValue('total_amount', undefined);
                    },
                  },
                }),
                {
                  key: 'name',
                  title: '合同名称',
                  colProps: { span: 24 },
                  formItemProps: { ...rulesHelper.text },
                },
                {
                  key: 'contract_time',
                  title: '合同有效期',
                  valueType: 'dateRange',
                  colProps: { span: 24 },
                  fieldProps: {
                    style: { width: '50%' },
                    format: 'YYYY-MM-DD',
                  },
                  formItemProps: { ...rulesHelper.text },
                },
                MyFormItems.EnumRadio({
                  key: 'contract_nature',
                  title: '合同性质',
                  valueEnum: ContractsContractNatureEnum,
                  colProps: { span: 12 },
                  formItemProps: {
                    ...rulesHelper.text,
                    labelCol: { span: 8 },
                    wrapperCol: { span: 16 },
                  },
                }),
                SelectContract.ContractTypes({
                  title: '合同类型',
                  key: 'contract_types_id',
                  required: true,
                  colProps: { span: 12 },
                  fieldProps: {
                    placeholder: '请选择合同类型',
                  },
                  formItemProps: {
                    ...rulesHelper.text,
                    labelCol: { span: 8 },
                    wrapperCol: { span: 16 },
                  },
                }),
                {
                  valueType: 'dependency',
                  name: ['income_expense_type'],
                  columns: ({ income_expense_type }) => {
                    return income_expense_type === 'None'
                      ? []
                      : [
                          MyFormItems.EnumRadio({
                            key: 'settlement_mode',
                            title: '结算模式',
                            valueEnum: ContractsSettlementModeEnum,
                            colProps: { span: 12 },
                            formItemProps: {
                              ...rulesHelper.text,
                              labelCol: { span: 8 },
                              wrapperCol: { span: 16 },
                            },
                          }),
                          {
                            title: '合同总金额',
                            key: 'total_amount',
                            valueType: 'digit',
                            colProps: { span: 12 },
                            formItemProps: {
                              ...rulesHelper.number,
                              labelCol: { span: 8 },
                              wrapperCol: { span: 16 },
                            },
                            fieldProps: {
                              style: { width: '100%' },
                              addonAfter: '元',
                            },
                          },
                          MyFormItems.EnumRadio({
                            key: 'is_deposit',
                            title: '是否有保证金',
                            valueEnum: IsDepositEnum,
                            colProps: { span: 12 },
                            formItemProps: {
                              ...rulesHelper.text,
                              labelCol: { span: 8 },
                              wrapperCol: { span: 16 },
                            },
                          }),
                          {
                            valueType: 'dependency',
                            name: ['is_deposit'],
                            columns: ({ is_deposit }) => {
                              return is_deposit === 'yes'
                                ? [
                                    {
                                      title: '请输入保证金',
                                      key: 'deposit_amount',
                                      valueType: 'digit',
                                      colProps: { span: 12 },
                                      formItemProps: {
                                        ...rulesHelper.number,
                                        labelCol: { span: 12 },
                                        wrapperCol: { span: 12 },
                                      },
                                      fieldProps: {
                                        style: { width: '100%' },
                                        suffix: '元',
                                      },
                                    },
                                  ]
                                : [];
                            },
                          },
                        ];
                  },
                },

                SelectContract.SupplierName({
                  key: 'sign_subject',
                  title: '选择签约主体',
                  params: {
                    counterparty: 'InternalCompany',
                  },
                  colProps: { span: 24 },
                  required: true,
                }),
                SelectContract.AssetProjects({
                  key: 'asset_projects_id',
                  title: '选择关联项目',
                  colProps: { span: 24 },
                  required: true,
                  fieldProps: {
                    showSearch: true,
                    // mode: 'multiple',
                  },
                }),
                SelectContract.EmployeeName({
                  key: 'contract_liaison',
                  title: '合同对接人',
                  colProps: { span: 24 },
                  required: true,
                }),
                {
                  title: '合同份数',
                  key: 'number_contract_copies',
                  valueType: 'digit',
                  colProps: { span: 24 },
                  formItemProps: { ...rulesHelper.number },
                  fieldProps: {
                    style: { width: '100%' },
                  },
                },
                {
                  valueType: 'dependency',
                  name: ['contract_time'],
                  columns: ({ contract_time }) => {
                    return contract_time?.length
                      ? [
                          {
                            colProps: { span: 24 },
                            title: '关联资源',
                            key: 'resources_id',
                            renderFormItem: () => {
                              return (
                                <ProCard bordered>
                                  <Space>
                                    <ModalsResourceSelectList
                                      item={{
                                        contract_start_date: contract_time?.[0],
                                        contract_end_date: contract_time?.[1],
                                      }}
                                      onChange={(e: any) => {
                                        setSelectedRow(e);
                                        form.setFieldsValue({
                                          resources_id: e?.id,
                                        });
                                      }}
                                    />
                                    {selectedRow?.name ? (
                                      <div>
                                        已选择
                                        {
                                          ResourceTypesCategoryEnum[
                                            selectedRow?.category as keyof typeof ResourceTypesCategoryEnum
                                          ]?.text
                                        }
                                        资源：{selectedRow?.name}
                                      </div>
                                    ) : (
                                      ''
                                    )}
                                  </Space>
                                </ProCard>
                              );
                            },
                          },
                        ]
                      : [];
                  },
                },

                {
                  valueType: 'divider',
                  fieldProps: {
                    orientation: 'left',
                    children: (
                      <>
                        <span style={{ color: '#ff4d4f', marginLeft: 4 }}>
                          *
                        </span>
                        交易方信息
                      </>
                    ),
                  },
                },
                {
                  valueType: 'formList',
                  dataIndex: 'peoples',
                  title: '',
                  fieldProps: {
                    copyIconProps: false,
                    // deleteIconProps: false,
                  },
                  formItemProps: {
                    ...rulesHelper.array,
                    wrapperCol: { span: 24 },
                  },
                  initialValue: [
                    {
                      sign_party: null,
                      counterparty_type: null,
                      counterparty: null,
                    },
                    {
                      sign_party: null,
                      counterparty_type: null,
                      counterparty: null,
                    },
                  ],
                  columns: [
                    {
                      valueType: 'group',
                      colProps: { span: 24 },
                      columns: [
                        MyFormItems.EnumSelect({
                          key: 'sign_party',
                          // title: `交易方`,
                          valueEnum: ContractPeoplesSignPartyEnum,
                          colProps: { span: 6 },
                          formItemProps: {
                            ...rulesHelper.text,
                            wrapperCol: { span: 24 },
                          },
                          fieldProps: {
                            placeholder: '请选择签约方',
                          },
                        }),
                        MyFormItems.EnumSelect({
                          key: 'counterparty_type',
                          title: '',
                          valueEnum: CompanySuppliersCounterpartyEnum,
                          colProps: { span: 6 },
                          formItemProps: {
                            ...rulesHelper.text,
                            wrapperCol: { span: 24 },
                          },
                        }),
                        {
                          valueType: 'dependency',
                          name: ['counterparty_type'],
                          columns: ({ counterparty_type }) => {
                            return counterparty_type === 'Supplier'
                              ? [
                                  SelectContract.SupplierName({
                                    key: 'counterparty',
                                    title: '',
                                    params: {
                                      counterparty: 'Supplier',
                                    },
                                    colProps: { span: 12 },
                                    formItemProps: {
                                      ...rulesHelper.text,
                                      wrapperCol: { span: 24 },
                                    },
                                    required: true,
                                    fieldProps: {
                                      placeholder: '请选择签约主体',
                                    },
                                  }),
                                ]
                              : counterparty_type === 'InternalCompany'
                              ? [
                                  SelectContract.SupplierName({
                                    key: 'counterparty',
                                    title: '',
                                    params: {
                                      counterparty: 'InternalCompany',
                                    },
                                    colProps: { span: 12 },
                                    formItemProps: {
                                      ...rulesHelper.text,
                                      wrapperCol: { span: 24 },
                                    },
                                    required: true,
                                    fieldProps: {
                                      placeholder: '请选择签约主体',
                                    },
                                  }),
                                ]
                              : [
                                  SelectContract.SupplierName({
                                    key: 'counterparty',
                                    title: '',
                                    params: {
                                      counterparty: 'InternalCompany',
                                    },
                                    colProps: { span: 12 },
                                    formItemProps: {
                                      ...rulesHelper.text,
                                      wrapperCol: { span: 24 },
                                    },
                                    required: true,
                                    fieldProps: {
                                      placeholder: '请选择签约主体',
                                      disabled: true,
                                    },
                                  }),
                                ];
                          },
                        },
                      ],
                    },
                  ],
                },

                {
                  valueType: 'divider',
                  fieldProps: {
                    orientation: 'left',
                    children: '合同附件',
                  },
                },
                MyFormItems.UploadImages({
                  key: 'attachments',
                  title: '上传附件',
                  tooltip: '支持上传任意格式的文件',
                  uploadType: 'file',
                  colProps: { span: 24 },
                  // accept: '.docx,.doc,.pdf',
                  max: 100,
                  required: true,
                }),

                {
                  valueType: 'divider',
                  fieldProps: {
                    orientation: 'left',
                    children: '印章申请',
                  },
                },
                SelectContract.ContractSeals({
                  key: 'seal_info',
                  required: true,
                  title: '选择印章',
                  colProps: { span: 24 },
                  fieldProps: {
                    showSearch: true,
                    mode: 'multiple',
                  },
                }),
              ]}
            />
          )}

          {/* 第二步：账单设置 */}
          {currentStep === 1 && (
            <BetaSchemaForm<ApiTypes.Contract.ContractBills.Store>
              {...MyModalFormProps.props}
              wrapperCol={{ span: 24 }}
              width="1200px"
              layoutType="Form"
              onFinish={async (values: any) => {
                handleBillsSubmit(values);
              }}
              submitter={{
                render: (props) => {
                  return [
                    <MyButtons.Default
                      key="Back"
                      size="middle"
                      type="default"
                      onClick={() => {
                        setCurrentStep(0);
                      }}
                      title="上一步"
                    />,
                    // <MyButtons.Default
                    //   key="Review"
                    //   size="middle"
                    //   type="primary"
                    //   onClick={() => {
                    //     props.submit();
                    //   }}
                    //   title="提交"
                    // />,
                    <MyButtons.Default
                      key="SubmitApproval"
                      size="middle"
                      type="primary"
                      onClick={() => {
                        // 先提交账单，然后显示提审弹窗
                        const formInstance = props?.form;
                        formInstance?.validateFields().then(() => {
                          const values = formInstance.getFieldsValue();
                          handleBillsSubmit(values).then((success) => {
                            if (success) {
                              setSubmitModalVisible(true);
                            }
                          });
                        });
                      }}
                      title="提交并审核"
                    />,
                  ];
                },
              }}
              columns={[
                {
                  colProps: { span: 24 },
                  renderFormItem: () => {
                    return (
                      <ProCard
                        bordered
                        type="inner"
                        title={`已选择：${contractData?.name} ｜ ${contractData?.code}`}
                        headerBordered
                      >
                        <Space
                          size="middle"
                          direction="vertical"
                          style={{ width: '100%' }}
                        >
                          <div style={{ display: 'flex', gap: 40 }}>
                            <div>
                              <strong>收支类型：</strong>
                              {contractData?.income_expense_type === 'Income'
                                ? '收入'
                                : '支出'}
                            </div>
                            <div>
                              <strong>结算模式：</strong>
                              {contractData?.settlement_mode ===
                              'LumpSumContract'
                                ? '总价合同'
                                : '开口合同'}
                            </div>
                            <div>
                              <strong>总金额：</strong>¥
                              {contractData?.total_amount}
                            </div>
                            <div>
                              <strong>剩余可生成账单金额：</strong>
                              {contractData?.settlement_mode ===
                                'LumpSumContract' && (
                                <span style={{ color: 'red' }}>
                                  ¥{totalBillSeparableAmount()}
                                </span>
                              )}
                            </div>
                          </div>
                        </Space>
                      </ProCard>
                    );
                  },
                },
                {
                  valueType: 'divider',
                  title: '账单设置',
                  fieldProps: {
                    orientation: 'left',
                    children: '账单设置',
                  },
                },

                {
                  title: '收款方',
                  valueType: 'select',
                  dataIndex: 'payee',
                  colProps: { span: 12 },
                  formItemProps: { ...rulesHelper.text },
                  fieldProps: {
                    options: contractData?.peoples
                      ?.filter((item: any) => {
                        // 当收入类型为Income时，只显示内部公司
                        if (contractData?.income_expense_type === 'Income') {
                          return item?.counterparty_type === 'InternalCompany';
                        }
                        // 其他情况显示所有
                        return item?.counterparty_type === 'Supplier';
                      })
                      .map((item: any) => ({
                        label: item?.counterparty,
                        value: item?.counterparty,
                      })),
                  },
                },
                {
                  title: '付款方',
                  valueType: 'select',
                  dataIndex: 'payer',
                  colProps: { span: 12 },
                  formItemProps: { ...rulesHelper.text },
                  fieldProps: {
                    options: contractData?.peoples
                      ?.filter((item: any) => {
                        // 当收入类型为Income时，只显示内部公司
                        if (contractData?.income_expense_type === 'Expense') {
                          return item?.counterparty_type === 'InternalCompany';
                        }
                        // 其他情况显示所有
                        return item?.counterparty_type === 'Supplier';
                      })
                      .map((item: any) => ({
                        label: item?.counterparty,
                        value: item?.counterparty,
                      })),
                  },
                },
                {
                  valueType: 'formList',
                  dataIndex: 'bills',
                  // title: '账单设置',
                  formItemProps: { ...rulesHelper.array },
                  fieldProps: {
                    copyIconProps: false,
                    // deleteIconProps: false,
                    creatorRecord: {
                      cost_type: contractData?.income_expense_type,
                    },
                  },
                  columns: [
                    {
                      valueType: 'group',
                      colProps: { span: 24 },
                      columns: [
                        {
                          title: '类型',
                          dataIndex: 'cost_type',
                          colProps: { span: 2 },
                          align: 'center',
                          renderFormItem: () => {
                            let res = {
                              text:
                                contractData?.income_expense_type === 'Income'
                                  ? '收入'
                                  : '支出',
                              color:
                                contractData?.income_expense_type === 'Income'
                                  ? 'green'
                                  : 'blue',
                            };
                            return contractData?.income_expense_type ? (
                              <span
                                style={{
                                  padding: '2px 8px',
                                  backgroundColor: res?.color,
                                  color: 'white',
                                  borderRadius: 4,
                                }}
                              >
                                {res?.text}
                              </span>
                            ) : (
                              '-'
                            );
                          },
                        },
                        {
                          title: '账单年月',
                          valueType: 'dateMonth',
                          dataIndex: 'year_month',
                          colProps: { span: 3 },
                          formItemProps: { ...rulesHelper.text },
                          fieldProps: {
                            style: {
                              width: '100%',
                            },
                          },
                        },
                        {
                          title: '期数',
                          valueType: 'digit',
                          dataIndex: 'period_num',
                          colProps: { span: 2 },
                          formItemProps: { ...rulesHelper.number },
                          fieldProps: {
                            style: {
                              width: '100%',
                              maxLength: 2,
                            },
                          },
                        },
                        {
                          title: '账单金额',
                          valueType: 'digit',
                          dataIndex: 'amount',
                          colProps: { span: 4 },
                          formItemProps: { ...rulesHelper.number },
                          fieldProps: {
                            style: {
                              width: '100%',
                            },
                            addonAfter: '元',
                          },
                        },
                        {
                          title: '关联标地',
                          formItemProps: { ...rulesHelper.text },
                          dataIndex: 'object_name',
                          colProps: { span: 8 },
                        },
                        {
                          title: '备注',
                          dataIndex: 'remark',
                          colProps: { span: 5 },
                        },
                      ],
                    },
                  ],
                },
              ]}
            />
          )}

          {/* 提审弹窗 */}
          <MySubmitApproval
            open={submitModalVisible}
            item={{ type: 'Contract', contracts_id: contractId }}
            onCancel={() => {
              setSubmitModalVisible(false);
            }}
            reload={() => {
              setSubmitModalVisible(false);
              navigate('/contract/contracts');
            }}
          />
        </div>
      </ProCard>
    </MyPageContainer>
  );
}
