@page "/Project/ProjectSearch"
@attribute [Authorize]
<PageContainer>
    <Breadcrumb>
        <Breadcrumb>
            <BreadcrumbItem>
                <a href="/Home"><Icon Type="home"></Icon></a>
            </BreadcrumbItem>
            <BreadcrumbItem>
                <span>我的专案</span>
            </BreadcrumbItem>
        </Breadcrumb>
    </Breadcrumb>
    <Content></Content>
    <ChildContent>
        @if (ProjectInfos == null)
        {
            <center><Spin /></center>

        }
        else
        {

            <AntDesign.Table @ref="table" @bind-PageIndex="@_pageIndex" @bind-PageSize="@_pageSize" Total="@_total"
                             TItem="ProjectInfo"
                             Loading="_loading"
                             DataSource="@ProjectInfos"
                             Bordered=@true
                             Size=@TableSize.Middle>
                <ChildContent>
                    @*<Selection Key="@(context.CaseNo)" />*@
                    <AntDesign.Column Title="序号" TData="int" Width="70">
                        @serialNumber(_pageIndex, _pageSize, context.CaseNo)
                    </AntDesign.Column>
                    <AntDesign.Column Title="我方文号" @bind-Field="@context.CaseNo" Sortable Filterable />
                    <AntDesign.Column Title="案件名称" @bind-Field="@context.CaseName" Format="yyyy-MM-dd" Sortable Filterable />
                    <AntDesign.Column Title="案件类型" Field="@context.CaseType" Sortable Filterable />
                    <AntDesign.Column Title="业务类型" @bind-Field="@context.BusinessType" Sortable Filterable />
                    <AntDesign.Column Title="客户" TData="string" DataIndex=@("Customer.Name") Sortable Filterable />
                    <AntDesign.Column Title="案件状态" TData="string" Sortable Filterable>
                        <Template>
                            <span>@(context.CaseState==0?"处理中":"已完成")</span>
                        </Template>
                    </AntDesign.Column>
                    <ActionColumn>
                        <Space>
                            @if (context.CaseState == 0)
                            {
                                <SpaceItem><Button Danger OnClick="() => SetFinished(context.CaseNo)">设为已完成</Button></SpaceItem>
                            }
                        </Space>
                    </ActionColumn>
                </ChildContent>
                <PaginationTemplate>
                    <div style="display: flex; align-items: center">
                        <Pagination Class="my-custom-pagination"
                                    Total="@_total"
                                    PageSize="@_pageSize"
                                    Current="@_pageIndex"
                                    ShowSizeChanger="@true"
                                    OnChange="HandlePageChange" />
                    </div>
                </PaginationTemplate>
            </AntDesign.Table>

        }

    </ChildContent>
</PageContainer>
<style>
    .my-custom-pagination {
        margin: 15px 0;
    }

        .my-custom-pagination .ant-pagination-item,
        .my-custom-pagination .ant-pagination-item-link {
            border-radius: 100%;
        }
</style>