@page "/Project/MyProjects"
@attribute [Authorize]

<PageContainer>
    <Breadcrumb>
        <Breadcrumb>
            <BreadcrumbItem>
                <a href="/Home"><Icon Type="home"></Icon></a>
            </BreadcrumbItem>
            <BreadcrumbItem>
                <span>我的专案</span>
            </BreadcrumbItem>
        </Breadcrumb>
    </Breadcrumb>
    <Content>
        <Button Type="primary" Icon="plus" OnClick="AddNew" Style="float:right">添加工作内容</Button>
    </Content>
    <ChildContent>
        @if (ProjectInfos == null)
        {
            <center><Spin /></center>

        }
        else
        {

            <AntDesign.Table @bind-PageIndex="_pageIndex" @bind-PageSize="_pageSize"
                             Total="@_total"
                             TItem="ProjectContentRecord"
                             Loading="_loading"
                             DataSource="@ProjectInfos"
                             Bordered=@true
                             Size=@TableSize.Middle>
                <RowTemplate>
                    @*<Selection Key="@(context.ProjectNo)" />*@
                    <AntDesign.Column Title="序号" TData="int" Width="60">
                        @serialNumber(_pageIndex, _pageSize, context)
                    </AntDesign.Column>
                    <AntDesign.Column Title="我方文号" @bind-Field="@context.ProjectNo" Sortable Filterable />
                    <AntDesign.Column Title="案件名称" DataIndex="Project.CaseName" TData="string" Sortable Filterable />
                    <AntDesign.Column Title="案件类型" DataIndex="Project.CaseType" TData="string" Sortable Filterable />
                    <AntDesign.Column Title="客户" DataIndex="Project.Customer.Name" TData="string" Sortable Filterable />
                    <AntDesign.Column Title="绩效月份" TData="string" Sortable Filterable>
                        @if (context.CalMonth != null)
                        {
                            @($"{context.CalMonth.Year}年{context.CalMonth.Month}月")
                        }
                    </AntDesign.Column>
                    <AntDesign.Column Title="最终绩效" TData="string">
                        @FininalJX(context)
                    </AntDesign.Column>
                    <AntDesign.Column Title="业务类型" DataIndex="Project.BusinessType" TData="string" Sortable Filterable />
                    <AntDesign.Column Title="状态" TData="string">
                        @getStatus(context.State)
                    </AntDesign.Column>
                    <ActionColumn>
                        <Space>
                            @if (context.State == 0)
                            {
                                <SpaceItem><Button Danger OnClick="() => Edit(context)">修改</Button></SpaceItem>
                                <SpaceItem><Button Danger OnClick="() => Submit(context)">提交审核</Button></SpaceItem>
                            }
                        </Space>
                    </ActionColumn>
                </RowTemplate>
                <ExpandTemplate>
                    <Table DataSource="context.Data.ProjectWorkContents" Context="pp">
                        <ChildContent>

                            <AntDesign.Column Title="工作内容" TData="string">
                                @pp.Content
                            </AntDesign.Column>
                            <AntDesign.Column Title="工作日期" TData="string">
                                @pp.WorkDate.ToString("yyyy-MM-dd")
                            </AntDesign.Column>
                            <AntDesign.Column Title="时间跨度" TData="string">
                                @pp.TimeSpan 天
                            </AntDesign.Column>
                            <AntDesign.Column Title="耗时" TData="string">
                                @pp.TakeTime 小时
                            </AntDesign.Column>
                            <AntDesign.Column Title="工作难度系数" TData="string">
                                @pp.DifficultFactor
                            </AntDesign.Column>
                            <AntDesign.Column Title="实际绩效" TData="string">
                                @pp.ActualPerformance
                            </AntDesign.Column>
                            <AntDesign.Column Title="最终绩效" TData="string">
                                @pp.FinalPerformance
                            </AntDesign.Column>

                        </ChildContent>
                    </Table>
                </ExpandTemplate>
                <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>