286 lines
		
	
	
		
			11 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
			
		
		
	
	
			286 lines
		
	
	
		
			11 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
@page "/stock/list"
 | 
						|
@using MasaBlazorApp3.Report
 | 
						|
@using Radzen.Blazor.Rendering
 | 
						|
<style>
 | 
						|
    @@keyframes shake {
 | 
						|
    0% {
 | 
						|
    opacity: 1;
 | 
						|
    color: red;
 | 
						|
    }
 | 
						|
 | 
						|
    25% {
 | 
						|
    opacity: 1;
 | 
						|
    color: orange;
 | 
						|
    }
 | 
						|
 | 
						|
    50% {
 | 
						|
    opacity: 0;
 | 
						|
    color: yellow;
 | 
						|
    }
 | 
						|
 | 
						|
    75% {
 | 
						|
    opacity: 1;
 | 
						|
    color: crimson;
 | 
						|
    }
 | 
						|
 | 
						|
    100% {
 | 
						|
    opacity: 1;
 | 
						|
    color: red;
 | 
						|
    }
 | 
						|
    }
 | 
						|
 | 
						|
    .rz-custom-header {
 | 
						|
    width: 100%;
 | 
						|
    }
 | 
						|
 | 
						|
    .shaky-text {
 | 
						|
    animation: shake 2s infinite ease-in-out;
 | 
						|
    /* 你可以根据需要调整动画的持续时间和迭代次数 */
 | 
						|
    transition: color 0.5s linear,opacity 0.5s linear;
 | 
						|
    }
 | 
						|
 | 
						|
    .my-popup {
 | 
						|
    display: none;
 | 
						|
    position: absolute;
 | 
						|
    overflow: auto;
 | 
						|
    /* height: 360px; */
 | 
						|
    width: 900px;
 | 
						|
    border: var(--rz-panel-border);
 | 
						|
    background-color: var(--rz-panel-background-color);
 | 
						|
    box-shadow: var(--rz-panel-shadow);
 | 
						|
    border-radius: var(--rz-border-radius);
 | 
						|
    }
 | 
						|
</style>
 | 
						|
<div class="col-12 mb-4">
 | 
						|
 | 
						|
    @*   <form onsubmit="@(() => grid.Reload())">
 | 
						|
        <RadzenFieldset Text="报表导出">
 | 
						|
            <RadzenStack Orientation="Orientation.Horizontal" Gap="1rem">
 | 
						|
                <RadzenRow JustifyContent="JustifyContent.End" AlignItems="AlignItems.Center">
 | 
						|
                    <RadzenButton @ref=button Icon="download" Text="专用账册导出" Variant="Variant.Outlined" Click="@(args => popup2.ToggleAsync(button.Element))" />                   
 | 
						|
                    <Popup @ref=popup2 Lazy=true class="my-popup">
 | 
						|
                        <RadzenStack Orientation="Orientation.Vertical" Gap="1rem" class="rz-h-100 rz-p-4">
 | 
						|
                            <RadzenFieldset Text="条件选择">
 | 
						|
                                <RadzenStack Orientation="Orientation.Horizontal" Gap="1rem">
 | 
						|
                                    <RadzenRow AlignItems="AlignItems.Center">
 | 
						|
                                        <RadzenColumn Size="4">
 | 
						|
                                            <RadzenLabel Text="开始" Component="Start" />
 | 
						|
                                            <RadzenLabel Text="时间" Component="Start" />
 | 
						|
                                        </RadzenColumn>
 | 
						|
                                        <RadzenColumn Size="8">
 | 
						|
                                            <RadzenDatePicker DateFormat="yyyy-MM-dd HH:mm:ss" ShowTime="true" @bind-Value="start" Style="width: 100%;" Name="Start" />
 | 
						|
                                        </RadzenColumn>
 | 
						|
                                    </RadzenRow>
 | 
						|
                                    <RadzenRow AlignItems="AlignItems.Center">
 | 
						|
                                        <RadzenColumn Size="4">
 | 
						|
                                            <RadzenLabel Text="结束" Component="End" />
 | 
						|
                                            <RadzenLabel Text="时间" Component="End" />
 | 
						|
                                        </RadzenColumn>
 | 
						|
                                        <RadzenColumn Size="8">
 | 
						|
                                            <RadzenDatePicker DateFormat="yyyy-MM-dd HH:mm:ss" ShowTime="true" @bind-Value="end" Style="width: 100%;" Name="End" />
 | 
						|
                                        </RadzenColumn>
 | 
						|
                                    </RadzenRow>
 | 
						|
                                    <RadzenRow AlignItems="AlignItems.Center">
 | 
						|
                                        <RadzenColumn Size="5">
 | 
						|
                                            <RadzenLabel Text="药品名称" Component="drug" />
 | 
						|
                                            <RadzenLabel Text="拼音码" Component="drug" />
 | 
						|
                                            <RadzenLabel Text="编码" Component="drug" />
 | 
						|
                                        </RadzenColumn>
 | 
						|
                                        <RadzenColumn Size="6">
 | 
						|
                                            <RadzenAutoComplete Name="drug" Multiline="true" @bind-Value=@drugName Data=@drugInfo TextProperty="@nameof(DrugInfo.DrugNameSpecManufactory)"
 | 
						|
                                                                Style="width: 100%;" InputAttributes="@(new Dictionary<string, object>() { { "aria-label", "drugInfo" } })" />
 | 
						|
                                        </RadzenColumn>
 | 
						|
                                    </RadzenRow>
 | 
						|
 | 
						|
                                    <RadzenRow AlignItems="AlignItems.Center">
 | 
						|
                                        <RadzenColumn>
 | 
						|
                                            <RadzenButton Click="reloadGrid" Icon="refresh" Text="重置" ButtonStyle="ButtonStyle.Warning" />
 | 
						|
                                        </RadzenColumn>
 | 
						|
                                    </RadzenRow>
 | 
						|
                                    <RadzenRow JustifyContent="JustifyContent.End" AlignItems="AlignItems.Center">
 | 
						|
                                        <RadzenButton Icon="download" Text="导出" Variant="Variant.Outlined" Click="AccountBookExport" />
 | 
						|
                                    </RadzenRow>
 | 
						|
                                </RadzenStack>
 | 
						|
                            </RadzenFieldset>
 | 
						|
                        </RadzenStack>
 | 
						|
                    </Popup>
 | 
						|
                </RadzenRow>
 | 
						|
            </RadzenStack>
 | 
						|
        </RadzenFieldset>
 | 
						|
    </form> *@
 | 
						|
</div>
 | 
						|
<div class="col-12 mb-4">
 | 
						|
 | 
						|
    <RadzenDataGrid @ref="grid"
 | 
						|
    IsLoading="@isLoading"
 | 
						|
    RowRender="@RowRender"
 | 
						|
    EmptyText="无数据"
 | 
						|
    Data="@_forecasts"
 | 
						|
    AllowColumnResize="true" AllowAlternatingRows="false"
 | 
						|
    SelectionMode="DataGridSelectionMode.Single"
 | 
						|
    ExpandMode="DataGridExpandMode.Single">
 | 
						|
        @* <HeaderTemplate>
 | 
						|
            <RadzenRow JustifyContent="JustifyContent.End" AlignItems="AlignItems.Center">
 | 
						|
                <RadzenButton Icon="download" Text="库存导出" Variant="Variant.Outlined" Click="StockExport" />
 | 
						|
                <RadzenButton Icon="download" Text="专用账册导出" Variant="Variant.Outlined" Click="AccountBookExport" />
 | 
						|
            </RadzenRow>
 | 
						|
        </HeaderTemplate> *@
 | 
						|
        <Template Context="di">
 | 
						|
            <RadzenDataGrid Data="@di.Stocks" EmptyText="无数据">
 | 
						|
                <Columns>
 | 
						|
                    <RadzenDataGridColumn Title="库位" Property="DrawerNo">
 | 
						|
                        <Template Context="s">
 | 
						|
                            @if (s.MachineId == "DM5")
 | 
						|
                            {
 | 
						|
                                switch (s.DrawerNo)
 | 
						|
                                {
 | 
						|
                                    case 99:
 | 
						|
                                        @("急诊药盒")
 | 
						|
                                        break;
 | 
						|
                                    case 111:
 | 
						|
                                        @("恢复室药盒")
 | 
						|
                                        break;
 | 
						|
                                    case 31:
 | 
						|
                                        @("胃镜药盒")
 | 
						|
                                        break;
 | 
						|
                                    case 32:
 | 
						|
                                        @("导管药盒")
 | 
						|
                                        break;
 | 
						|
                                    case 33:
 | 
						|
                                        @("生殖药盒")
 | 
						|
                                        break;
 | 
						|
                                    case 34:
 | 
						|
                                        @("妇门药盒")                                        
 | 
						|
                                        break;
 | 
						|
                                    default:
 | 
						|
                                        @* @($"{s.DrawerNo}-{(s.ColNo == 1 ? '白' : '绿')}") *@
 | 
						|
                                        @("常规神外药盒")
 | 
						|
                                        break;
 | 
						|
                                }
 | 
						|
 | 
						|
                            }
 | 
						|
                            else
 | 
						|
                            {
 | 
						|
                                @($"{s.DrawerNo}-{s.ColNo}")
 | 
						|
                            }
 | 
						|
                        </Template>
 | 
						|
                    </RadzenDataGridColumn>
 | 
						|
                    <RadzenDataGridColumn Title="数量" Property="Quantity">
 | 
						|
                    </RadzenDataGridColumn>
 | 
						|
                    <RadzenDataGridColumn Title="批次" Property="ManuNo"></RadzenDataGridColumn>
 | 
						|
                    <RadzenDataGridColumn Title="效期" Property="EffDate">
 | 
						|
                        <Template Context="s">
 | 
						|
                            @{
 | 
						|
                                DateTime dateTime;
 | 
						|
                                bool success = DateTime.TryParse(s.EffDate, out dateTime);
 | 
						|
                                // if (success && dateTime <= DateTime.Now.AddMonths(3))
 | 
						|
                                // {
 | 
						|
                                //     @s.EffDate
 | 
						|
 | 
						|
                                //     <p class="shaky-text">近效期药品!</p>
 | 
						|
                                // }
 | 
						|
                                // else
 | 
						|
                                //{
 | 
						|
                                @s.EffDate
 | 
						|
                                //}
 | 
						|
                            }
 | 
						|
                        </Template>
 | 
						|
                    </RadzenDataGridColumn>
 | 
						|
                </Columns>
 | 
						|
            </RadzenDataGrid>
 | 
						|
        </Template>
 | 
						|
        <Columns>
 | 
						|
            <RadzenDataGridColumn Frozen="true" Width="200px" Title="药品名称" Property="DrugName"></RadzenDataGridColumn>
 | 
						|
            <RadzenDataGridColumn Title="规格" Property="DrugSpec"></RadzenDataGridColumn>
 | 
						|
            <RadzenDataGridColumn Title="总库存" Property="StockQuantity">
 | 
						|
                <Template Context="s">
 | 
						|
                    @*   @if (s.StockQuantity < 10)
 | 
						|
                    {
 | 
						|
                        @s.StockQuantity
 | 
						|
 | 
						|
                        <p class="shaky-text">库存预警!</p>
 | 
						|
                    }
 | 
						|
                    else
 | 
						|
                    { *@
 | 
						|
                    @s.StockQuantity
 | 
						|
                    @* } *@
 | 
						|
                </Template>
 | 
						|
            </RadzenDataGridColumn>
 | 
						|
 | 
						|
        </Columns>
 | 
						|
    </RadzenDataGrid>
 | 
						|
</div>
 | 
						|
 | 
						|
@code {
 | 
						|
    @inject IDrugInfoDao drugInfoDao;
 | 
						|
    @inject DialogService dialogService;
 | 
						|
    @inject IReportDataDao reportDataDao;
 | 
						|
    RadzenDataGrid<DrugInfo> grid;
 | 
						|
    bool isLoading;
 | 
						|
    int count;
 | 
						|
    private IEnumerable<DrugInfo>? _forecasts;
 | 
						|
    DateTime? start;
 | 
						|
    DateTime? end;
 | 
						|
 | 
						|
    string drugName;
 | 
						|
    RadzenButton button;
 | 
						|
 | 
						|
    Popup popup2;
 | 
						|
    IEnumerable<DrugInfo> drugInfo;
 | 
						|
 | 
						|
    protected override async Task OnInitializedAsync()
 | 
						|
    {
 | 
						|
        await base.OnInitializedAsync();
 | 
						|
        isLoading = true;
 | 
						|
 | 
						|
        var result = await drugInfoDao.GetAllDrugAndStock();
 | 
						|
        // Update the Data property
 | 
						|
        _forecasts = result;
 | 
						|
 | 
						|
        drugInfo = await drugInfoDao.GetAllDrug();
 | 
						|
 | 
						|
        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<DrugInfo> args)
 | 
						|
    {
 | 
						|
        args.Expandable = args.Data.Stocks.Count > 0;
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    // //库存导出
 | 
						|
    // async Task StockExport()
 | 
						|
    // {
 | 
						|
    //     PageData<ReportStockDateInfo> pageData = await reportDataDao.GetStockExportData(drugName);
 | 
						|
    //     GridReportUtil.PrintReport("stock_template.grf", pageData);
 | 
						|
    // }
 | 
						|
    //专用账册导出
 | 
						|
    async Task AccountBookExport()
 | 
						|
    {
 | 
						|
        // string drugId = drugName != null ? drugName.Split('/').Last().Trim():"";
 | 
						|
        // GridReportUtil gridReportUtil = new GridReportUtil();
 | 
						|
        PageData<ReportAccountDateInfo> pageData = await reportDataDao.GetAccountExportData(start, end, drugName);
 | 
						|
        GridReportUtil.PrintReport("account_book_temp.grf", pageData);
 | 
						|
    }
 | 
						|
 | 
						|
    //重置
 | 
						|
    async Task reloadGrid()
 | 
						|
    {
 | 
						|
        start = DateTime.MinValue;
 | 
						|
        end = DateTime.MinValue;
 | 
						|
        drugName = string.Empty;
 | 
						|
        await grid.Reload();
 | 
						|
    }
 | 
						|
 | 
						|
}
 |