import { MyBetaModalFormProps, MyColumns, MyProTableProps } from '@/common';
import { Apis } from '@/gen/Apis';
import { ContractsStatusEnum } from '@/gen/Enums';
import { ProTable } from '@ant-design/pro-components';
import dayjs from 'dayjs';

export default function Index(props: MyBetaModalFormProps) {
  return (
    <ProTable<Record<any, any>>
      {...MyProTableProps.props}
      request={async (params, sort) =>
        MyProTableProps.request(
          {
            params,
            is_agreement: true,
            parent_id: props?.item?.id,
          },
          sort,
          Apis.Contract.Contracts.List,
        )
      }
      headerTitle="补充协议"
      search={false}
      columns={[
        MyColumns.ID({ search: false }),
        MyColumns.EnumTag({
          title: '合同状态',
          dataIndex: 'status',
          valueEnum: ContractsStatusEnum,
        }),
        {
          title: '合同编号',
          dataIndex: 'code',
        },
        {
          title: '合同名称',
          dataIndex: 'name',
        },

        {
          title: '有效期',
          search: false,
          render: (_, item: any) => {
            return `${dayjs(item.start_time).format('YYYY-MM-DD')}至${dayjs(
              item.end_time,
            ).format('YYYY-MM-DD')}`;
          },
        },
        {
          title: '关联项目',
          dataIndex: ['asset_project', 'name'],

          search: false,
        },
        {
          title: '合同对接人',
          dataIndex: 'contract_liaison',
          search: false,
        },
        {
          title: '用印日期',
          dataIndex: 'sign_time',
          valueType: 'date',
        },
        MyColumns.CreatedAt(),
      ]}
    />
  );
}
