@page "/MyCaseList"
@using wispro.sp.web.Components
@using wispro.sp.share 

@inject IAgentFeedBackMemoItemsService _afService; 

<PageContainer TabList="@tabList" OnTabChange="OnTabChange">
    <Breadcrumb>
        <Breadcrumb>
            <BreadcrumbItem>
                <a href="/Home"><Icon Type="home"></Icon></a>
            </BreadcrumbItem>
            <BreadcrumbItem>
                <Icon Type="setting"></Icon><span>我的绩效清单</span>
            </BreadcrumbItem>

        </Breadcrumb>
    </Breadcrumb>
    

        <ChildContent>

            <Card>
                @*<Pagination @bind-Current="@_pageIndex" @bind-Total="@_total" ShowSizeChanger OnChange="OnChange" />*@
                @if (_Datas == null)
                {
                    <center><Spin /></center>
                }
                else
                {
                    if (_CurrentKey == "myList")
                    {
                        <PageHeader>
                            <PageHeaderTitle>基础点数统计</PageHeaderTitle>
                            <PageHeaderExtra><Button Type="@ButtonType.Primary">缺失数据提报</Button></PageHeaderExtra>
                            <PageHeaderContent>
                                <div style="border:1px solid #000000">
                                    <AntDesign.Row Align="center" Justify="center">
                                        <AntDesign.Col Span="2" style="border-left:1px solid #000000"><center></center></AntDesign.Col>
                                        <AntDesign.Col Span="4" style="border:1px solid #000000"><center>新申请</center></AntDesign.Col>
                                        <AntDesign.Col Span="4" style="border:1px solid #000000"><center>OA(国内、涉外)</center></AntDesign.Col>
                                        <AntDesign.Col Span="4" style="border:1px solid #000000"><center>其它</center></AntDesign.Col>
                                        <AntDesign.Col Span="2" style="border:1px solid #000000"></AntDesign.Col>
                                        <AntDesign.Col Span="4" style="border:1px solid #000000">一次OA授权</AntDesign.Col>
                                        <AntDesign.Col Span="4" style="border:1px solid #000000"></AntDesign.Col>
                                    </AntDesign.Row>
                                    <AntDesign.Row>
                                        <AntDesign.Col Span="2" style="border:1px solid #000000"><center>代理人</center></AntDesign.Col>
                                        <AntDesign.Col Span="2" style="border:1px solid #000000"><center>承办</center></AntDesign.Col>
                                        <AntDesign.Col Span="2" style="border:1px solid #000000"><center>核稿</center></AntDesign.Col>
                                        <AntDesign.Col Span="2" style="border:1px solid #000000"><center>承办</center></AntDesign.Col>
                                        <AntDesign.Col Span="2" style="border:1px solid #000000"><center>核稿</center></AntDesign.Col>
                                        <AntDesign.Col Span="2" style="border:1px solid #000000"><center>承办</center></AntDesign.Col>
                                        <AntDesign.Col Span="2" style="border:1px solid #000000"><center>核稿</center></AntDesign.Col>
                                        <AntDesign.Col Span="2" style="border:1px solid #000000"><center>调查案</center></AntDesign.Col>
                                        <AntDesign.Col Span="2" style="border:1px solid #000000"><center>承办人</center></AntDesign.Col>
                                        <AntDesign.Col Span="2" style="border:1px solid #000000"><center>审核人</center></AntDesign.Col>
                                        <AntDesign.Col Span="4" style="border:1px solid #000000"><center>总计</center></AntDesign.Col>
                                    </AntDesign.Row>
                                    <AntDesign.Row>
                                        <AntDesign.Col Span="2" style="border:1px solid #000000"><center>@_userService.CurrentUser.Name</center></AntDesign.Col>
                                        <AntDesign.Col Span="2" style="border:1px solid #000000"><center>@GetStatistics("新申请处理")</center></AntDesign.Col>
                                        <AntDesign.Col Span="2" style="border:1px solid #000000"><center>@GetStatistics("新申请审核")</center></AntDesign.Col>
                                        <AntDesign.Col Span="2" style="border:1px solid #000000"><center>@GetStatistics("OA处理")</center></AntDesign.Col>
                                        <AntDesign.Col Span="2" style="border:1px solid #000000"><center>@GetStatistics("OA审核")</center></AntDesign.Col>
                                        <AntDesign.Col Span="2" style="border:1px solid #000000"><center>@GetStatistics("其它处理")</center></AntDesign.Col>
                                        <AntDesign.Col Span="2" style="border:1px solid #000000"><center>@GetStatistics("其它审核")</center></AntDesign.Col>
                                        <AntDesign.Col Span="2" style="border:1px solid #000000"><center></center></AntDesign.Col>
                                        <AntDesign.Col Span="2" style="border:1px solid #000000"><center>@GetStatistics("一次OA授权处理")</center></AntDesign.Col>
                                        <AntDesign.Col Span="2" style="border:1px solid #000000"><center>@GetStatistics("一次OA授权审核")</center></AntDesign.Col>
                                        <AntDesign.Col Span="4" style="border:1px solid #000000"><center>@GetStatistics("ALL")</center></AntDesign.Col>
                                    </AntDesign.Row>

                                </div>
                            </PageHeaderContent>
                        </PageHeader>

                        <AntDesign.Table DataSource="_Datas" TItem="PerformanceItem" @ref="@table"
                                         @bind-PageIndex="_pageIndex"
                                         @bind-PageSize="_pageSize"
                                         Total="_total"
                                         ScrollX="1150" Size="TableSize.Small" Bordered
                                         @bind-SelectedRows="selectedItems"
                                         OnRow="OnRow"
                                         Loading="_loading"
                                         RowClassName="@(x => x.Data.isDanger() ? "danger" : "")"
                                         OnChange="HandleTableChange" RemoteDataSource>
                            <RowTemplate>
                                <AntDesign.Selection Key="@(context.Id.ToString())" Width="50" Fixed="left" />
                                <AntDesign.Column Title="序号" TData="int" Width="50" Fixed="left">
                                    @serialNumber(_pageIndex, _pageSize, context.Id)
                                </AntDesign.Column>
                                <AntDesign.Column Title="基础点数" TData="string" Width="100">@(context.BasePoint == null ? "" : context.BasePoint)</AntDesign.Column>
                                <AntDesign.Column Title="我方文号" @bind-Field="@context.CaseNo" Width="150" Sortable Filterable />
                                <AntDesign.Column Title="案件类型" @bind-Field="@context.CaseType" Width="120" Sortable Filterable />
                                <AntDesign.Column Title="案件系数"
                                                  @bind-Field="@context.CaseCoefficient" Width="120"
                                                  Filters="CaseCoeFilters"
                                                  FilterMultiple="false"
                                                  OnFilter="((value,name)=>name.StartsWith(value))"
                                                  Sortable />
                                <AntDesign.Column Title="处理事项" @bind-Field="@context.DoItem" Width="150" Sortable Filterable />
                                <AntDesign.Column Title="处理事项系数" @bind-Field="@context.DoItemCoefficient" Width="150" Sortable Filterable />
                                <AntDesign.Column Title="案件阶段" @bind-Field="@context.CaseStage" Width="100"></AntDesign.Column>
                                <AntDesign.Column Title="绩效特殊字段" @bind-Field="@context.AgentFeedbackMemo" Width="250" />
                                <AntDesign.Column Title="处理人" TData="string" DataIndex="@nameof(context.ItemStaffs)" Width="150">
                                    @if (context.ItemStaffs != null)
                                    {
                                        foreach (ItemStaff itemStaff in context.ItemStaffs)
                                        {
                                            <span>@(itemStaff.DoPerson.Name)&nbsp;</span>
                                        }
                                    }
                                </AntDesign.Column>
                                <AntDesign.Column Title="核稿人" TData="string" Width="100">@(context.Reviewer == null ? "" : context.Reviewer.Name)</AntDesign.Column>

                                <ActionColumn Fixed="right" Title="操作" Width="120">
                                    <Space>
                                        <SpaceItem>
                                            <AntDesign.Dropdown>
                                                <Overlay>
                                                    <Menu>
                                                        @foreach (var apType in apTypeService.GetItems(context))
                                                        {
                                                            <MenuItem @key="@($"{context.Id}-{apType.Id}")" OnClick="()=>ShowModel(context,apType)">@apType.Name</MenuItem>
                                                        }

                                                    </Menu>
                                                </Overlay>
                                                <ChildContent>
                                                    <Button Type="Primary">...</Button>
                                                </ChildContent>
                                            </AntDesign.Dropdown>
                                        </SpaceItem>
                                    </Space>

                                </ActionColumn>
                            </RowTemplate>
                            <ExpandTemplate>
                                <div style="width:1000px;margin-left:30px;">
                                    <Card Title=@("详情")>
                                        <Body>
                                            <Descriptions Bordered Size="@DescriptionsSize.Small">
                                                <DescriptionsItem Title="绩效特殊字段" Span="3">
                                                    <Select DataSource="@_afService.GetItems(context.Data)"
                                                            @bind-Value="@context.Data.AgentFeedbackMemo"
                                                            LabelName="@nameof(Reason.Name)"
                                                            ValueName="@nameof(Reason.Value)"
                                                            Placeholder="请选项一项"
                                                            DefaultActiveFirstItem="false"
                                                            EnableSearch="true"
                                                            AllowClear="true"
                                                            Style="width:220px;"
                                                            OnSelectedItemChanged="SelectChanged"
                                                            OnClearSelected="() => ClearSelect(context.Data.Id)"
                                                            OnFocus="() => OnFocus(context.Data)">
                                                    </Select>
                                                </DescriptionsItem>
                                                <DescriptionsItem Title="完成时间">@(context.Data.FinishedDate.HasValue ? context.Data.FinishedDate.Value.ToString("yyyy-MM-dd") : "")</DescriptionsItem>
                                                <DescriptionsItem Title="返稿日">@(context.Data.ReturnDate.HasValue ? context.Data.ReturnDate.Value.ToString("yyyy-MM-dd") : "")</DescriptionsItem>
                                                <DescriptionsItem Title="客户期限">@(context.Data.CustomerLimitDate.HasValue ? context.Data.CustomerLimitDate.Value.ToString("yyyy-MM-dd") : "")</DescriptionsItem>
                                                <DescriptionsItem Title="初稿日">@(context.Data.FirstDraftDate.HasValue ? context.Data.FirstDraftDate.Value.ToString("yyyy-MM-dd") : "")</DescriptionsItem>
                                                <DescriptionsItem Title="内部期限">@(context.Data.InternalDate.HasValue ? context.Data.InternalDate.Value.ToString("yyyy-MM-dd") : "")</DescriptionsItem>
                                                <DescriptionsItem Title="案件状态">@context.Data.CaseState</DescriptionsItem>
                                                <DescriptionsItem Title="处理事项备注">@context.Data.DoItemMemo</DescriptionsItem>
                                                <DescriptionsItem Title="案件名称" Span="2">@context.Data.CaseName</DescriptionsItem>
                                                <DescriptionsItem Title="申请人" Span="3">@context.Data.ApplicationName</DescriptionsItem>
                                                <DescriptionsItem Title="备注" Span="3">@context.Data.CaseMemo</DescriptionsItem>

                                            </Descriptions>
                                        </Body>
                                    </Card>
                                </div>
                            </ExpandTemplate>
                        </AntDesign.Table>
                    }
                    else
                    {
                        <AntDesign.Table DataSource="_Datas" TItem="PerformanceItem" @ref="@table"
                                         @bind-PageIndex="_pageIndex"
                                         @bind-PageSize="_pageSize"
                                         Total="_total" ScrollX="1200"
                                         Size="TableSize.Small" Bordered
                                         @bind-SelectedRows="selectedItems"
                                         OnRow="OnRow"
                                         Loading="_loading"
                                         OnChange="HandleTableChange" RemoteDataSource>
                            <RowTemplate>
                                <AntDesign.Selection Key="@(context.Id.ToString())" Width="50" Fixed="left" />
                                <AntDesign.Column Title="序号" TData="int" Width="50" Fixed="left">
                                    @serialNumber(_pageIndex, _pageSize, context.Id)
                                </AntDesign.Column>

                                <AntDesign.Column Title="基础点数" TData="string" Width="100">@(context.BasePoint == null ? "" : context.BasePoint)</AntDesign.Column>
                                <AntDesign.Column Title="我方文号" @bind-Field="@context.CaseNo" Width="150" Sortable Filterable />
                                <AntDesign.Column Title="案件类型" @bind-Field="@context.CaseType" Width="120" Sortable Filterable />
                                <AntDesign.Column Title="案件系数"
                                                  @bind-Field="@context.CaseCoefficient" Width="120"
                                                  Filters="CaseCoeFilters"
                                                  FilterMultiple="false"
                                                  OnFilter="((value,name)=>name.StartsWith(value))"
                                                  Sortable />
                                <AntDesign.Column Title="处理事项" @bind-Field="@context.DoItem" Width="150" Sortable Filterable />
                                <AntDesign.Column Title="处理事项系数" @bind-Field="@context.DoItemCoefficient" Width="150" Sortable Filterable />
                                <AntDesign.Column Title="绩效特殊字段" @bind-Field="@context.AgentFeedbackMemo" Width="250" />
                                <AntDesign.Column Title="案件阶段" @bind-Field="@context.CaseStage" Width="100"></AntDesign.Column>
                                <AntDesign.Column Title="处理人" TData="string" DataIndex="@nameof(context.ItemStaffs)" Width="150">
                                    @if (context.ItemStaffs != null)
                                    {
                                        foreach (ItemStaff itemStaff in context.ItemStaffs)
                                        {
                                            <span>@(itemStaff.DoPerson.Name)&nbsp;</span>
                                        }
                                    }
                                </AntDesign.Column>
                                <AntDesign.Column Title="核稿人" TData="string" Width="100">@(context.Reviewer == null ? "" : context.Reviewer.Name)</AntDesign.Column>
                            </RowTemplate>
                            <ExpandTemplate>
                                <div style="width:1000px;margin-left:30px;">
                                    <Card Title=@("详情")>
                                        <Body>
                                            <Descriptions Bordered Size="@DescriptionsSize.Small">
                                                <DescriptionsItem Title="完成时间">@(context.Data.FinishedDate.HasValue ? context.Data.FinishedDate.Value.ToString("yyyy-MM-dd") : "")</DescriptionsItem>
                                                <DescriptionsItem Title="返稿日">@(context.Data.ReturnDate.HasValue ? context.Data.ReturnDate.Value.ToString("yyyy-MM-dd") : "")</DescriptionsItem>
                                                <DescriptionsItem Title="客户期限">@(context.Data.CustomerLimitDate.HasValue ? context.Data.CustomerLimitDate.Value.ToString("yyyy-MM-dd") : "")</DescriptionsItem>
                                                <DescriptionsItem Title="初稿日">@(context.Data.FirstDraftDate.HasValue ? context.Data.FirstDraftDate.Value.ToString("yyyy-MM-dd") : "")</DescriptionsItem>
                                                <DescriptionsItem Title="内部期限">@(context.Data.InternalDate.HasValue ? context.Data.InternalDate.Value.ToString("yyyy-MM-dd") : "")</DescriptionsItem>
                                                <DescriptionsItem Title="案件状态">@context.Data.CaseState</DescriptionsItem>
                                                <DescriptionsItem Title="处理事项备注">@context.Data.DoItemMemo</DescriptionsItem>
                                                <DescriptionsItem Title="案件名称" Span="2">@context.Data.CaseName</DescriptionsItem>
                                                <DescriptionsItem Title="申请人" Span="3">@context.Data.ApplicationName</DescriptionsItem>
                                                <DescriptionsItem Title="备注" Span="3">@context.Data.CaseMemo</DescriptionsItem>
                                            </Descriptions>
                                        </Body>
                                    </Card>
                                </div>
                            </ExpandTemplate>
                        </AntDesign.Table>
                    }
                }
            </Card>

        </ChildContent>
   
</PageContainer>

<style>
    .danger {
        background-color: #fa3d2c;
    }
</style>


