import { MyBetaModalFormProps, MyColumns, MyProTableProps } from '@/common';
import { Apis } from '@/gen/Apis';
import { ContractBillObjectsStatusEnum } from '@/gen/Enums';
import { ProTable } from '@ant-design/pro-components';
import { Space } from 'antd';
import MyCompleteApply from '../../../contract_bills/modals/CompleteApply';
export default function Index(props: MyBetaModalFormProps) {
  return (
    <ProTable
      {...MyProTableProps.props}
      request={async (params, sort) =>
        MyProTableProps.request(
          { ...params, contracts_id: props?.item?.id },
          sort,
          Apis.Contract.ContractBillObjects.List,
        )
      }
      headerTitle="合同标的"
      search={false}
      columns={[
        MyColumns.ID({
          search: false,
        }),

        {
          title: '名称',
          dataIndex: 'name',
        },
        MyColumns.EnumTag({
          title: '状态',
          dataIndex: 'status',
          valueEnum: ContractBillObjectsStatusEnum,
        }),
        {
          title: '金额',
          dataIndex: 'amount',
          render: (_, item: any) => {
            return `¥${item?.amount || 0}`;
          },
        },
        MyColumns.Option({
          render: (_, item: any, index, action) => (
            <Space key={`item_${index}`}>
              <MyCompleteApply
                item={{
                  id: item?.contract_bills_id,
                  typeSource: '标地',
                  status: item?.status,
                }}
                reload={action?.reload}
                title="申请付款"
              />
            </Space>
          ),
        }),
      ]}
    />
  );
}
