@page "/Box/BoxAdd"
@using MasaBlazorApp3.Report
@using Radzen.Blazor.Rendering
    
        
            
                
                
            
        
    
    
        
            
                
                    
                    
                    
                    
                    
                    
                    @*  
                    
                     *@
                    
                    
                    
                    
                
            
        
        
            
                
                    @($"{DrawerNo.DrawerNo}-{DrawerNo.ColNo}")
                
            
            
        
    
@code {
    @inject IChannelListDao channelStockDao;
    @inject DialogService dialogService;
    @inject IReportDataDao reportDataDao;
    RadzenDataGrid grid;
    bool isLoading;
    int count;
    private IEnumerable? _forecasts;
    DateTime start;
    DateTime end;
    RadzenButton button;
    Popup popup;
    IList selectedChannelLists;
    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();
    }
    async Task LoadData(LoadDataArgs args)
    {
        isLoading = true;
        var result = await channelStockDao.GetAllBoxAddDrug(args.Top, args.Skip);
        // Update the Data property
        _forecasts = result.Desserts;
        isLoading = false;
    }
    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        base.OnAfterRender(firstRender);
        if (firstRender)
        {
            // await grid.ExpandRows(grid.PagedView.Where(di => di.Stocks.Count > 0));
        }
    }
    void RowRender(RowRenderEventArgs args)
    {
        args.Expandable = args.Data.ChannelStocks.Count > 0;
    }
    async void OnRowSelect(ChannelList cl)
    {
        var b = await dialogService.OpenAsync(
               $"{cl.DrawerNo}号药盒加药",
             new Dictionary() { { "boxChannelList", cl } },
             new DialogOptions() { Width = "85vw", Resizable = true, Draggable = true, ShowClose = false }
       );
        if (b)
        {
            await grid.Reload();
        }
    }
    //请领登记表导出
    async Task AccountBookExport()
    {
        // string drugId = drugName != null ? drugName.Split('/').Last().Trim():"";
        // GridReportUtil gridReportUtil = new GridReportUtil();
        PageData pageData = await reportDataDao.GetApplyInfoDate(start);
        GridReportUtil.PrintReport("account_book_temp.grf", pageData);
    }
}