90 lines
3.0 KiB
Plaintext
90 lines
3.0 KiB
Plaintext
@using System.Collections.ObjectModel
|
|
@using AyCode.Core.Helpers
|
|
@using AyCode.Core.Loggers
|
|
@using AyCode.Utils.Extensions
|
|
@using FruitBank.Common.Dtos
|
|
@using FruitBank.Common.Entities
|
|
@using FruitBankHybrid.Shared.Components.Grids.Shippings
|
|
@using FruitBankHybrid.Shared.Components.Toolbars
|
|
@using FruitBankHybrid.Shared.Databases
|
|
@using FruitBankHybrid.Shared.Services.Loggers
|
|
@using FruitBankHybrid.Shared.Services.SignalRs
|
|
|
|
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
|
@inject FruitBankSignalRClient FruitBankSignalRClient
|
|
|
|
<GridStockTakingItemBase @ref="Grid" AutoSaveLayoutName="GridStockTakingItem" SignalRClient="FruitBankSignalRClient" Logger="_logger"
|
|
CssClass="@GridCss" ValidationEnabled="false"
|
|
FocusedRowChanged="Grid_FocusedRowChanged">
|
|
<Columns>
|
|
<DxGridDataColumn FieldName="Id" SortIndex="0" SortOrder="GridColumnSortOrder.Descending" ReadOnly="true" />
|
|
|
|
<DxGridDataColumn FieldName="StockTaking.StartDateTime" />
|
|
<DxGridDataColumn FieldName="Product.Name" />
|
|
<DxGridDataColumn FieldName="IsMeasured" />
|
|
<DxGridDataColumn FieldName="OriginalStockQuantity" />
|
|
<DxGridDataColumn FieldName="MeasuredStockQuantity" />
|
|
<DxGridDataColumn FieldName="OriginalNetWeight" />
|
|
<DxGridDataColumn FieldName="MeasuredNetWeight" />
|
|
|
|
<DxGridDataColumn FieldName="Created" ReadOnly="true" />
|
|
<DxGridDataColumn FieldName="Modified" ReadOnly="true" />
|
|
<DxGridCommandColumn Visible="!IsMasterGrid" Width="120"></DxGridCommandColumn>
|
|
</Columns>
|
|
<ToolbarTemplate>
|
|
@if (IsMasterGrid)
|
|
{
|
|
<FruitBankToolbarTemplate Grid="Grid" OnReloadDataClick="() => ReloadDataFromDb(true)" />
|
|
}
|
|
</ToolbarTemplate>
|
|
</GridStockTakingItemBase>
|
|
|
|
@code {
|
|
//[Inject] public required ObjectLock ObjectLock { get; set; }
|
|
[Inject] public required DatabaseClient Database { get; set; }
|
|
|
|
[Parameter] public bool IsMasterGrid { get; set; } = false;
|
|
[Parameter] public AcObservableCollection<Partner>? Partners { get; set; }
|
|
[Parameter] public AcObservableCollection<Shipping>? Shippings { get; set; }
|
|
|
|
const string ExportFileName = "ExportResult";
|
|
string GridSearchText = "";
|
|
bool EditItemsEnabled { get; set; }
|
|
int FocusedRowVisibleIndex { get; set; }
|
|
public GridStockTakingItemBase Grid { get; set; }
|
|
string GridCss => !IsMasterGrid ? "hide-toolbar" : string.Empty;
|
|
|
|
private int _activeTabIndex;
|
|
private LoggerClient<GridStockTakingItem> _logger;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
_logger = new LoggerClient<GridStockTakingItem>(LogWriters.ToArray());
|
|
await ReloadDataFromDb(false);
|
|
}
|
|
|
|
private async Task ReloadDataFromDb(bool forceReload = false)
|
|
{
|
|
if (!IsMasterGrid) return;
|
|
|
|
if (Grid == null) return;
|
|
|
|
//using (await ObjectLock.GetSemaphore<StockTakingItem>().UseWaitAsync())
|
|
//if (forceReload) await Grid.ReloadDataSourceAsync();
|
|
|
|
if (forceReload) Grid.Reload();
|
|
}
|
|
|
|
async Task Grid_FocusedRowChanged(GridFocusedRowChangedEventArgs args)
|
|
{
|
|
if (Grid == null) return;
|
|
|
|
if (Grid.IsEditing() && !Grid.IsEditingNewRow())
|
|
await Grid.SaveChangesAsync();
|
|
|
|
FocusedRowVisibleIndex = args.VisibleIndex;
|
|
EditItemsEnabled = true;
|
|
}
|
|
}
|
|
|