230 lines
8.5 KiB
Plaintext
230 lines
8.5 KiB
Plaintext
@page "/stock/list"
|
||
@using MasaBlazorApp3.Report
|
||
<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;
|
||
}
|
||
|
||
</style>
|
||
<div class="col-12 mb-4">
|
||
|
||
<form onsubmit="@(() => grid.Reload())">
|
||
<RadzenFieldset Text="@myText.Search">
|
||
<RadzenStack Orientation="Orientation.Horizontal" Gap="1rem">
|
||
<RadzenRow AlignItems="AlignItems.Center">
|
||
<RadzenColumn Size="4">
|
||
<RadzenLabel Text="@myText.StartDate" 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="@myText.EndDate" 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="6">
|
||
<RadzenLabel Text="@myText.DrugSearch" 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 Size="12">
|
||
@* <RadzenButton Size="ButtonSize.Large" ButtonType="ButtonType.Submit" IsBusy="isLoading" Icon="search" Text="查询" /> *@
|
||
<RadzenButton Size="ButtonSize.Large" Click="reloadGrid" IsBusy="isLoading" Icon="refresh" Text="@myText.Restore" ButtonStyle="ButtonStyle.Warning" />
|
||
</RadzenColumn>
|
||
</RadzenRow>
|
||
<RadzenRow JustifyContent="JustifyContent.End" AlignItems="AlignItems.Center">
|
||
<RadzenButton Icon="download" Text="@myText.StoreExport" Variant="Variant.Outlined" Click="StockExport" />
|
||
<RadzenButton Icon="download" Text="@myText.AccountExport" Variant="Variant.Outlined" Click="AccountBookExport" />
|
||
</RadzenRow>
|
||
</RadzenStack>
|
||
</RadzenFieldset>
|
||
</form>
|
||
</div>
|
||
<div class="col-12 mb-4">
|
||
|
||
<RadzenDataGrid @ref="grid"
|
||
IsLoading="@isLoading"
|
||
RowRender="@RowRender"
|
||
EmptyText="@myText.NoDate"
|
||
Data="@_forecasts"
|
||
AllowColumnResize="true" AllowAlternatingRows="false"
|
||
SelectionMode="DataGridSelectionMode.Single"
|
||
ExpandMode="DataGridExpandMode.Multiple">
|
||
@* <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="@myText.NoDate">
|
||
<Columns>
|
||
<RadzenDataGridColumn Title="@myText.StorageLocation" Property="DrawerNo">
|
||
<Template Context="s">
|
||
@s.DrawerNo - @s.ColNo
|
||
</Template>
|
||
</RadzenDataGridColumn>
|
||
<RadzenDataGridColumn Title="@myText.Quantity" Property="Quantity">
|
||
</RadzenDataGridColumn>
|
||
<RadzenDataGridColumn Title="@myText.Batch" Property="ManuNo"></RadzenDataGridColumn>
|
||
<RadzenDataGridColumn Title="@myText.Expiration" 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">@myText.AlertExpir!</p>
|
||
}
|
||
else
|
||
{
|
||
@s.EffDate
|
||
}
|
||
}
|
||
</Template>
|
||
</RadzenDataGridColumn>
|
||
</Columns>
|
||
</RadzenDataGrid>
|
||
</Template>
|
||
<Columns>
|
||
<RadzenDataGridColumn Frozen="true" Width="200px" Title="@myText.DrugName" Property="DrugName"></RadzenDataGridColumn>
|
||
<RadzenDataGridColumn Title="@myText.Spec" Property="DrugSpec"></RadzenDataGridColumn>
|
||
<RadzenDataGridColumn Title="@myText.TotalStock" Property="StockQuantity">
|
||
<Template Context="s">
|
||
@if (s.StockQuantity < 10)
|
||
{
|
||
@s.StockQuantity
|
||
|
||
<p class="shaky-text">@myText.AlertStock!</p>
|
||
}
|
||
else
|
||
{
|
||
@s.StockQuantity
|
||
}
|
||
</Template>
|
||
</RadzenDataGridColumn>
|
||
|
||
</Columns>
|
||
</RadzenDataGrid>
|
||
</div>
|
||
|
||
@code {
|
||
@inject IDrugInfoDao drugInfoDao;
|
||
@inject DialogService dialogService;
|
||
@inject IReportDataDao reportDataDao;
|
||
@inject Toolbelt.Blazor.I18nText.I18nText I18nText;
|
||
private I18nText.local myText = new I18nText.local();
|
||
RadzenDataGrid<DrugInfo> grid;
|
||
bool isLoading;
|
||
int count;
|
||
private IEnumerable<DrugInfo>? _forecasts;
|
||
DateTime? start;
|
||
DateTime? end;
|
||
|
||
string drugName;
|
||
|
||
IEnumerable<DrugInfo> drugInfo;
|
||
|
||
protected override async Task OnInitializedAsync()
|
||
{
|
||
myText = await I18nText.GetTextTableAsync<I18nText.local>(this);
|
||
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();
|
||
}
|
||
|
||
}
|