@page  "/StaffGrade"

@inject HttpClient Http
@using AntDesign.TableModels
@inject MessageService _message
@using System.ComponentModel
@using wispro.sp.share

@attribute [Authorize]
<PageContainer>
    <Breadcrumb>
        <Breadcrumb>
            <BreadcrumbItem>
                <a href="/Home"><Icon Type="home"></Icon></a>
            </BreadcrumbItem>
            <BreadcrumbItem>
                <Icon Type="setting"></Icon><span>基本信息管理</span>
            </BreadcrumbItem>
            <BreadcrumbItem>
                <Icon Type="user"></Icon><span>代理人系数设定</span>
            </BreadcrumbItem>
        </Breadcrumb>
    </Breadcrumb>
    <Content>
        <Button Type="primary" Icon="plus" OnClick="AddNew" Style="float:right">添加</Button>
    </Content>
    <ChildContent>
        @if (staffGrades == null)
        {
            <center><Spin /></center>

        }
        else
        {

            <AntDesign.Table @ref="table"
                             TItem="wispro.sp.entity.StaffGrade"
                             Loading="_loading"
                             DataSource="@staffGrades"
                             Total="_total"
                             @bind-SelectedRows="selectedRows"
                             OnRow="OnRow"
                             Bordered=@true
                             Size=@TableSize.Middle>
                <ChildContent>
                    <Selection Key="@(context.Id.ToString())" />
                    <AntDesign.Column Title="序号" TData="int" @bind-Field="@context.Id">

                    </AntDesign.Column>
                    <AntDesign.Column Title="代理人等级" @bind-Field="@context.Grade" Sortable Filterable />
                    <AntDesign.Column Title="代理人系数" @bind-Field="@context.Coefficient" Sortable Filterable />

                    <ActionColumn>
                        <Space>
                            <SpaceItem><Button Danger OnClick="()=>Edit(context.Id)">编辑</Button></SpaceItem>
                        </Space>
                    </ActionColumn>
                </ChildContent>

            </AntDesign.Table>

        }
    </ChildContent>
</PageContainer>

<Modal Title="修改"
       Visible="@_visible"
       OnOk="@HandleOk"
       OnCancel="@HandleCancel">

    <Form Model="EditingStaff" LabelColSpan="6"
          WrapperColSpan="16">
        @if (_isAdd)
        {
            <FormItem Label="代理人等级">
                <Input @bind-Value="@context.Grade" />
            </FormItem>
        }
        else
        {
            <FormItem Label="代理人等级">
                <span>@context.Grade</span>
            </FormItem>
        }

        <FormItem Label="等级系数">
            <Input @bind-Value="@context.Coefficient" />
        </FormItem>

    </Form>

</Modal>


