@page "/app/record"
@attribute [ReuseTabsPage(Title = "交易记录")]


<Spin Spinning="Loading">
    <Table @ref="Table" AutoHeight TItem="TRecord" @bind-PageSize="Ps"
           @bind-PageIndex="Pi" Total="Total" DataSource="DataSource" @bind-SelectedRows="SelectedRows" OnChange="OnChange">
        <TitleTemplate>
            <Flex Justify="FlexJustify.Start" Gap="@("10")">
                <Input Width="300" Placeholder="油枪号" @bind-Value="@Q_Nozzle" />
                <Button OnClick="Search">搜索</Button>
                <Button OnClick="ResetQuery">重置</Button>

            </Flex>
        </TitleTemplate>
        <ColumnDefinitions Context="row">
            <PropertyColumn Align="ColumnAlign.Center" Property="c=>c.Id" Width="100" Title="ID" />
            <PropertyColumn Align="ColumnAlign.Center" Property="c=>c.fip" Title="油机号" />
            <PropertyColumn Align="ColumnAlign.Center" Property="c=>c.board" Title="主板号" />
			<PropertyColumn Align="ColumnAlign.Center" Property="c=>c.noz" Title="油枪号" />
            <PropertyColumn Align="ColumnAlign.Center" Property="c => c.tmEnd" Title="交易时间">
                @{
                    DateTime specificTime = new DateTime(1900, 1, 1, 0, 0, 0);
                    string tmEnd = row.tmEnd == specificTime?"":row.tmEnd.ToString("yyyy-MM-dd HH:mm:ss");//?.ToString("yyyy-MM-dd HH:mm:ss") ?? "N/A";
                }
                @tmEnd
            </PropertyColumn>
            <PropertyColumn Align="ColumnAlign.Center" Property="c => c.tmBegin" Title="提枪时间">
                @{
                    DateTime specificTime = new DateTime(1900, 1, 1, 0, 0, 0);
                    string tmBegin = row.tmBegin == specificTime ? "" : row.tmBegin.ToString("yyyy-MM-dd HH:mm:ss");//?.ToString("yyyy-MM-dd HH:mm:ss") ?? "N/A";
                }
                @tmBegin
            </PropertyColumn>
			<PropertyColumn Align="ColumnAlign.Center" Property="c=>c.vlr" Title="气液比">
				@{var vlr = (row.vlr / 1000.0).ToString("F2");
                } @vlr
            </PropertyColumn>
            <PropertyColumn Align="ColumnAlign.Center" Property="c=>c.ttc" Title="TTC" />
            <PropertyColumn Align="ColumnAlign.Center" Property="c=>c.noz" Title="气流量" >
                @{var qll = (row.vaporVl/100.0).ToString("F2");
                } @qll</PropertyColumn>
            <PropertyColumn Align="ColumnAlign.Center" Property="c=>c.noz" Title="油流量" >
                @{var yll = (row.liquidVl/100.0).ToString("F2");
                } @yll</PropertyColumn>
            <PropertyColumn Align="ColumnAlign.Center" Property="c=>c.noz" Title="气流速" >
                @{var qls = (row.vaporFr/10.0).ToString("F2");
                } @qls</PropertyColumn>
            <PropertyColumn Align="ColumnAlign.Center" Property="c=>c.noz" Title="油流速" >
                @{var yls = (row.liquidFr/10.0).ToString("F2");
                } @yls</PropertyColumn>
            <PropertyColumn Align="ColumnAlign.Center" Property="c => c.CreateTime" Title="创建时间">
                @{
                    var formattedTime = row.CreateTime?.ToString("yyyy-MM-dd HH:mm:ss") ?? "N/A";
                }
                @formattedTime
            </PropertyColumn>
        </ColumnDefinitions>
        <PaginationTemplate>
            <Pagination Class="@(context.PaginationClass + " my-custom-pagination")"
                        Total="context.Total"
                        PageSize="context.PageSize"
                        Current="context.PageIndex"
                        ShowSizeChanger
                        ShowQuickJumper
                        ShowTotal="ShowTotal"
                        OnChange="context.HandlePageChange" />
        </PaginationTemplate>
    </Table>
</Spin>

@inject ModalService ModalService;
@inject ConfirmService ComfirmService;
@inject IMessageService MessageService;

@code {

   

    private async Task<bool> Comfirm(string message)
    {
        return await ComfirmService.Show(message, "提示", ConfirmButtons.YesNo, ConfirmIcon.Warning) == ConfirmResult.Yes;
    }
}
