import { MyColumns, MyPageContainer, MyProTableProps } from '@/common';
import { Apis } from '@/gen/Apis';
import {
  ApprovalInstancesStatusEnum,
  ApprovalTemplatesTypeEnum,
} from '@/gen/Enums';
import { ProTable } from '@ant-design/pro-components';
import { Space } from 'antd';
import Show from './modals/Show';
export default function Index({ title = '抄送我的' }) {
  return (
    <MyPageContainer
      title={title}
      enableTabs={true}
      tabKey="my_apply_list"
      tabLabel={title}
    >
      <ProTable
        {...MyProTableProps.props}
        request={async (params, sort) =>
          MyProTableProps.request(
            params,
            sort,
            Apis.Approval.ApprovalInstances.CcList,
          )
        }
        headerTitle={title}
        columns={[
          MyColumns.ID({ search: false }),
          {
            title: '申请事项',
            dataIndex: 'title',
            search: false,
          },
          {
            title: '关联项目',
            dataIndex: ['asset_project', 'name'],
            search: false,
          },
          MyColumns.EnumTag({
            title: '状态',
            dataIndex: 'status',
            valueEnum: ApprovalInstancesStatusEnum,
          }),
          MyColumns.EnumTag({
            dataIndex: 'type',
            title: '业务类型',
            valueEnum: ApprovalTemplatesTypeEnum,
            search: false,
          }),

          // {
          //   title: '项目ID',
          //   dataIndex: 'asset_projects_id',
          //   hidden: true,
          // },
          // {
          //   title: '申请人',
          //   dataIndex: 'applicant_name',
          //   search: false,
          // },
          MyColumns.CreatedAt(),
          MyColumns.Option({
            render: (_, item: any, index, action) => (
              <Space key={index}>
                <Show item={item} reload={action?.reload} title={title} />
              </Space>
            ),
          }),
        ]}
      />
    </MyPageContainer>
  );
}
