* Fixed Focus issues in Grid
This commit is contained in:
@@ -94,3 +94,12 @@ main {
|
|||||||
right: 0.75rem;
|
right: 0.75rem;
|
||||||
top: 0.5rem;
|
top: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.e-grid .e-row.e-selection {
|
||||||
|
background-color: #D3D3D3 !important; /* Jasny szary */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Domyślny styl dla wierszy (na wszelki wypadek) */
|
||||||
|
.e-grid .e-row {
|
||||||
|
background-color: #FFFFFF; /* Biały, domyślny kolor */
|
||||||
|
}
|
||||||
|
|||||||
@@ -53,7 +53,8 @@
|
|||||||
<ToolbarItem Type="ItemType.Button" Text="Zapisz zmiany" Id="SaveButton"
|
<ToolbarItem Type="ItemType.Button" Text="Zapisz zmiany" Id="SaveButton"
|
||||||
PrefixIcon="e-icons e-save" OnClick="SaveChanges"/>
|
PrefixIcon="e-icons e-save" OnClick="SaveChanges"/>
|
||||||
<ToolbarItem Type="ItemType.Button" Text="Podziel Linię" Id="SplitLineButton"
|
<ToolbarItem Type="ItemType.Button" Text="Podziel Linię" Id="SplitLineButton"
|
||||||
PrefixIcon="e-icons e-split-horizontal" OnClick="ShowSplitDialog" Disabled="IsDisabled"/>
|
PrefixIcon="e-icons e-split-horizontal" OnClick="ShowSplitDialog"
|
||||||
|
Disabled="IsDisabled"/>
|
||||||
<ToolbarItem Type="ItemType.Button" Id="Generuj XLS i Wyślij" PrefixIcon="e-icons e-export-xls"
|
<ToolbarItem Type="ItemType.Button" Id="Generuj XLS i Wyślij" PrefixIcon="e-icons e-export-xls"
|
||||||
Text="Generuj XLS i Wyślij" OnClick="ExportXls"/>
|
Text="Generuj XLS i Wyślij" OnClick="ExportXls"/>
|
||||||
</ToolbarItems>
|
</ToolbarItems>
|
||||||
@@ -72,7 +73,8 @@
|
|||||||
HeaderText="Ilość w Dostawie" Width="80"></GridColumn>
|
HeaderText="Ilość w Dostawie" Width="80"></GridColumn>
|
||||||
<GridColumn Field=@nameof(WzRowMeyleDto.PalletNumber) AllowEditing="true"
|
<GridColumn Field=@nameof(WzRowMeyleDto.PalletNumber) AllowEditing="true"
|
||||||
TextAlign="TextAlign.Center" HeaderText="Nr Palety" Width="100"></GridColumn>
|
TextAlign="TextAlign.Center" HeaderText="Nr Palety" Width="100"></GridColumn>
|
||||||
<GridColumn Field=@nameof(WzRowMeyleDto.PartNumberSl) AllowEditing="true" TextAlign="TextAlign.Center"
|
<GridColumn Field=@nameof(WzRowMeyleDto.PartNumberSl) AllowEditing="true"
|
||||||
|
TextAlign="TextAlign.Center"
|
||||||
HeaderText="Nr Partii SL" Width="80"></GridColumn>
|
HeaderText="Nr Partii SL" Width="80"></GridColumn>
|
||||||
<GridColumn Field=@nameof(WzRowMeyleDto.PartNumber) AllowEditing="true" TextAlign="TextAlign.Center"
|
<GridColumn Field=@nameof(WzRowMeyleDto.PartNumber) AllowEditing="true" TextAlign="TextAlign.Center"
|
||||||
HeaderText="Nr Partii Meyle" Width="80"></GridColumn>
|
HeaderText="Nr Partii Meyle" Width="80"></GridColumn>
|
||||||
@@ -121,8 +123,10 @@
|
|||||||
<p>Błąd skanowania! Wystąpił jeden z wyjątków (Zeskanowana wartość '<b>@ScannedValue</b>'):</p>
|
<p>Błąd skanowania! Wystąpił jeden z wyjątków (Zeskanowana wartość '<b>@ScannedValue</b>'):</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><p>Zeskanowano niepoprawny Numer Partii SL (nieistniejący w tabeli)</p></li>
|
<li><p>Zeskanowano niepoprawny Numer Partii SL (nieistniejący w tabeli)</p></li>
|
||||||
<li><p>Zeskanowano niepoprawny numer Partii Meyle (niezaczynający się od <b>@($"{DateTime.Now.Year - 2000}X")</b>)</p></li>
|
<li><p>Zeskanowano niepoprawny numer Partii Meyle (niezaczynający się od
|
||||||
<li><p>Numer Palety nie jest większy niż 0 (aktualnie wybrany numer palety: '<b>@PalletNumber</b>')</p></li>
|
<b>@($"{DateTime.Now.Year - 2000}X")</b>)</p></li>
|
||||||
|
<li><p>Numer Palety nie jest większy niż 0 (aktualnie wybrany numer palety:
|
||||||
|
'<b>@PalletNumber</b>')</p></li>
|
||||||
</ul>
|
</ul>
|
||||||
</Content>
|
</Content>
|
||||||
</DialogTemplates>
|
</DialogTemplates>
|
||||||
@@ -131,10 +135,24 @@
|
|||||||
</DialogButtons>
|
</DialogButtons>
|
||||||
</SfDialog>
|
</SfDialog>
|
||||||
|
|
||||||
<SfDialog Width="500px" Title="Podziel Linię" IsModal="true" @bind-Visible="VisibilityLineSplitter" AllowPrerender="true">
|
<SfDialog Width="500px" Title="Błąd" IsModal="true" @bind-Visible="VisibilityPalletNumber"
|
||||||
|
AllowPrerender="true">
|
||||||
<DialogTemplates>
|
<DialogTemplates>
|
||||||
<Content>
|
<Content>
|
||||||
<label for="textBox" class="form-label">Podziel linię <b>@SelectedRow?.FaIndex</b> podając ilość sztuk dla nowej linii:</label>
|
<p>Błąd skanowania! <b>Wybierz NUMER PALETY większy niż 0</b> (Aktualnie '@PalletNumber'):</p>
|
||||||
|
</Content>
|
||||||
|
</DialogTemplates>
|
||||||
|
<DialogButtons>
|
||||||
|
<DialogButton Content="OK" IsPrimary="true" OnClick="@HideModal"/>
|
||||||
|
</DialogButtons>
|
||||||
|
</SfDialog>
|
||||||
|
|
||||||
|
<SfDialog Width="500px" Title="Podziel Linię" IsModal="true" @bind-Visible="VisibilityLineSplitter"
|
||||||
|
AllowPrerender="true">
|
||||||
|
<DialogTemplates>
|
||||||
|
<Content>
|
||||||
|
<label for="textBox" class="form-label">Podziel linię <b>@SelectedRow?.FaIndex</b> podając ilość
|
||||||
|
sztuk dla nowej linii:</label>
|
||||||
<SfTextBox ID="newQuantity" Type="InputType.Number" @bind-Value="@NewQuantity"
|
<SfTextBox ID="newQuantity" Type="InputType.Number" @bind-Value="@NewQuantity"
|
||||||
CssClass="e-outline"/>
|
CssClass="e-outline"/>
|
||||||
</Content>
|
</Content>
|
||||||
@@ -171,6 +189,7 @@
|
|||||||
private bool Visibility { get; set; }
|
private bool Visibility { get; set; }
|
||||||
private bool VisibilityValidation { get; set; }
|
private bool VisibilityValidation { get; set; }
|
||||||
private bool VisibilityLineSplitter { get; set; }
|
private bool VisibilityLineSplitter { get; set; }
|
||||||
|
public bool VisibilityPalletNumber { get; set; }
|
||||||
|
|
||||||
private string? EmailAddresses { get; set; } = string.Empty;
|
private string? EmailAddresses { get; set; } = string.Empty;
|
||||||
private string PalletNumber { get; set; } = "0";
|
private string PalletNumber { get; set; } = "0";
|
||||||
@@ -187,6 +206,7 @@
|
|||||||
Visibility = false;
|
Visibility = false;
|
||||||
VisibilityValidation = false;
|
VisibilityValidation = false;
|
||||||
VisibilityLineSplitter = false;
|
VisibilityLineSplitter = false;
|
||||||
|
VisibilityPalletNumber = false;
|
||||||
|
|
||||||
LastScannedValue = ScannedValue;
|
LastScannedValue = ScannedValue;
|
||||||
ScannedValue = string.Empty;
|
ScannedValue = string.Empty;
|
||||||
@@ -258,7 +278,7 @@
|
|||||||
if (string.IsNullOrWhiteSpace(obj.Value)) return;
|
if (string.IsNullOrWhiteSpace(obj.Value)) return;
|
||||||
if (int.Parse(PalletNumber) <= 0)
|
if (int.Parse(PalletNumber) <= 0)
|
||||||
{
|
{
|
||||||
ShowValidationMessage();
|
VisibilityPalletNumber = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,13 +326,12 @@
|
|||||||
return scannedValue.StartsWith(format);
|
return scannedValue.StartsWith(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FillMeylePartNumber(string scannedValue)
|
private async Task FillMeylePartNumber(string scannedValue)
|
||||||
{
|
{
|
||||||
if (SelectedRow != null)
|
var rowIndex = WzRowsMeyle.FindIndex(x => x.FaIndex == SelectedRow?.FaIndex && x.Quantity == SelectedRow?.Quantity);
|
||||||
{
|
|
||||||
var rowIndex = WzRowsMeyle.FindIndex(x => x.FaIndex == SelectedRow?.ItemNumber && x.Quantity == SelectedRow?.Quantity);
|
|
||||||
FocusGridRow(rowIndex);
|
|
||||||
|
|
||||||
|
if (SelectedRow != null && !SelectedRows.Any())
|
||||||
|
{
|
||||||
SelectedRow.PartNumber = scannedValue;
|
SelectedRow.PartNumber = scannedValue;
|
||||||
ChangedRecords.Add(SelectedRow);
|
ChangedRecords.Add(SelectedRow);
|
||||||
}
|
}
|
||||||
@@ -323,24 +342,27 @@
|
|||||||
ChangedRecords.Add(wzRowMeyleDto);
|
ChangedRecords.Add(wzRowMeyleDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveChanges();
|
await SaveChanges();
|
||||||
InvokeAsync(StateHasChanged);
|
|
||||||
_grid.Refresh();
|
|
||||||
_scanner.FocusAsync();
|
|
||||||
ChangedRecords.Clear();
|
ChangedRecords.Clear();
|
||||||
|
SelectedRows.Clear();
|
||||||
|
|
||||||
|
FocusGridRow(rowIndex);
|
||||||
|
await _scanner.FocusAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FillFaPartNumberAndPalletNumber(TransactionModel materialTransactionByPartNumber, string scannedValue)
|
private async Task FillFaPartNumberAndPalletNumber(TransactionModel materialTransactionByPartNumber, string scannedValue)
|
||||||
{
|
{
|
||||||
var rowIndex = WzRowsMeyle.FindIndex(x => x.FaIndex == materialTransactionByPartNumber.ItemNumber && x.Quantity == materialTransactionByPartNumber.Quantity);
|
await _grid.ClearSelectionAsync();
|
||||||
|
await _grid.Refresh();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
|
||||||
|
List<int> selectedIndices = new List<int>();
|
||||||
|
int palletNumber = int.Parse(PalletNumber);
|
||||||
|
int rowIndex = WzRowsMeyle.FindIndex(x => x.FaIndex == materialTransactionByPartNumber.ItemNumber && x.Quantity == materialTransactionByPartNumber.Quantity);
|
||||||
|
|
||||||
switch (rowIndex)
|
switch (rowIndex)
|
||||||
{
|
{
|
||||||
case -1 when int.Parse(PalletNumber) <= 0:
|
|
||||||
ShowValidationMessage();
|
|
||||||
LastScannedValue = ScannedValue;
|
|
||||||
ScannedValue = string.Empty;
|
|
||||||
return;
|
|
||||||
case -1:
|
case -1:
|
||||||
{
|
{
|
||||||
SelectedRows = WzRowsMeyle.Where(x => x.FaIndex == materialTransactionByPartNumber.ItemNumber).ToList();
|
SelectedRows = WzRowsMeyle.Where(x => x.FaIndex == materialTransactionByPartNumber.ItemNumber).ToList();
|
||||||
@@ -351,22 +373,38 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (WzRowMeyleDto wzRowMeyleDto in SelectedRows)
|
rowIndex = WzRowsMeyle.FindIndex(x => x.FaIndex == SelectedRows.First().FaIndex && x.Quantity == SelectedRows.First().Quantity);
|
||||||
|
|
||||||
|
var validCombinations = FindCombinations(SelectedRows, (int?)materialTransactionByPartNumber.Quantity ?? 0);
|
||||||
|
|
||||||
|
foreach (var combination in validCombinations)
|
||||||
{
|
{
|
||||||
wzRowMeyleDto.PartNumberSl = scannedValue;
|
foreach (var record in combination)
|
||||||
ChangedRecords.Add(wzRowMeyleDto);
|
{
|
||||||
|
record.PartNumberSl = scannedValue;
|
||||||
|
ChangedRecords.Add(record);
|
||||||
|
|
||||||
|
int index = WzRowsMeyle.IndexOf(record);
|
||||||
|
if (index >= 0)
|
||||||
|
{
|
||||||
|
selectedIndices.Add(index);
|
||||||
|
Console.WriteLine($"Dodano indeks: {index}"); // Debugowanie
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectedRows.Clear();
|
||||||
|
SelectedRows.AddRange(ChangedRecords);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
FocusGridRow(rowIndex);
|
|
||||||
|
|
||||||
SelectedRow = WzRowsMeyle[rowIndex];
|
SelectedRow = WzRowsMeyle[rowIndex];
|
||||||
|
selectedIndices.Add(rowIndex);
|
||||||
|
|
||||||
SelectedRow.PartNumberSl = ScannedValue;
|
SelectedRow.PartNumberSl = scannedValue;
|
||||||
SelectedRow.PalletNumber = int.Parse(PalletNumber);
|
SelectedRow.PalletNumber = palletNumber;
|
||||||
|
|
||||||
if (ChangedRecords.All(x => x.TransactionNumber != SelectedRow.TransactionNumber))
|
if (ChangedRecords.All(x => x.TransactionNumber != SelectedRow.TransactionNumber))
|
||||||
{
|
{
|
||||||
@@ -377,11 +415,19 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveChanges();
|
await SaveChanges();
|
||||||
InvokeAsync(StateHasChanged);
|
|
||||||
_grid.Refresh();
|
|
||||||
_scanner.FocusAsync();
|
|
||||||
ChangedRecords.Clear();
|
ChangedRecords.Clear();
|
||||||
|
|
||||||
|
if (selectedIndices.Any())
|
||||||
|
{
|
||||||
|
await _grid.SelectRowsAsync(selectedIndices.ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
await _grid.Refresh();
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
|
||||||
|
FocusGridRow(rowIndex);
|
||||||
|
await _scanner.FocusAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FocusGridRow(int rowIndex)
|
private void FocusGridRow(int rowIndex)
|
||||||
@@ -438,7 +484,9 @@
|
|||||||
OrderNumber = SelectedRow.OrderNumber,
|
OrderNumber = SelectedRow.OrderNumber,
|
||||||
PalletNumber = SelectedRow.PalletNumber,
|
PalletNumber = SelectedRow.PalletNumber,
|
||||||
WzNumber = SelectedRow.WzNumber,
|
WzNumber = SelectedRow.WzNumber,
|
||||||
TransactionNumber = SelectedRow.TransactionNumber += 10000
|
TransactionNumber = SelectedRow.TransactionNumber += 10000,
|
||||||
|
PartNumberSl = SelectedRow.PartNumberSl,
|
||||||
|
PartNumber = SelectedRow.PartNumber
|
||||||
};
|
};
|
||||||
|
|
||||||
WzRowsMeyle.Add(splitRow);
|
WzRowsMeyle.Add(splitRow);
|
||||||
@@ -464,4 +512,32 @@
|
|||||||
SelectedRow = obj.Data;
|
SelectedRow = obj.Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<List<WzRowMeyleDto>> FindCombinations(List<WzRowMeyleDto> records, int targetSum)
|
||||||
|
{
|
||||||
|
var result = new List<List<WzRowMeyleDto>>();
|
||||||
|
var currentCombination = new List<WzRowMeyleDto>();
|
||||||
|
|
||||||
|
void Backtrack(int start, int currentSum)
|
||||||
|
{
|
||||||
|
if (currentSum == targetSum)
|
||||||
|
{
|
||||||
|
result.Add(new List<WzRowMeyleDto>(currentCombination));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = start; i < records.Count; i++)
|
||||||
|
{
|
||||||
|
if (currentSum + records[i].Quantity <= targetSum)
|
||||||
|
{
|
||||||
|
currentCombination.Add(records[i]);
|
||||||
|
Backtrack(i + 1, currentSum + records[i].Quantity ?? 0);
|
||||||
|
currentCombination.RemoveAt(currentCombination.Count - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Backtrack(0, 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user