@page  "/CustomerList"

@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 (_Customers == null)
        {
            <center><Spin /></center>
        }
        else
        {

            <AntDesign.Table @ref="table"
                             TItem="wispro.sp.entity.Customer"
                             Loading="_loading"
                             DataSource="@_Customers"
                             Total="_total"
                             @bind-SelectedRows="selectedRows"
                             OnRow="OnRow"
                             Bordered=@true
                             Size=@TableSize.Middle>
                <ChildContent>
                    <Selection Key="@(context.Id.ToString())" />
                    <AntDesign.Column Title="公司名称" @bind-Field="@context.Name" Sortable Filterable />
                    <AntDesign.Column Title="地址" @bind-Field="@context.Address" Sortable Filterable />
                    <AntDesign.Column Title="联系人" @bind-Field="@context.ContactMan" Sortable Filterable />
                    <AntDesign.Column Title="电话" @bind-Field="@context.Phone" Sortable Filterable />
                    @*<AntDesign.Column Title="负责人" @bind-Field="@context.ResponseMan.Name" 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="Editing" LabelColSpan="6"
          WrapperColSpan="16">

        <FormItem Label="公司名称">
            <Input @bind-Value="@context.Name" />
        </FormItem>

        <FormItem Label="联系地址">
            <Input @bind-Value="@context.Address" />
        </FormItem>

        <FormItem Label="电话">
            <Input @bind-Value="@context.Phone" />
        </FormItem>

        <FormItem Label="联系人">
            <Input @bind-Value="@context.ContactMan" />
        </FormItem>

        <FormItem Label="负责人">
            @if (context.ResponseMan == null)
            {
                context.ResponseMan = new Staff();
            }
            <Input @bind-Value="@context.ResponseMan.Name" />
        </FormItem>

    </Form>

</Modal>




